Map asciidoc level 5 section so it can be shown in the sidebar
[geany-mirror.git] / src / tagmanager / tm_parser.c
blob9f3be4fcd09be0ace5cab3a90898daead5aa2f96
1 /*
2 * tm_parser.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2016 The Geany contributors
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "tm_parser.h"
22 #include "tm_ctags.h"
24 #include <string.h>
26 #include "config.h"
29 #ifdef GETTEXT_PACKAGE
30 # include <glib/gi18n-lib.h>
31 #else
32 # define _(String) String
33 # define N_(String) String
34 #endif
36 typedef struct
38 const gchar kind;
39 TMTagType type;
40 } TMParserMapEntry;
42 /* Allows remapping a subparser tag type to another type if there's a clash with
43 * the master parser tag type. Only subparser tag types explicitly listed within
44 * TMSubparserMapEntry maps are added to tag manager - tags with types not listed
45 * are discarded to prevent uncontrolled merging of tags from master parser and
46 * subparsers. */
47 typedef struct
49 TMTagType orig_type;
50 TMTagType new_type;
51 } TMSubparserMapEntry;
53 typedef struct
55 const gchar *name;
56 guint icon;
57 TMTagType types;
58 } TMParserMapGroup;
60 static GHashTable *subparser_map = NULL;
63 #define COMMON_C \
64 {'d', tm_tag_macro_t}, /* macro */ \
65 {'e', tm_tag_enumerator_t}, /* enumerator */ \
66 {'f', tm_tag_function_t}, /* function */ \
67 {'g', tm_tag_enum_t}, /* enum */ \
68 {'m', tm_tag_member_t}, /* member */ \
69 {'p', tm_tag_prototype_t}, /* prototype */ \
70 {'s', tm_tag_struct_t}, /* struct */ \
71 {'t', tm_tag_typedef_t}, /* typedef */ \
72 {'u', tm_tag_union_t}, /* union */ \
73 {'v', tm_tag_variable_t}, /* variable */ \
74 {'x', tm_tag_externvar_t}, /* externvar */ \
75 {'h', tm_tag_include_t}, /* header */ \
76 {'l', tm_tag_local_var_t}, /* local */ \
77 {'z', tm_tag_local_var_t}, /* parameter */ \
78 {'L', tm_tag_undef_t}, /* label */ \
79 {'D', tm_tag_undef_t}, /* macroparam */
81 static TMParserMapEntry map_C[] = {
82 COMMON_C
84 /* Used also by other languages than C - keep all the tm_tag_* here even though
85 * they aren't used by C as they might be used by some other language */
86 static TMParserMapGroup group_C[] = {
87 {N_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t | tm_tag_package_t | tm_tag_include_t},
88 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
89 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
90 {N_("Functions"), TM_ICON_METHOD, tm_tag_prototype_t | tm_tag_method_t | tm_tag_function_t},
91 {N_("Members"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_field_t},
92 {N_("Structs"), TM_ICON_STRUCT, tm_tag_union_t | tm_tag_struct_t},
93 {N_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t | tm_tag_enum_t},
94 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t | tm_tag_macro_with_arg_t},
95 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t | tm_tag_local_var_t},
96 {N_("Extern Variables"), TM_ICON_VAR, tm_tag_externvar_t},
97 {N_("Other"), TM_ICON_OTHER, tm_tag_other_t},
100 static TMParserMapEntry map_CPP[] = {
101 COMMON_C
102 {'c', tm_tag_class_t}, // class
103 {'n', tm_tag_namespace_t}, // namespace
104 {'A', tm_tag_undef_t}, // alias
105 {'N', tm_tag_undef_t}, // name
106 {'U', tm_tag_undef_t}, // using
107 {'Z', tm_tag_undef_t}, // tparam
109 #define group_CPP group_C
111 static TMParserMapEntry map_JAVA[] = {
112 {'c', tm_tag_class_t}, // class
113 {'f', tm_tag_field_t}, // field
114 {'i', tm_tag_interface_t}, // interface
115 {'m', tm_tag_method_t}, // method
116 {'p', tm_tag_package_t}, // package
117 {'e', tm_tag_enumerator_t}, // enumConstant
118 {'g', tm_tag_enum_t}, // enum
120 static TMParserMapGroup group_JAVA[] = {
121 {N_("Package"), TM_ICON_NAMESPACE, tm_tag_package_t},
122 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
123 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
124 {N_("Methods"), TM_ICON_METHOD, tm_tag_method_t},
125 {N_("Members"), TM_ICON_MEMBER, tm_tag_field_t},
126 {N_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
127 {N_("Other"), TM_ICON_VAR, tm_tag_enumerator_t},
130 // no scope information
131 static TMParserMapEntry map_MAKEFILE[] = {
132 {'m', tm_tag_macro_t}, // macro
133 {'t', tm_tag_function_t}, // target
134 {'I', tm_tag_undef_t}, // makefile
136 static TMParserMapGroup group_MAKEFILE[] = {
137 {N_("Targets"), TM_ICON_METHOD, tm_tag_function_t},
138 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
141 static TMParserMapEntry map_PASCAL[] = {
142 {'f', tm_tag_function_t}, // function
143 {'p', tm_tag_function_t}, // procedure
145 static TMParserMapGroup group_PASCAL[] = {
146 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
149 // no scope information
150 static TMParserMapEntry map_PERL[] = {
151 {'c', tm_tag_enum_t}, // constant
152 {'f', tm_tag_other_t}, // format
153 {'l', tm_tag_macro_t}, // label
154 {'p', tm_tag_package_t}, // package
155 {'s', tm_tag_function_t}, // subroutine
156 {'d', tm_tag_prototype_t}, // subroutineDeclaration
157 {'M', tm_tag_undef_t}, // module
159 static TMParserMapGroup group_PERL[] = {
160 {N_("Package"), TM_ICON_NAMESPACE, tm_tag_package_t},
161 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
162 {N_("Labels"), TM_ICON_NONE, tm_tag_macro_t},
163 {N_("Constants"), TM_ICON_NONE, tm_tag_enum_t},
164 {N_("Other"), TM_ICON_OTHER, tm_tag_other_t},
167 static TMParserMapEntry map_PHP[] = {
168 {'c', tm_tag_class_t}, // class
169 {'d', tm_tag_macro_t}, // define
170 {'f', tm_tag_function_t}, // function
171 {'i', tm_tag_interface_t}, // interface
172 {'l', tm_tag_local_var_t}, // local
173 {'n', tm_tag_namespace_t}, // namespace
174 {'t', tm_tag_struct_t}, // trait
175 {'v', tm_tag_variable_t}, // variable
176 {'a', tm_tag_undef_t}, // alias
178 static TMParserMapGroup group_PHP[] = {
179 {N_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
180 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
181 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
182 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
183 {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
184 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
185 {N_("Traits"), TM_ICON_STRUCT, tm_tag_struct_t},
188 static TMParserMapEntry map_PYTHON[] = {
189 {'c', tm_tag_class_t}, // class
190 {'f', tm_tag_function_t}, // function
191 {'m', tm_tag_method_t}, // member
192 {'v', tm_tag_variable_t}, // variable
193 {'I', tm_tag_externvar_t}, // namespace
194 {'i', tm_tag_externvar_t}, // module
195 /* defined as externvar to get those excluded as forward type in symbols.c:goto_tag()
196 * so we can jump to the real implementation (if known) instead of to the import statement */
197 {'x', tm_tag_externvar_t}, // unknown
198 {'z', tm_tag_local_var_t}, // parameter
199 {'l', tm_tag_local_var_t}, // local
201 static TMParserMapGroup group_PYTHON[] = {
202 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
203 {N_("Methods"), TM_ICON_MACRO, tm_tag_method_t},
204 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
205 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
206 {N_("Imports"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
209 static TMParserMapEntry map_LATEX[] = {
210 {'p', tm_tag_enum_t}, // part
211 {'c', tm_tag_namespace_t}, // chapter
212 {'s', tm_tag_member_t}, // section
213 {'u', tm_tag_macro_t}, // subsection
214 {'b', tm_tag_variable_t}, // subsubsection
215 {'P', tm_tag_undef_t}, // paragraph
216 {'G', tm_tag_undef_t}, // subparagraph
217 {'l', tm_tag_struct_t}, // label
218 {'i', tm_tag_undef_t}, // xinput
219 {'B', tm_tag_field_t}, // bibitem
220 {'C', tm_tag_function_t}, // command
221 {'o', tm_tag_function_t}, // operator
222 {'e', tm_tag_class_t}, // environment
223 {'t', tm_tag_class_t}, // theorem
224 {'N', tm_tag_undef_t}, // counter
226 static TMParserMapGroup group_LATEX[] = {
227 {N_("Command"), TM_ICON_NONE, tm_tag_function_t},
228 {N_("Environment"), TM_ICON_NONE, tm_tag_class_t},
229 {N_("Part"), TM_ICON_NONE, tm_tag_enum_t},
230 {N_("Chapter"), TM_ICON_NONE, tm_tag_namespace_t},
231 {N_("Section"), TM_ICON_NONE, tm_tag_member_t},
232 {N_("Subsection"), TM_ICON_NONE, tm_tag_macro_t},
233 {N_("Subsubsection"), TM_ICON_NONE, tm_tag_variable_t},
234 {N_("Bibitem"), TM_ICON_NONE, tm_tag_field_t},
235 {N_("Label"), TM_ICON_NONE, tm_tag_struct_t},
238 // no scope information
239 static TMParserMapEntry map_BIBTEX[] = {
240 {'a', tm_tag_function_t}, // article
241 {'b', tm_tag_class_t}, // book
242 {'B', tm_tag_class_t}, // booklet
243 {'c', tm_tag_member_t}, // conference
244 {'i', tm_tag_macro_t}, // inbook
245 {'I', tm_tag_macro_t}, // incollection
246 {'j', tm_tag_member_t}, // inproceedings
247 {'m', tm_tag_other_t}, // manual
248 {'M', tm_tag_variable_t}, // mastersthesis
249 {'n', tm_tag_other_t}, // misc
250 {'p', tm_tag_variable_t}, // phdthesis
251 {'P', tm_tag_class_t}, // proceedings
252 {'s', tm_tag_namespace_t}, // string
253 {'t', tm_tag_other_t}, // techreport
254 {'u', tm_tag_externvar_t}, // unpublished
256 static TMParserMapGroup group_BIBTEX[] = {
257 {N_("Articles"), TM_ICON_NONE, tm_tag_function_t},
258 {N_("Book Chapters"), TM_ICON_NONE, tm_tag_macro_t},
259 {N_("Books & Conference Proceedings"), TM_ICON_NONE, tm_tag_class_t},
260 {N_("Conference Papers"), TM_ICON_NONE, tm_tag_member_t},
261 {N_("Theses"), TM_ICON_NONE, tm_tag_variable_t},
262 {N_("Strings"), TM_ICON_NONE, tm_tag_namespace_t},
263 {N_("Unpublished"), TM_ICON_NONE, tm_tag_externvar_t},
264 {N_("Other"), TM_ICON_NONE, tm_tag_other_t},
267 static TMParserMapEntry map_ASM[] = {
268 {'d', tm_tag_macro_t}, // define
269 {'l', tm_tag_namespace_t}, // label
270 {'m', tm_tag_function_t}, // macro
271 {'t', tm_tag_struct_t}, // type
272 {'s', tm_tag_undef_t}, // section
274 static TMParserMapGroup group_ASM[] = {
275 {N_("Labels"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
276 {N_("Macros"), TM_ICON_METHOD, tm_tag_function_t},
277 {N_("Defines"), TM_ICON_MACRO, tm_tag_macro_t},
278 {N_("Types"), TM_ICON_STRUCT, tm_tag_struct_t},
281 static TMParserMapEntry map_CONF[] = {
282 {'s', tm_tag_namespace_t}, // section
283 {'k', tm_tag_macro_t}, // key
285 static TMParserMapGroup group_CONF[] = {
286 {N_("Sections"), TM_ICON_OTHER, tm_tag_namespace_t},
287 {N_("Keys"), TM_ICON_VAR, tm_tag_macro_t},
290 static TMParserMapEntry map_SQL[] = {
291 {'c', tm_tag_undef_t}, // cursor
292 {'d', tm_tag_prototype_t}, // prototype
293 {'f', tm_tag_function_t}, // function
294 {'E', tm_tag_field_t}, // field
295 {'l', tm_tag_undef_t}, // local
296 {'L', tm_tag_undef_t}, // label
297 {'P', tm_tag_package_t}, // package
298 {'p', tm_tag_namespace_t}, // procedure
299 {'r', tm_tag_undef_t}, // record
300 {'s', tm_tag_undef_t}, // subtype
301 {'t', tm_tag_class_t}, // table
302 {'T', tm_tag_macro_t}, // trigger
303 {'v', tm_tag_variable_t}, // variable
304 {'i', tm_tag_struct_t}, // index
305 {'e', tm_tag_undef_t}, // event
306 {'U', tm_tag_undef_t}, // publication
307 {'R', tm_tag_undef_t}, // service
308 {'D', tm_tag_undef_t}, // domain
309 {'V', tm_tag_member_t}, // view
310 {'n', tm_tag_undef_t}, // synonym
311 {'x', tm_tag_undef_t}, // mltable
312 {'y', tm_tag_undef_t}, // mlconn
313 {'z', tm_tag_undef_t}, // mlprop
314 {'C', tm_tag_undef_t}, // ccflag
316 static TMParserMapGroup group_SQL[] = {
317 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
318 {N_("Procedures"), TM_ICON_NAMESPACE, tm_tag_namespace_t | tm_tag_package_t},
319 {N_("Indexes"), TM_ICON_STRUCT, tm_tag_struct_t},
320 {N_("Tables"), TM_ICON_CLASS, tm_tag_class_t},
321 {N_("Triggers"), TM_ICON_MACRO, tm_tag_macro_t},
322 {N_("Views"), TM_ICON_VAR, tm_tag_field_t | tm_tag_member_t},
323 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
326 static TMParserMapEntry map_DOCBOOK[] = {
327 {'f', tm_tag_function_t},
328 {'c', tm_tag_class_t},
329 {'m', tm_tag_member_t},
330 {'d', tm_tag_macro_t},
331 {'v', tm_tag_variable_t},
332 {'s', tm_tag_struct_t},
334 static TMParserMapGroup group_DOCBOOK[] = {
335 {N_("Chapter"), TM_ICON_NONE, tm_tag_function_t},
336 {N_("Section"), TM_ICON_NONE, tm_tag_class_t},
337 {N_("Sect1"), TM_ICON_NONE, tm_tag_member_t},
338 {N_("Sect2"), TM_ICON_NONE, tm_tag_macro_t},
339 {N_("Sect3"), TM_ICON_NONE, tm_tag_variable_t},
340 {N_("Appendix"), TM_ICON_NONE, tm_tag_struct_t},
343 // no scope information
344 static TMParserMapEntry map_ERLANG[] = {
345 {'d', tm_tag_macro_t}, // macro
346 {'f', tm_tag_function_t}, // function
347 {'m', tm_tag_undef_t}, // module
348 {'r', tm_tag_struct_t}, // record
349 {'t', tm_tag_typedef_t}, // type
351 static TMParserMapGroup group_ERLANG[] = {
352 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
353 {N_("Structs"), TM_ICON_STRUCT, tm_tag_struct_t},
354 {N_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t},
355 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
358 // no scope information
359 static TMParserMapEntry map_CSS[] = {
360 {'c', tm_tag_class_t}, // class
361 {'s', tm_tag_struct_t}, // selector
362 {'i', tm_tag_variable_t}, // id
364 static TMParserMapGroup group_CSS[] = {
365 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
366 {N_("ID Selectors"), TM_ICON_VAR, tm_tag_variable_t},
367 {N_("Type Selectors"), TM_ICON_STRUCT, tm_tag_struct_t},
370 static TMParserMapEntry map_RUBY[] = {
371 {'c', tm_tag_class_t}, // class
372 {'f', tm_tag_method_t}, // method
373 {'m', tm_tag_namespace_t}, // module
374 {'S', tm_tag_member_t}, // singletonMethod
375 {'C', tm_tag_undef_t}, // constant
376 {'A', tm_tag_undef_t}, // accessor
377 {'a', tm_tag_undef_t}, // alias
378 {'L', tm_tag_undef_t}, // library
380 static TMParserMapGroup group_RUBY[] = {
381 {N_("Modules"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
382 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
383 {N_("Singletons"), TM_ICON_STRUCT, tm_tag_member_t},
384 {N_("Methods"), TM_ICON_METHOD, tm_tag_method_t},
387 static TMParserMapEntry map_TCL[] = {
388 {'p', tm_tag_function_t}, // procedure
389 {'n', tm_tag_namespace_t}, // namespace
390 {'z', tm_tag_undef_t}, // parameter
392 static TMParserMapGroup group_TCL[] = {
393 {N_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
394 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
395 {N_("Methods"), TM_ICON_METHOD, tm_tag_member_t},
396 {N_("Procedures"), TM_ICON_OTHER, tm_tag_function_t},
399 static TMParserMapEntry map_TCLOO[] = {
400 {'c', tm_tag_class_t}, // class
401 {'m', tm_tag_member_t}, // method
403 #define group_TCLOO group_TCL
405 static TMSubparserMapEntry subparser_TCLOO_TCL_map[] = {
406 {tm_tag_namespace_t, tm_tag_namespace_t},
407 {tm_tag_class_t, tm_tag_class_t},
408 {tm_tag_member_t, tm_tag_member_t},
409 {tm_tag_function_t, tm_tag_function_t},
412 static TMParserMapEntry map_SH[] = {
413 {'a', tm_tag_undef_t}, // alias
414 {'f', tm_tag_function_t}, // function
415 {'s', tm_tag_undef_t}, // script
416 {'h', tm_tag_undef_t}, // heredoc
418 static TMParserMapGroup group_SH[] = {
419 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
422 static TMParserMapEntry map_D[] = {
423 {'c', tm_tag_class_t}, // class
424 {'e', tm_tag_enumerator_t}, // enumerator
425 {'f', tm_tag_function_t}, // function
426 {'g', tm_tag_enum_t}, // enum
427 {'i', tm_tag_interface_t}, // interface
428 {'m', tm_tag_member_t}, // member
429 {'n', tm_tag_namespace_t}, // namespace
430 {'p', tm_tag_prototype_t}, // prototype
431 {'s', tm_tag_struct_t}, // struct
432 {'t', tm_tag_typedef_t}, // typedef
433 {'u', tm_tag_union_t}, // union
434 {'v', tm_tag_variable_t}, // variable
435 {'x', tm_tag_externvar_t}, // externvar
437 static TMParserMapGroup group_D[] = {
438 {N_("Module"), TM_ICON_NONE, tm_tag_namespace_t},
439 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
440 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
441 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
442 {N_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
443 {N_("Structs"), TM_ICON_STRUCT, tm_tag_struct_t | tm_tag_union_t},
444 {N_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t | tm_tag_enum_t},
445 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t},
446 {N_("Extern Variables"), TM_ICON_VAR, tm_tag_externvar_t},
449 static TMParserMapEntry map_DIFF[] = {
450 {'m', tm_tag_function_t}, // modifiedFile
451 {'n', tm_tag_function_t}, // newFile
452 {'d', tm_tag_function_t}, // deletedFile
453 {'h', tm_tag_undef_t}, // hunk
455 static TMParserMapGroup group_DIFF[] = {
456 {N_("Files"), TM_ICON_NONE, tm_tag_function_t},
459 static TMParserMapEntry map_VHDL[] = {
460 {'c', tm_tag_variable_t}, // constant
461 {'t', tm_tag_typedef_t}, // type
462 {'T', tm_tag_typedef_t}, // subtype
463 {'r', tm_tag_undef_t}, // record
464 {'e', tm_tag_class_t}, // entity
465 {'C', tm_tag_member_t}, // component
466 {'d', tm_tag_undef_t}, // prototype
467 {'f', tm_tag_function_t}, // function
468 {'p', tm_tag_function_t}, // procedure
469 {'P', tm_tag_namespace_t}, // package
470 {'l', tm_tag_variable_t}, // local
471 {'a', tm_tag_struct_t}, // architecture
472 {'q', tm_tag_variable_t}, // port
473 {'g', tm_tag_undef_t}, // generic
474 {'s', tm_tag_variable_t}, // signal
475 {'Q', tm_tag_member_t}, // process
476 {'v', tm_tag_variable_t}, // variable
477 {'A', tm_tag_typedef_t}, // alias
479 static TMParserMapGroup group_VHDL[] = {
480 {N_("Package"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
481 {N_("Entities"), TM_ICON_CLASS, tm_tag_class_t},
482 {N_("Architectures"), TM_ICON_STRUCT, tm_tag_struct_t},
483 {N_("Types"), TM_ICON_OTHER, tm_tag_typedef_t},
484 {N_("Functions / Procedures"), TM_ICON_METHOD, tm_tag_function_t},
485 {N_("Variables / Signals / Ports"), TM_ICON_VAR, tm_tag_variable_t},
486 {N_("Processes / Blocks / Components"), TM_ICON_MEMBER, tm_tag_member_t},
489 static TMParserMapEntry map_LUA[] = {
490 {'f', tm_tag_function_t}, // function
491 {'X', tm_tag_undef_t}, // unknown
493 static TMParserMapGroup group_LUA[] = {
494 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
497 static TMParserMapEntry map_JAVASCRIPT[] = {
498 {'f', tm_tag_function_t}, // function
499 {'c', tm_tag_class_t}, // class
500 {'m', tm_tag_method_t}, // method
501 {'p', tm_tag_member_t}, // property
502 {'C', tm_tag_macro_t}, // constant
503 {'v', tm_tag_variable_t}, // variable
504 {'g', tm_tag_function_t}, // generator
505 {'G', tm_tag_undef_t}, // getter
506 {'S', tm_tag_undef_t}, // setter
507 {'M', tm_tag_undef_t}, // field
509 static TMParserMapGroup group_JAVASCRIPT[] = {
510 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
511 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
512 {N_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
513 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
514 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
517 // no scope information
518 static TMParserMapEntry map_HASKELL[] = {
519 {'t', tm_tag_typedef_t}, // type
520 {'c', tm_tag_macro_t}, // constructor
521 {'f', tm_tag_function_t}, // function
522 {'m', tm_tag_namespace_t}, // module
524 static TMParserMapGroup group_HASKELL[] = {
525 {N_("Module"), TM_ICON_NONE, tm_tag_namespace_t},
526 {N_("Types"), TM_ICON_NONE, tm_tag_typedef_t},
527 {N_("Type constructors"), TM_ICON_NONE, tm_tag_macro_t},
528 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
531 #define map_UNUSED1 map_HASKELL
532 #define group_UNUSED1 group_HASKELL
534 static TMParserMapEntry map_CSHARP[] = {
535 {'c', tm_tag_class_t}, // class
536 {'d', tm_tag_macro_t}, // macro
537 {'e', tm_tag_enumerator_t}, // enumerator
538 {'E', tm_tag_undef_t}, // event
539 {'f', tm_tag_field_t}, // field
540 {'g', tm_tag_enum_t}, // enum
541 {'i', tm_tag_interface_t}, // interface
542 {'l', tm_tag_undef_t}, // local
543 {'m', tm_tag_method_t}, // method
544 {'n', tm_tag_namespace_t}, // namespace
545 {'p', tm_tag_undef_t}, // property
546 {'s', tm_tag_struct_t}, // struct
547 {'t', tm_tag_typedef_t}, // typedef
549 #define group_CSHARP group_C
551 // no scope information
552 static TMParserMapEntry map_FREEBASIC[] = {
553 {'c', tm_tag_macro_t}, // constant
554 {'f', tm_tag_function_t}, // function
555 {'l', tm_tag_namespace_t}, // label
556 {'t', tm_tag_struct_t}, // type
557 {'v', tm_tag_variable_t}, // variable
558 {'g', tm_tag_externvar_t}, // enum
560 static TMParserMapGroup group_FREEBASIC[] = {
561 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
562 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_externvar_t},
563 {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
564 {N_("Types"), TM_ICON_NAMESPACE, tm_tag_struct_t},
565 {N_("Labels"), TM_ICON_MEMBER, tm_tag_namespace_t},
568 // no scope information
569 static TMParserMapEntry map_HAXE[] = {
570 {'m', tm_tag_method_t}, // method
571 {'c', tm_tag_class_t}, // class
572 {'e', tm_tag_enum_t}, // enum
573 {'v', tm_tag_variable_t}, // variable
574 {'i', tm_tag_interface_t}, // interface
575 {'t', tm_tag_typedef_t}, // typedef
577 static TMParserMapGroup group_HAXE[] = {
578 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
579 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
580 {N_("Methods"), TM_ICON_METHOD, tm_tag_method_t},
581 {N_("Types"), TM_ICON_MACRO, tm_tag_typedef_t | tm_tag_enum_t},
582 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
585 static TMParserMapEntry map_REST[] = {
586 {'c', tm_tag_namespace_t}, // chapter
587 {'s', tm_tag_member_t}, // section
588 {'S', tm_tag_macro_t}, // subsection
589 {'t', tm_tag_variable_t}, // subsubsection
590 {'C', tm_tag_undef_t}, // citation
591 {'T', tm_tag_undef_t}, // target
592 {'d', tm_tag_undef_t}, // substdef
594 static TMParserMapGroup group_REST[] = {
595 {N_("Chapter"), TM_ICON_NONE, tm_tag_namespace_t},
596 {N_("Section"), TM_ICON_NONE, tm_tag_member_t},
597 {N_("Subsection"), TM_ICON_NONE, tm_tag_macro_t},
598 {N_("Subsubsection"), TM_ICON_NONE, tm_tag_variable_t},
601 // no scope information
602 static TMParserMapEntry map_HTML[] = {
603 {'a', tm_tag_member_t}, // anchor
604 {'c', tm_tag_undef_t}, // class
605 {'h', tm_tag_namespace_t}, // heading1
606 {'i', tm_tag_class_t}, // heading2
607 {'j', tm_tag_variable_t}, // heading3
608 {'C', tm_tag_undef_t}, // stylesheet
609 {'I', tm_tag_undef_t}, // id
610 {'J', tm_tag_undef_t}, // script
612 static TMParserMapGroup group_HTML[] = {
613 {N_("Functions"), TM_ICON_NONE, tm_tag_function_t}, // javascript functions from subparser
614 {N_("Anchors"), TM_ICON_NONE, tm_tag_member_t},
615 {N_("H1 Headings"), TM_ICON_NONE, tm_tag_namespace_t},
616 {N_("H2 Headings"), TM_ICON_NONE, tm_tag_class_t},
617 {N_("H3 Headings"), TM_ICON_NONE, tm_tag_variable_t},
620 static TMSubparserMapEntry subparser_HTML_javascript_map[] = {
621 {tm_tag_function_t, tm_tag_function_t},
624 static TMParserMapEntry map_FORTRAN[] = {
625 {'b', tm_tag_undef_t}, // blockData
626 {'c', tm_tag_macro_t}, // common
627 {'e', tm_tag_undef_t}, // entry
628 {'E', tm_tag_enum_t}, // enum
629 {'f', tm_tag_function_t}, // function
630 {'i', tm_tag_interface_t}, // interface
631 {'k', tm_tag_member_t}, // component
632 {'l', tm_tag_undef_t}, // label
633 {'L', tm_tag_undef_t}, // local
634 {'m', tm_tag_namespace_t}, // module
635 {'M', tm_tag_member_t}, // method
636 {'n', tm_tag_undef_t}, // namelist
637 {'N', tm_tag_enumerator_t}, // enumerator
638 {'p', tm_tag_struct_t}, // program
639 {'P', tm_tag_undef_t}, // prototype
640 {'s', tm_tag_method_t}, // subroutine
641 {'t', tm_tag_class_t}, // type
642 {'v', tm_tag_variable_t}, // variable
643 {'S', tm_tag_undef_t}, // submodule
645 static TMParserMapGroup group_FORTRAN[] = {
646 {N_("Module"), TM_ICON_CLASS, tm_tag_namespace_t},
647 {N_("Programs"), TM_ICON_CLASS, tm_tag_struct_t},
648 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
649 {N_("Functions / Subroutines"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
650 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t},
651 {N_("Types"), TM_ICON_CLASS, tm_tag_class_t},
652 {N_("Components"), TM_ICON_MEMBER, tm_tag_member_t},
653 {N_("Blocks"), TM_ICON_MEMBER, tm_tag_macro_t},
654 {N_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
657 static TMParserMapEntry map_MATLAB[] = {
658 {'f', tm_tag_function_t}, // function
659 {'s', tm_tag_struct_t}, // struct
661 static TMParserMapGroup group_MATLAB[] = {
662 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
663 {N_("Structures"), TM_ICON_STRUCT, tm_tag_struct_t},
666 #define map_CUDA map_C
667 #define group_CUDA group_C
669 static TMParserMapEntry map_VALA[] = {
670 {'c', tm_tag_class_t}, // class
671 {'d', tm_tag_macro_t}, // macro
672 {'e', tm_tag_enumerator_t}, // enumerator
673 {'f', tm_tag_field_t}, // field
674 {'g', tm_tag_enum_t}, // enum
675 {'i', tm_tag_interface_t}, // interface
676 {'l', tm_tag_undef_t}, // local
677 {'m', tm_tag_method_t}, // method
678 {'n', tm_tag_namespace_t}, // namespace
679 {'p', tm_tag_undef_t}, // property
680 {'S', tm_tag_undef_t}, // signal
681 {'s', tm_tag_struct_t}, // struct
683 #define group_VALA group_C
685 static TMParserMapEntry map_ACTIONSCRIPT[] = {
686 {'f', tm_tag_function_t}, // function
687 {'c', tm_tag_class_t}, // class
688 {'i', tm_tag_interface_t}, // interface
689 {'P', tm_tag_package_t}, // package
690 {'m', tm_tag_method_t}, // method
691 {'p', tm_tag_member_t}, // property
692 {'v', tm_tag_variable_t}, // variable
693 {'l', tm_tag_variable_t}, // localvar
694 {'C', tm_tag_macro_t}, // constant
695 {'I', tm_tag_externvar_t}, // import
696 {'x', tm_tag_other_t}, // mxtag
698 static TMParserMapGroup group_ACTIONSCRIPT[] = {
699 {N_("Imports"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
700 {N_("Package"), TM_ICON_NAMESPACE, tm_tag_package_t},
701 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
702 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
703 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t| tm_tag_method_t},
704 {N_("Properties"), TM_ICON_MEMBER, tm_tag_member_t},
705 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
706 {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
707 {N_("Other"), TM_ICON_OTHER, tm_tag_other_t},
710 static TMParserMapEntry map_NSIS[] = {
711 {'s', tm_tag_namespace_t}, // section
712 {'f', tm_tag_function_t}, // function
713 {'v', tm_tag_variable_t}, // variable
714 {'d', tm_tag_undef_t}, // definition
715 {'m', tm_tag_undef_t}, // macro
716 {'S', tm_tag_undef_t}, // sectionGroup
717 {'p', tm_tag_undef_t}, // macroparam
718 {'l', tm_tag_undef_t}, // langstr
719 {'i', tm_tag_undef_t}, // script
721 static TMParserMapGroup group_NSIS[] = {
722 {N_("Sections"), TM_ICON_OTHER, tm_tag_namespace_t},
723 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
724 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
727 static TMParserMapEntry map_MARKDOWN[] = {
728 {'c', tm_tag_namespace_t}, //chapter
729 {'s', tm_tag_member_t}, //section
730 {'S', tm_tag_macro_t}, //subsection
731 {'t', tm_tag_variable_t}, //subsubsection
732 {'T', tm_tag_struct_t}, //l4subsection
733 {'u', tm_tag_union_t}, //l5subsection
734 {'n', tm_tag_undef_t}, //footnote
736 static TMParserMapGroup group_MARKDOWN[] = {
737 {N_("Chapters"), TM_ICON_NONE, tm_tag_namespace_t},
738 {N_("Sections"), TM_ICON_NONE, tm_tag_member_t},
739 {N_("Subsections"), TM_ICON_NONE, tm_tag_macro_t},
740 {N_("Subsubsections"), TM_ICON_NONE, tm_tag_variable_t},
741 {N_("Level 4 sections"), TM_ICON_NONE, tm_tag_struct_t},
742 {N_("Level 5 sections"), TM_ICON_NONE, tm_tag_union_t},
745 static TMParserMapEntry map_TXT2TAGS[] = {
746 {'s', tm_tag_member_t}, // section
748 #define group_TXT2TAGS group_REST
750 // no scope information
751 static TMParserMapEntry map_ABC[] = {
752 {'s', tm_tag_member_t}, // section
754 #define group_ABC group_REST
756 static TMParserMapEntry map_VERILOG[] = {
757 {'c', tm_tag_variable_t}, // constant
758 {'e', tm_tag_typedef_t}, // event
759 {'f', tm_tag_function_t}, // function
760 {'m', tm_tag_class_t}, // module
761 {'n', tm_tag_variable_t}, // net
762 {'p', tm_tag_variable_t}, // port
763 {'r', tm_tag_variable_t}, // register
764 {'t', tm_tag_function_t}, // task
765 {'b', tm_tag_undef_t}, // block
766 {'i', tm_tag_undef_t}, // instance
768 static TMParserMapGroup group_VERILOG[] = {
769 {N_("Events"), TM_ICON_MACRO, tm_tag_typedef_t},
770 {N_("Modules"), TM_ICON_CLASS, tm_tag_class_t},
771 {N_("Functions / Tasks"), TM_ICON_METHOD, tm_tag_function_t},
772 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
775 static TMParserMapEntry map_R[] = {
776 {'f', tm_tag_function_t}, // function
777 {'l', tm_tag_other_t}, // library
778 {'s', tm_tag_other_t}, // source
779 {'g', tm_tag_undef_t}, // globalVar
780 {'v', tm_tag_undef_t}, // functionVar
781 {'z', tm_tag_undef_t}, // parameter
782 {'c', tm_tag_undef_t}, // vector
783 {'L', tm_tag_undef_t}, // list
784 {'d', tm_tag_undef_t}, // dataframe
785 {'n', tm_tag_undef_t}, // nameattr
787 static TMParserMapGroup group_R[] = {
788 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
789 {N_("Other"), TM_ICON_NONE, tm_tag_other_t},
792 static TMParserMapEntry map_COBOL[] = {
793 {'f', tm_tag_function_t}, // fd
794 {'g', tm_tag_struct_t}, // group
795 {'P', tm_tag_class_t}, // program
796 {'s', tm_tag_namespace_t}, // section
797 {'D', tm_tag_interface_t}, // division
798 {'p', tm_tag_macro_t}, // paragraph
799 {'d', tm_tag_variable_t}, // data
800 {'S', tm_tag_externvar_t}, // sourcefile
802 static TMParserMapGroup group_COBOL[] = {
803 {N_("Program"), TM_ICON_CLASS, tm_tag_class_t},
804 {N_("File"), TM_ICON_METHOD, tm_tag_function_t},
805 {N_("Divisions"), TM_ICON_NAMESPACE, tm_tag_interface_t},
806 {N_("Sections"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
807 {N_("Paragraph"), TM_ICON_OTHER, tm_tag_macro_t},
808 {N_("Group"), TM_ICON_STRUCT, tm_tag_struct_t},
809 {N_("Data"), TM_ICON_VAR, tm_tag_variable_t},
810 {N_("Copies"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
813 static TMParserMapEntry map_OBJC[] = {
814 {'i', tm_tag_interface_t}, // interface
815 {'I', tm_tag_undef_t}, // implementation
816 {'P', tm_tag_undef_t}, // protocol
817 {'m', tm_tag_method_t}, // method
818 {'c', tm_tag_class_t}, // class
819 {'v', tm_tag_variable_t}, // var
820 {'E', tm_tag_field_t}, // field
821 {'f', tm_tag_function_t}, // function
822 {'p', tm_tag_undef_t}, // property
823 {'t', tm_tag_typedef_t}, // typedef
824 {'s', tm_tag_struct_t}, // struct
825 {'e', tm_tag_enum_t}, // enum
826 {'M', tm_tag_macro_t}, // macro
827 {'C', tm_tag_undef_t}, // category
829 #define group_OBJC group_C
831 static TMParserMapEntry map_ASCIIDOC[] = {
832 {'c', tm_tag_namespace_t}, //chapter
833 {'s', tm_tag_member_t}, //section
834 {'S', tm_tag_macro_t}, //subsection
835 {'t', tm_tag_variable_t}, //subsubsection
836 {'T', tm_tag_struct_t}, //l4subsection
837 {'u', tm_tag_enumerator_t}, //l5subsection
838 {'a', tm_tag_undef_t}, //anchor
840 static TMParserMapGroup group_ASCIIDOC[] = {
841 {N_("Document"), TM_ICON_NONE, tm_tag_namespace_t},
842 {N_("Section Level 1"), TM_ICON_NONE, tm_tag_member_t},
843 {N_("Section Level 2"), TM_ICON_NONE, tm_tag_macro_t},
844 {N_("Section Level 3"), TM_ICON_NONE, tm_tag_variable_t},
845 {N_("Section Level 4"), TM_ICON_NONE, tm_tag_struct_t},
846 {N_("Section Level 5"), TM_ICON_NONE, tm_tag_enumerator_t},
849 // no scope information
850 static TMParserMapEntry map_ABAQUS[] = {
851 {'p', tm_tag_class_t}, // part
852 {'a', tm_tag_member_t}, // assembly
853 {'s', tm_tag_interface_t}, // step
855 static TMParserMapGroup group_ABAQUS[] = {
856 {N_("Parts"), TM_ICON_NONE, tm_tag_class_t},
857 {N_("Assembly"), TM_ICON_NONE, tm_tag_member_t},
858 {N_("Steps"), TM_ICON_NONE, tm_tag_interface_t},
861 static TMParserMapEntry map_RUST[] = {
862 {'n', tm_tag_namespace_t}, // module
863 {'s', tm_tag_struct_t}, // struct
864 {'i', tm_tag_interface_t}, // interface
865 {'c', tm_tag_class_t}, // implementation
866 {'f', tm_tag_function_t}, // function
867 {'g', tm_tag_enum_t}, // enum
868 {'t', tm_tag_typedef_t}, // typedef
869 {'v', tm_tag_variable_t}, // variable
870 {'M', tm_tag_macro_t}, // macro
871 {'m', tm_tag_field_t}, // field
872 {'e', tm_tag_enumerator_t}, // enumerator
873 {'P', tm_tag_method_t}, // method
875 static TMParserMapGroup group_RUST[] = {
876 {N_("Modules"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
877 {N_("Structures"), TM_ICON_STRUCT, tm_tag_struct_t},
878 {N_("Traits"), TM_ICON_CLASS, tm_tag_interface_t},
879 {N_("Implementations"), TM_ICON_CLASS, tm_tag_class_t},
880 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
881 {N_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t | tm_tag_enum_t},
882 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t},
883 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
884 {N_("Methods"), TM_ICON_MEMBER, tm_tag_field_t},
887 static TMParserMapEntry map_GO[] = {
888 {'p', tm_tag_namespace_t}, // package
889 {'f', tm_tag_function_t}, // func
890 {'c', tm_tag_macro_t}, // const
891 {'t', tm_tag_typedef_t}, // type
892 {'v', tm_tag_variable_t}, // var
893 {'s', tm_tag_struct_t}, // struct
894 {'i', tm_tag_interface_t}, // interface
895 {'m', tm_tag_member_t}, // member
896 {'M', tm_tag_undef_t}, // anonMember
897 {'n', tm_tag_undef_t}, // methodSpec
898 {'u', tm_tag_undef_t}, // unknown
899 {'P', tm_tag_undef_t}, // packageName
900 {'a', tm_tag_undef_t}, // talias
901 {'R', tm_tag_undef_t}, // receiver
903 static TMParserMapGroup group_GO[] = {
904 {N_("Package"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
905 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
906 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
907 {N_("Structs"), TM_ICON_STRUCT, tm_tag_struct_t},
908 {N_("Types"), TM_ICON_STRUCT, tm_tag_typedef_t},
909 {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
910 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
911 {N_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
914 static TMParserMapEntry map_JSON[] = {
915 {'o', tm_tag_member_t}, // object
916 {'a', tm_tag_member_t}, // array
917 {'n', tm_tag_member_t}, // number
918 {'s', tm_tag_member_t}, // string
919 {'b', tm_tag_member_t}, // boolean
920 {'z', tm_tag_member_t}, // null
922 static TMParserMapGroup group_JSON[] = {
923 {N_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
926 /* Zephir, same as PHP */
927 #define map_ZEPHIR map_PHP
928 #define group_ZEPHIR group_PHP
930 static TMParserMapEntry map_POWERSHELL[] = {
931 {'f', tm_tag_function_t}, // function
932 {'v', tm_tag_variable_t}, // variable
934 static TMParserMapGroup group_POWERSHELL[] = {
935 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
936 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
939 static TMParserMapEntry map_JULIA[] = {
940 {'c', tm_tag_variable_t}, // constant
941 {'f', tm_tag_function_t}, // function
942 {'g', tm_tag_member_t}, // field
943 {'m', tm_tag_macro_t}, // macro
944 {'n', tm_tag_namespace_t}, // module
945 {'s', tm_tag_struct_t}, // struct
946 {'t', tm_tag_typedef_t}, // type
947 /* defined as externvar to get those excluded as forward type in symbols.c:goto_tag()
948 * so we can jump to the real implementation (if known) instead of to the import statement */
949 {'x', tm_tag_externvar_t}, // unknown
951 static TMParserMapGroup group_JULIA[] = {
952 {N_("Constants"), TM_ICON_VAR, tm_tag_variable_t},
953 {N_("Modules"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
954 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
955 {N_("Fields"), TM_ICON_MEMBER, tm_tag_member_t},
956 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
957 {N_("Structures"), TM_ICON_STRUCT, tm_tag_struct_t},
958 {N_("Types"), TM_ICON_CLASS, tm_tag_typedef_t},
959 {N_("Unknowns"), TM_ICON_OTHER, tm_tag_externvar_t},
962 static TMParserMapEntry map_CPREPROCESSOR[] = {
963 {'d', tm_tag_undef_t}, // macro
964 {'h', tm_tag_undef_t}, // header
965 {'D', tm_tag_undef_t}, // parameter
967 #define group_CPREPROCESSOR group_C
969 static TMParserMapEntry map_GDSCRIPT[] = {
970 {'c', tm_tag_class_t}, // class
971 {'m', tm_tag_method_t}, // method
972 {'v', tm_tag_variable_t}, // variable
973 {'C', tm_tag_variable_t}, // const
974 {'g', tm_tag_enum_t}, // enum
975 {'e', tm_tag_variable_t}, // enumerator
976 {'z', tm_tag_local_var_t}, // parameter
977 {'l', tm_tag_local_var_t}, // local
978 {'s', tm_tag_variable_t}, // signal
980 static TMParserMapGroup group_GDSCRIPT[] = {
981 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
982 {N_("Methods"), TM_ICON_MACRO, tm_tag_method_t},
983 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
984 {N_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
987 static TMParserMapEntry map_CLOJURE[] = {
988 {'f', tm_tag_function_t}, // function
989 {'n', tm_tag_namespace_t}, // namespace
991 static TMParserMapGroup group_CLOJURE[] = {
992 {N_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
993 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
996 static TMParserMapEntry map_LISP[] = {
997 {'u', tm_tag_undef_t}, // unknown
998 {'f', tm_tag_function_t}, // function
999 {'v', tm_tag_variable_t}, // variable
1000 {'m', tm_tag_macro_t}, // macro
1001 {'c', tm_tag_field_t}, // const
1003 static TMParserMapGroup group_LISP[] = {
1004 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
1005 {N_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
1006 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
1007 {N_("Constants"), TM_ICON_VAR, tm_tag_field_t},
1010 static TMParserMapEntry map_TYPESCRIPT[] = {
1011 {'f', tm_tag_function_t}, // function
1012 {'c', tm_tag_class_t}, // class
1013 {'i', tm_tag_interface_t}, // interface
1014 {'g', tm_tag_enum_t}, // enum
1015 {'e', tm_tag_enumerator_t}, // enumerator
1016 {'m', tm_tag_method_t}, // method
1017 {'n', tm_tag_namespace_t}, // namespace
1018 {'z', tm_tag_local_var_t}, // parameter
1019 {'p', tm_tag_member_t}, // property
1020 {'v', tm_tag_variable_t}, // variable
1021 {'l', tm_tag_local_var_t}, // local
1022 {'C', tm_tag_macro_t}, // constant
1023 {'G', tm_tag_undef_t}, // generator
1024 {'a', tm_tag_undef_t}, // alias
1026 static TMParserMapGroup group_TYPESCRIPT[] = {
1027 {N_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
1028 {N_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
1029 {N_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
1030 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
1031 {N_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
1032 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
1033 {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
1034 {N_("Other"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_enumerator_t},
1037 static TMParserMapEntry map_ADA[] = {
1038 {'P', tm_tag_package_t}, // packspec
1039 {'p', tm_tag_package_t}, // package
1040 {'T', tm_tag_typedef_t}, // typespec
1041 {'t', tm_tag_typedef_t}, // type
1042 {'U', tm_tag_undef_t}, // subspec
1043 {'u', tm_tag_typedef_t}, // subtype
1044 {'c', tm_tag_member_t}, // component
1045 {'l', tm_tag_enumerator_t}, // literal
1046 {'V', tm_tag_undef_t}, // varspec
1047 {'v', tm_tag_variable_t}, // variable
1048 {'f', tm_tag_undef_t}, // formal
1049 {'n', tm_tag_macro_t}, // constant
1050 {'x', tm_tag_undef_t}, // exception
1051 {'R', tm_tag_prototype_t}, // subprogspec
1052 {'r', tm_tag_function_t}, // subprogram
1053 {'K', tm_tag_prototype_t}, // taskspec
1054 {'k', tm_tag_method_t}, // task
1055 {'O', tm_tag_undef_t}, // protectspec
1056 {'o', tm_tag_undef_t}, // protected
1057 {'E', tm_tag_undef_t}, // entryspec
1058 {'e', tm_tag_undef_t}, // entry
1059 {'b', tm_tag_undef_t}, // label
1060 {'i', tm_tag_undef_t}, // identifier
1061 {'a', tm_tag_undef_t}, // autovar
1062 {'y', tm_tag_undef_t}, // anon
1064 static TMParserMapGroup group_ADA[] = {
1065 {N_("Packages"), TM_ICON_NAMESPACE, tm_tag_package_t},
1066 {N_("Types"), TM_ICON_STRUCT, tm_tag_typedef_t},
1067 {N_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
1068 {N_("Tasks"), TM_ICON_METHOD, tm_tag_method_t},
1069 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
1070 {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
1071 {N_("Other"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_enumerator_t},
1074 static TMParserMapEntry map_BATCH[] = {
1075 {'l', tm_tag_other_t}, // label
1076 {'v', tm_tag_variable_t}, // variable
1078 static TMParserMapGroup group_BATCH[] = {
1079 {N_("Labels"), TM_ICON_OTHER, tm_tag_other_t},
1080 {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
1083 typedef struct
1085 TMParserMapEntry *entries;
1086 guint size;
1087 TMParserMapGroup *groups;
1088 guint group_num;
1089 } TMParserMap;
1091 #define MAP_ENTRY(lang) [TM_PARSER_##lang] = {map_##lang, G_N_ELEMENTS(map_##lang), group_##lang, G_N_ELEMENTS(group_##lang)}
1093 /* keep in sync with TM_PARSER_* definitions in the header */
1094 static TMParserMap parser_map[] = {
1095 MAP_ENTRY(C),
1096 MAP_ENTRY(CPP),
1097 MAP_ENTRY(JAVA),
1098 MAP_ENTRY(MAKEFILE),
1099 MAP_ENTRY(PASCAL),
1100 MAP_ENTRY(PERL),
1101 MAP_ENTRY(PHP),
1102 MAP_ENTRY(PYTHON),
1103 MAP_ENTRY(LATEX),
1104 MAP_ENTRY(BIBTEX),
1105 MAP_ENTRY(ASM),
1106 MAP_ENTRY(CONF),
1107 MAP_ENTRY(SQL),
1108 MAP_ENTRY(DOCBOOK),
1109 MAP_ENTRY(ERLANG),
1110 MAP_ENTRY(CSS),
1111 MAP_ENTRY(RUBY),
1112 MAP_ENTRY(TCL),
1113 MAP_ENTRY(SH),
1114 MAP_ENTRY(D),
1115 MAP_ENTRY(FORTRAN),
1116 MAP_ENTRY(GDSCRIPT),
1117 MAP_ENTRY(DIFF),
1118 MAP_ENTRY(VHDL),
1119 MAP_ENTRY(LUA),
1120 MAP_ENTRY(JAVASCRIPT),
1121 MAP_ENTRY(HASKELL),
1122 MAP_ENTRY(CSHARP),
1123 MAP_ENTRY(FREEBASIC),
1124 MAP_ENTRY(HAXE),
1125 MAP_ENTRY(REST),
1126 MAP_ENTRY(HTML),
1127 MAP_ENTRY(ADA),
1128 MAP_ENTRY(CUDA),
1129 MAP_ENTRY(MATLAB),
1130 MAP_ENTRY(VALA),
1131 MAP_ENTRY(ACTIONSCRIPT),
1132 MAP_ENTRY(NSIS),
1133 MAP_ENTRY(MARKDOWN),
1134 MAP_ENTRY(TXT2TAGS),
1135 MAP_ENTRY(ABC),
1136 MAP_ENTRY(VERILOG),
1137 MAP_ENTRY(R),
1138 MAP_ENTRY(COBOL),
1139 MAP_ENTRY(OBJC),
1140 MAP_ENTRY(ASCIIDOC),
1141 MAP_ENTRY(ABAQUS),
1142 MAP_ENTRY(RUST),
1143 MAP_ENTRY(GO),
1144 MAP_ENTRY(JSON),
1145 MAP_ENTRY(ZEPHIR),
1146 MAP_ENTRY(POWERSHELL),
1147 MAP_ENTRY(JULIA),
1148 MAP_ENTRY(CPREPROCESSOR),
1149 MAP_ENTRY(TCLOO),
1150 MAP_ENTRY(CLOJURE),
1151 MAP_ENTRY(LISP),
1152 MAP_ENTRY(TYPESCRIPT),
1153 MAP_ENTRY(BATCH),
1155 /* make sure the parser map is consistent and complete */
1156 G_STATIC_ASSERT(G_N_ELEMENTS(parser_map) == TM_PARSER_COUNT);
1159 TMTagType tm_parser_get_tag_type(gchar kind, TMParserType lang)
1161 TMParserMap *map = &parser_map[lang];
1162 guint i;
1164 for (i = 0; i < map->size; i++)
1166 TMParserMapEntry *entry = &map->entries[i];
1168 if (entry->kind == kind)
1169 return entry->type;
1171 return tm_tag_undef_t;
1175 gchar tm_parser_get_tag_kind(TMTagType type, TMParserType lang)
1177 TMParserMap *map = &parser_map[lang];
1178 guint i;
1180 for (i = 0; i < map->size; i++)
1182 TMParserMapEntry *entry = &map->entries[i];
1184 if (entry->type == type)
1185 return entry->kind;
1187 return '\0';
1191 gint tm_parser_get_sidebar_group(TMParserType lang, TMTagType type)
1193 TMParserMap *map;
1194 guint i;
1196 if (lang >= TM_PARSER_COUNT)
1197 return -1;
1199 map = &parser_map[lang];
1200 for (i = 0; i < map->group_num; i++)
1202 if (map->groups[i].types & type)
1203 return i + 1; // "Symbols" group is always first
1205 return -1;
1209 const gchar *tm_parser_get_sidebar_info(TMParserType lang, gint group, guint *icon)
1211 const gchar *name;
1212 TMParserMap *map;
1213 TMParserMapGroup *grp;
1215 if (lang >= TM_PARSER_COUNT)
1216 return NULL;
1218 if (group == 0)
1220 name = _("Symbols");
1221 *icon = TM_ICON_NAMESPACE;
1223 else
1225 map = &parser_map[lang];
1226 if (group > (gint)map->group_num)
1227 return NULL;
1229 grp = &map->groups[group - 1];
1230 name = _(grp->name);
1231 *icon = grp->icon;
1234 return name;
1238 static void add_subparser(TMParserType lang, TMParserType sublang, TMSubparserMapEntry *map, guint map_size)
1240 guint i;
1241 GPtrArray *mapping;
1242 GHashTable *lang_map = g_hash_table_lookup(subparser_map, GINT_TO_POINTER(lang));
1244 if (!lang_map)
1246 lang_map = g_hash_table_new(g_direct_hash, g_direct_equal);
1247 g_hash_table_insert(subparser_map, GINT_TO_POINTER(lang), lang_map);
1250 mapping = g_ptr_array_new();
1251 for (i = 0; i < map_size; i++)
1252 g_ptr_array_add(mapping, &map[i]);
1254 g_hash_table_insert(lang_map, GINT_TO_POINTER(sublang), mapping);
1258 #define SUBPARSER_MAP_ENTRY(lang, sublang, map) add_subparser(TM_PARSER_##lang, TM_PARSER_##sublang, map, G_N_ELEMENTS(map))
1260 static void init_subparser_map(void)
1262 SUBPARSER_MAP_ENTRY(HTML, JAVASCRIPT, subparser_HTML_javascript_map);
1263 SUBPARSER_MAP_ENTRY(TCLOO, TCL, subparser_TCLOO_TCL_map);
1267 TMTagType tm_parser_get_subparser_type(TMParserType lang, TMParserType sublang, TMTagType type)
1269 guint i;
1270 GHashTable *lang_map;
1271 GPtrArray *mapping;
1273 if (!subparser_map)
1275 subparser_map = g_hash_table_new(g_direct_hash, g_direct_equal);
1276 init_subparser_map();
1279 lang_map = g_hash_table_lookup(subparser_map, GINT_TO_POINTER(lang));
1280 if (!lang_map)
1281 return tm_tag_undef_t;
1283 mapping = g_hash_table_lookup(lang_map, GINT_TO_POINTER(sublang));
1284 if (!mapping)
1285 return tm_tag_undef_t;
1287 for (i = 0; i < mapping->len; i++)
1289 TMSubparserMapEntry *entry = mapping->pdata[i];
1290 if (entry->orig_type == type)
1291 return entry->new_type;
1294 return tm_tag_undef_t;
1298 void tm_parser_verify_type_mappings(void)
1300 TMParserType lang;
1302 if (TM_PARSER_COUNT > tm_ctags_get_lang_count())
1303 g_error("More parsers defined in Geany than in ctags");
1305 for (lang = 0; lang < TM_PARSER_COUNT; lang++)
1307 const gchar *kinds = tm_ctags_get_lang_kinds(lang);
1308 TMParserMap *map = &parser_map[lang];
1309 gchar presence_map[256];
1310 TMTagType lang_types = 0;
1311 TMTagType group_types = 0;
1312 guint i;
1314 if (! map->entries || map->size < 1)
1315 g_error("No tag types in TM for %s, is the language listed in parser_map?",
1316 tm_ctags_get_lang_name(lang));
1318 if (map->size != strlen(kinds))
1319 g_error("Different number of tag types in TM (%d) and ctags (%d) for %s",
1320 map->size, (int)strlen(kinds), tm_ctags_get_lang_name(lang));
1322 memset(presence_map, 0, sizeof(presence_map));
1323 for (i = 0; i < map->size; i++)
1325 gboolean ctags_found = FALSE;
1326 gboolean tm_found = FALSE;
1327 guint j;
1329 for (j = 0; j < map->size; j++)
1331 /* check that for every type in TM there's a type in ctags */
1332 if (map->entries[i].kind == kinds[j])
1333 ctags_found = TRUE;
1334 /* check that for every type in ctags there's a type in TM */
1335 if (map->entries[j].kind == kinds[i])
1336 tm_found = TRUE;
1337 if (ctags_found && tm_found)
1338 break;
1340 if (!ctags_found)
1341 g_error("Tag type '%c' found in TM but not in ctags for %s",
1342 map->entries[i].kind, tm_ctags_get_lang_name(lang));
1343 if (!tm_found)
1344 g_error("Tag type '%c' found in ctags but not in TM for %s",
1345 kinds[i], tm_ctags_get_lang_name(lang));
1347 presence_map[(unsigned char) map->entries[i].kind]++;
1348 lang_types |= map->entries[i].type;
1351 for (i = 0; i < sizeof(presence_map); i++)
1353 if (presence_map[i] > 1)
1354 g_error("Duplicate tag type '%c' found for %s",
1355 (gchar)i, tm_ctags_get_lang_name(lang));
1358 for (i = 0; i < map->group_num; i++)
1359 group_types |= map->groups[i].types;
1361 if ((group_types & lang_types) != lang_types)
1362 g_warning("Not all tag types mapped to symbol tree groups for %s",
1363 tm_ctags_get_lang_name(lang));
1368 /* When the suffix of 'str' is an operator that should trigger scope
1369 * autocompletion, this function should return the length of the operator,
1370 * zero otherwise. */
1371 gint tm_parser_scope_autocomplete_suffix(TMParserType lang, const gchar *str)
1373 const gchar *sep = tm_parser_scope_separator(lang);
1375 if (g_str_has_suffix(str, sep))
1376 return strlen(sep);
1378 switch (lang)
1380 case TM_PARSER_C:
1381 case TM_PARSER_CPP:
1382 if (g_str_has_suffix(str, "."))
1383 return 1;
1384 else if (g_str_has_suffix(str, "->"))
1385 return 2;
1386 else if (lang == TM_PARSER_CPP && g_str_has_suffix(str, "->*"))
1387 return 3;
1388 default:
1389 break;
1391 return 0;
1395 /* Get the name of constructor method. Arguments of this method will be used
1396 * for calltips when creating an object using the class name
1397 * (e.g. after the opening brace in 'c = MyClass()' in Python) */
1398 const gchar *tm_parser_get_constructor_method(TMParserType lang)
1400 switch (lang)
1402 case TM_PARSER_D:
1403 return "this";
1404 case TM_PARSER_PYTHON:
1405 return "__init__";
1406 default:
1407 return NULL;
1412 /* determine anonymous tags from tag names only when corresponding
1413 * ctags information is not available */
1414 gboolean tm_parser_is_anon_name(TMParserType lang, gchar *name)
1416 guint i;
1417 char dummy;
1419 if (sscanf(name, "__anon%u%c", &i, &dummy) == 1) /* uctags tags files */
1420 return TRUE;
1421 else if (lang == TM_PARSER_C || lang == TM_PARSER_CPP) /* legacy Geany tags files */
1422 return sscanf(name, "anon_%*[a-z]_%u%c", &i, &dummy) == 1;
1423 else if (lang == TM_PARSER_FORTRAN) /* legacy Geany tags files */
1425 return sscanf(name, "Structure#%u%c", &i, &dummy) == 1 ||
1426 sscanf(name, "Interface#%u%c", &i, &dummy) == 1 ||
1427 sscanf(name, "Enum#%u%c", &i, &dummy) == 1;
1429 return FALSE;
1433 static gchar *replace_string_if_present(gchar *haystack, gchar *needle, gchar *subst)
1435 if (strstr(haystack, needle))
1437 gchar **split = g_strsplit(haystack, needle, -1);
1438 gchar *ret = g_strjoinv(subst, split);
1439 g_strfreev(split);
1440 return ret;
1442 return haystack;
1446 /* return updated scope or original scope if no change needed */
1447 gchar *tm_parser_update_scope(TMParserType lang, gchar *scope)
1449 switch (lang)
1451 case TM_PARSER_PHP:
1452 case TM_PARSER_ZEPHIR:
1453 /* PHP parser uses two different scope separators but this would
1454 * complicate things in Geany so make sure there's just one type */
1455 return replace_string_if_present(scope, "\\", "::");
1456 case TM_PARSER_TCL:
1457 case TM_PARSER_TCLOO:
1458 /* The TCL(OO) parser returns scope prefixed with :: which we don't
1459 * want. */
1460 if (g_str_has_prefix(scope, "::"))
1461 return g_strdup(scope + 2);
1462 break;
1464 return scope;
1468 /* whether or not to enable ctags roles for the given language and kind */
1469 gboolean tm_parser_enable_role(TMParserType lang, gchar kind)
1471 switch (lang)
1473 case TM_PARSER_GDSCRIPT:
1474 return kind == 'c' ? FALSE : TRUE;
1475 case TM_PARSER_GO:
1476 /* 'p' is used both for package definition tags and imported package
1477 * tags and we can't tell which is which just by kind. By disabling
1478 * roles for this kind, we only get package definition tags. */
1479 return kind == 'p' ? FALSE : TRUE;
1481 return TRUE;
1485 /* whether or not to enable ctags kinds for the given language */
1486 gboolean tm_parser_enable_kind(TMParserType lang, gchar kind)
1488 TMParserMap *map;
1489 guint i;
1491 if (lang >= TM_PARSER_COUNT)
1492 /* Fatal error but tm_parser_verify_type_mappings() will provide
1493 * better message later */
1494 return FALSE;
1496 map = &parser_map[lang];
1497 for (i = 0; i < map->size; i++)
1499 if (map->entries[i].kind == kind)
1500 return map->entries[i].type != tm_tag_undef_t;
1502 return FALSE;
1506 gchar *tm_parser_format_variable(TMParserType lang, const gchar *name, const gchar *type)
1508 if (!type)
1509 return NULL;
1511 switch (lang)
1513 case TM_PARSER_GO:
1514 return g_strconcat(name, " ", type, NULL);
1515 case TM_PARSER_PASCAL:
1516 case TM_PARSER_PYTHON:
1517 return g_strconcat(name, ": ", type, NULL);
1518 default:
1519 return g_strconcat(type, " ", name, NULL);
1524 gchar *tm_parser_format_function(TMParserType lang, const gchar *fname, const gchar *args,
1525 const gchar *retval, const gchar *scope)
1527 GString *str;
1529 if (!args) /* not a function */
1530 return NULL;
1532 str = g_string_new(NULL);
1534 if (scope)
1536 g_string_append(str, scope);
1537 g_string_append(str, tm_parser_scope_separator_printable(lang));
1539 g_string_append(str, fname);
1540 g_string_append_c(str, ' ');
1541 g_string_append(str, args);
1543 if (retval)
1545 switch (lang)
1547 case TM_PARSER_GDSCRIPT:
1548 case TM_PARSER_GO:
1549 case TM_PARSER_PASCAL:
1550 case TM_PARSER_PYTHON:
1552 /* retval after function */
1553 const gchar *sep;
1554 switch (lang)
1556 case TM_PARSER_PASCAL:
1557 sep = ": ";
1558 break;
1559 case TM_PARSER_GDSCRIPT:
1560 case TM_PARSER_PYTHON:
1561 sep = " -> ";
1562 break;
1563 default:
1564 sep = " ";
1565 break;
1567 g_string_append(str, sep);
1568 g_string_append(str, retval);
1569 break;
1571 default:
1572 /* retval before function */
1573 g_string_prepend_c(str, ' ');
1574 g_string_prepend(str, retval);
1575 break;
1579 return g_string_free(str, FALSE);
1583 const gchar *tm_parser_scope_separator(TMParserType lang)
1585 switch (lang)
1587 case TM_PARSER_C: /* for C++ .h headers or C structs */
1588 case TM_PARSER_CPP:
1589 case TM_PARSER_CUDA:
1590 case TM_PARSER_PHP:
1591 case TM_PARSER_POWERSHELL:
1592 case TM_PARSER_RUST:
1593 case TM_PARSER_TCL:
1594 case TM_PARSER_TCLOO:
1595 case TM_PARSER_ZEPHIR:
1596 return "::";
1598 case TM_PARSER_LATEX:
1599 case TM_PARSER_MARKDOWN:
1600 case TM_PARSER_TXT2TAGS:
1601 return "\"\"";
1603 /* these parsers don't report nested scopes but default "." for scope separator
1604 * might appear in the text so use something more improbable */
1605 case TM_PARSER_ASCIIDOC:
1606 case TM_PARSER_CONF:
1607 case TM_PARSER_REST:
1608 return "\x3";
1610 default:
1611 return ".";
1616 const gchar *tm_parser_scope_separator_printable(TMParserType lang)
1618 switch (lang)
1620 case TM_PARSER_ASCIIDOC:
1621 case TM_PARSER_CONF:
1622 case TM_PARSER_LATEX:
1623 case TM_PARSER_MARKDOWN:
1624 case TM_PARSER_REST:
1625 case TM_PARSER_TXT2TAGS:
1626 return " > ";
1628 default:
1629 return tm_parser_scope_separator(lang);
1634 gboolean tm_parser_has_full_scope(TMParserType lang)
1636 switch (lang)
1638 /* These parsers include full hierarchy in the tag scope, separated by tm_parser_scope_separator() */
1639 case TM_PARSER_ACTIONSCRIPT:
1640 case TM_PARSER_C:
1641 case TM_PARSER_CPP:
1642 case TM_PARSER_CUDA:
1643 case TM_PARSER_CSHARP:
1644 case TM_PARSER_COBOL:
1645 case TM_PARSER_D:
1646 case TM_PARSER_GDSCRIPT:
1647 case TM_PARSER_GO:
1648 case TM_PARSER_JAVA:
1649 case TM_PARSER_JAVASCRIPT:
1650 case TM_PARSER_JSON:
1651 case TM_PARSER_LATEX:
1652 case TM_PARSER_LUA:
1653 case TM_PARSER_MARKDOWN:
1654 case TM_PARSER_PHP:
1655 case TM_PARSER_POWERSHELL:
1656 case TM_PARSER_PYTHON:
1657 case TM_PARSER_R:
1658 case TM_PARSER_RUBY:
1659 case TM_PARSER_RUST:
1660 case TM_PARSER_SQL:
1661 case TM_PARSER_TCL:
1662 case TM_PARSER_TCLOO:
1663 case TM_PARSER_TXT2TAGS:
1664 case TM_PARSER_TYPESCRIPT:
1665 case TM_PARSER_VALA:
1666 case TM_PARSER_VHDL:
1667 case TM_PARSER_VERILOG:
1668 case TM_PARSER_ZEPHIR:
1669 return TRUE;
1671 /* These make use of the scope, but don't include nested hierarchy
1672 * (either as a parser limitation or a language semantic) */
1673 case TM_PARSER_ADA:
1674 case TM_PARSER_ASCIIDOC:
1675 case TM_PARSER_CLOJURE:
1676 case TM_PARSER_CONF:
1677 case TM_PARSER_ERLANG:
1678 case TM_PARSER_FORTRAN:
1679 case TM_PARSER_OBJC:
1680 case TM_PARSER_REST:
1681 /* Other parsers don't use scope at all (or should be somewhere above) */
1682 default:
1683 return FALSE;
1688 gboolean tm_parser_langs_compatible(TMParserType lang, TMParserType other)
1690 if (lang == TM_PARSER_NONE || other == TM_PARSER_NONE)
1691 return FALSE;
1692 if (lang == other)
1693 return TRUE;
1694 /* Accept CPP tags for C lang and vice versa */
1695 else if (lang == TM_PARSER_C && other == TM_PARSER_CPP)
1696 return TRUE;
1697 else if (lang == TM_PARSER_CPP && other == TM_PARSER_C)
1698 return TRUE;
1700 return FALSE;