Add batch file ctags parser
[geany-mirror.git] / src / tagmanager / tm_parser.c
blob2b9f91788e6477a7a238a2820e1485e77cab74b7
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 /* Only for the command-line xgettext tool to find translatable strings.
30 * The gettext() function is invoked manually using glib g_dgettext() */
31 #define _(String) (String)
33 typedef struct
35 const gchar kind;
36 TMTagType type;
37 } TMParserMapEntry;
39 /* Allows remapping a subparser tag type to another type if there's a clash with
40 * the master parser tag type. Only subparser tag types explicitly listed within
41 * TMSubparserMapEntry maps are added to tag manager - tags with types not listed
42 * are discarded to prevent uncontrolled merging of tags from master parser and
43 * subparsers. */
44 typedef struct
46 TMTagType orig_type;
47 TMTagType new_type;
48 } TMSubparserMapEntry;
50 typedef struct
52 const gchar *name;
53 guint icon;
54 TMTagType types;
55 } TMParserMapGroup;
57 static GHashTable *subparser_map = NULL;
60 #define COMMON_C \
61 {'d', tm_tag_macro_t}, /* macro */ \
62 {'e', tm_tag_enumerator_t}, /* enumerator */ \
63 {'f', tm_tag_function_t}, /* function */ \
64 {'g', tm_tag_enum_t}, /* enum */ \
65 {'m', tm_tag_member_t}, /* member */ \
66 {'p', tm_tag_prototype_t}, /* prototype */ \
67 {'s', tm_tag_struct_t}, /* struct */ \
68 {'t', tm_tag_typedef_t}, /* typedef */ \
69 {'u', tm_tag_union_t}, /* union */ \
70 {'v', tm_tag_variable_t}, /* variable */ \
71 {'x', tm_tag_externvar_t}, /* externvar */ \
72 {'h', tm_tag_include_t}, /* header */ \
73 {'l', tm_tag_local_var_t}, /* local */ \
74 {'z', tm_tag_local_var_t}, /* parameter */ \
75 {'L', tm_tag_undef_t}, /* label */ \
76 {'D', tm_tag_undef_t}, /* macroparam */
78 static TMParserMapEntry map_C[] = {
79 COMMON_C
81 /* Used also by other languages than C - keep all the tm_tag_* here even though
82 * they aren't used by C as they might be used by some other language */
83 static TMParserMapGroup group_C[] = {
84 {_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t | tm_tag_package_t | tm_tag_include_t},
85 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
86 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
87 {_("Functions"), TM_ICON_METHOD, tm_tag_prototype_t | tm_tag_method_t | tm_tag_function_t},
88 {_("Members"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_field_t},
89 {_("Structs"), TM_ICON_STRUCT, tm_tag_union_t | tm_tag_struct_t},
90 {_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t | tm_tag_enum_t},
91 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t | tm_tag_macro_with_arg_t},
92 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t | tm_tag_local_var_t},
93 {_("Extern Variables"), TM_ICON_VAR, tm_tag_externvar_t},
94 {_("Other"), TM_ICON_OTHER, tm_tag_other_t},
97 static TMParserMapEntry map_CPP[] = {
98 COMMON_C
99 {'c', tm_tag_class_t}, // class
100 {'n', tm_tag_namespace_t}, // namespace
101 {'A', tm_tag_undef_t}, // alias
102 {'N', tm_tag_undef_t}, // name
103 {'U', tm_tag_undef_t}, // using
104 {'Z', tm_tag_undef_t}, // tparam
106 #define group_CPP group_C
108 static TMParserMapEntry map_JAVA[] = {
109 {'c', tm_tag_class_t}, // class
110 {'f', tm_tag_field_t}, // field
111 {'i', tm_tag_interface_t}, // interface
112 {'m', tm_tag_method_t}, // method
113 {'p', tm_tag_package_t}, // package
114 {'e', tm_tag_enumerator_t}, // enumConstant
115 {'g', tm_tag_enum_t}, // enum
117 static TMParserMapGroup group_JAVA[] = {
118 {_("Package"), TM_ICON_NAMESPACE, tm_tag_package_t},
119 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
120 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
121 {_("Methods"), TM_ICON_METHOD, tm_tag_method_t},
122 {_("Members"), TM_ICON_MEMBER, tm_tag_field_t},
123 {_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
124 {_("Other"), TM_ICON_VAR, tm_tag_enumerator_t},
127 // no scope information
128 static TMParserMapEntry map_MAKEFILE[] = {
129 {'m', tm_tag_macro_t}, // macro
130 {'t', tm_tag_function_t}, // target
131 {'I', tm_tag_undef_t}, // makefile
133 static TMParserMapGroup group_MAKEFILE[] = {
134 {_("Targets"), TM_ICON_METHOD, tm_tag_function_t},
135 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
138 static TMParserMapEntry map_PASCAL[] = {
139 {'f', tm_tag_function_t}, // function
140 {'p', tm_tag_function_t}, // procedure
142 static TMParserMapGroup group_PASCAL[] = {
143 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
146 // no scope information
147 static TMParserMapEntry map_PERL[] = {
148 {'c', tm_tag_enum_t}, // constant
149 {'f', tm_tag_other_t}, // format
150 {'l', tm_tag_macro_t}, // label
151 {'p', tm_tag_package_t}, // package
152 {'s', tm_tag_function_t}, // subroutine
153 {'d', tm_tag_prototype_t}, // subroutineDeclaration
154 {'M', tm_tag_undef_t}, // module
156 static TMParserMapGroup group_PERL[] = {
157 {_("Package"), TM_ICON_NAMESPACE, tm_tag_package_t},
158 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
159 {_("Labels"), TM_ICON_NONE, tm_tag_macro_t},
160 {_("Constants"), TM_ICON_NONE, tm_tag_enum_t},
161 {_("Other"), TM_ICON_OTHER, tm_tag_other_t},
164 static TMParserMapEntry map_PHP[] = {
165 {'c', tm_tag_class_t}, // class
166 {'d', tm_tag_macro_t}, // define
167 {'f', tm_tag_function_t}, // function
168 {'i', tm_tag_interface_t}, // interface
169 {'l', tm_tag_local_var_t}, // local
170 {'n', tm_tag_namespace_t}, // namespace
171 {'t', tm_tag_struct_t}, // trait
172 {'v', tm_tag_variable_t}, // variable
173 {'a', tm_tag_undef_t}, // alias
175 static TMParserMapGroup group_PHP[] = {
176 {_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
177 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
178 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
179 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
180 {_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
181 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
182 {_("Traits"), TM_ICON_STRUCT, tm_tag_struct_t},
185 static TMParserMapEntry map_PYTHON[] = {
186 {'c', tm_tag_class_t}, // class
187 {'f', tm_tag_function_t}, // function
188 {'m', tm_tag_method_t}, // member
189 {'v', tm_tag_variable_t}, // variable
190 {'I', tm_tag_externvar_t}, // namespace
191 {'i', tm_tag_externvar_t}, // module
192 /* defined as externvar to get those excluded as forward type in symbols.c:goto_tag()
193 * so we can jump to the real implementation (if known) instead of to the import statement */
194 {'x', tm_tag_externvar_t}, // unknown
195 {'z', tm_tag_local_var_t}, // parameter
196 {'l', tm_tag_local_var_t}, // local
198 static TMParserMapGroup group_PYTHON[] = {
199 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
200 {_("Methods"), TM_ICON_MACRO, tm_tag_method_t},
201 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
202 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
203 {_("Imports"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
206 static TMParserMapEntry map_LATEX[] = {
207 {'p', tm_tag_enum_t}, // part
208 {'c', tm_tag_namespace_t}, // chapter
209 {'s', tm_tag_member_t}, // section
210 {'u', tm_tag_macro_t}, // subsection
211 {'b', tm_tag_variable_t}, // subsubsection
212 {'P', tm_tag_undef_t}, // paragraph
213 {'G', tm_tag_undef_t}, // subparagraph
214 {'l', tm_tag_struct_t}, // label
215 {'i', tm_tag_undef_t}, // xinput
216 {'B', tm_tag_field_t}, // bibitem
217 {'C', tm_tag_function_t}, // command
218 {'o', tm_tag_function_t}, // operator
219 {'e', tm_tag_class_t}, // environment
220 {'t', tm_tag_class_t}, // theorem
221 {'N', tm_tag_undef_t}, // counter
223 static TMParserMapGroup group_LATEX[] = {
224 {_("Command"), TM_ICON_NONE, tm_tag_function_t},
225 {_("Environment"), TM_ICON_NONE, tm_tag_class_t},
226 {_("Part"), TM_ICON_NONE, tm_tag_enum_t},
227 {_("Chapter"), TM_ICON_NONE, tm_tag_namespace_t},
228 {_("Section"), TM_ICON_NONE, tm_tag_member_t},
229 {_("Subsection"), TM_ICON_NONE, tm_tag_macro_t},
230 {_("Subsubsection"), TM_ICON_NONE, tm_tag_variable_t},
231 {_("Bibitem"), TM_ICON_NONE, tm_tag_field_t},
232 {_("Label"), TM_ICON_NONE, tm_tag_struct_t},
235 // no scope information
236 static TMParserMapEntry map_BIBTEX[] = {
237 {'a', tm_tag_function_t}, // article
238 {'b', tm_tag_class_t}, // book
239 {'B', tm_tag_class_t}, // booklet
240 {'c', tm_tag_member_t}, // conference
241 {'i', tm_tag_macro_t}, // inbook
242 {'I', tm_tag_macro_t}, // incollection
243 {'j', tm_tag_member_t}, // inproceedings
244 {'m', tm_tag_other_t}, // manual
245 {'M', tm_tag_variable_t}, // mastersthesis
246 {'n', tm_tag_other_t}, // misc
247 {'p', tm_tag_variable_t}, // phdthesis
248 {'P', tm_tag_class_t}, // proceedings
249 {'s', tm_tag_namespace_t}, // string
250 {'t', tm_tag_other_t}, // techreport
251 {'u', tm_tag_externvar_t}, // unpublished
253 static TMParserMapGroup group_BIBTEX[] = {
254 {_("Articles"), TM_ICON_NONE, tm_tag_function_t},
255 {_("Book Chapters"), TM_ICON_NONE, tm_tag_macro_t},
256 {_("Books & Conference Proceedings"), TM_ICON_NONE, tm_tag_class_t},
257 {_("Conference Papers"), TM_ICON_NONE, tm_tag_member_t},
258 {_("Theses"), TM_ICON_NONE, tm_tag_variable_t},
259 {_("Strings"), TM_ICON_NONE, tm_tag_namespace_t},
260 {_("Unpublished"), TM_ICON_NONE, tm_tag_externvar_t},
261 {_("Other"), TM_ICON_NONE, tm_tag_other_t},
264 static TMParserMapEntry map_ASM[] = {
265 {'d', tm_tag_macro_t}, // define
266 {'l', tm_tag_namespace_t}, // label
267 {'m', tm_tag_function_t}, // macro
268 {'t', tm_tag_struct_t}, // type
269 {'s', tm_tag_undef_t}, // section
271 static TMParserMapGroup group_ASM[] = {
272 {_("Labels"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
273 {_("Macros"), TM_ICON_METHOD, tm_tag_function_t},
274 {_("Defines"), TM_ICON_MACRO, tm_tag_macro_t},
275 {_("Types"), TM_ICON_STRUCT, tm_tag_struct_t},
278 static TMParserMapEntry map_CONF[] = {
279 {'s', tm_tag_namespace_t}, // section
280 {'k', tm_tag_macro_t}, // key
282 static TMParserMapGroup group_CONF[] = {
283 {_("Sections"), TM_ICON_OTHER, tm_tag_namespace_t},
284 {_("Keys"), TM_ICON_VAR, tm_tag_macro_t},
287 static TMParserMapEntry map_SQL[] = {
288 {'c', tm_tag_undef_t}, // cursor
289 {'d', tm_tag_prototype_t}, // prototype
290 {'f', tm_tag_function_t}, // function
291 {'E', tm_tag_field_t}, // field
292 {'l', tm_tag_undef_t}, // local
293 {'L', tm_tag_undef_t}, // label
294 {'P', tm_tag_package_t}, // package
295 {'p', tm_tag_namespace_t}, // procedure
296 {'r', tm_tag_undef_t}, // record
297 {'s', tm_tag_undef_t}, // subtype
298 {'t', tm_tag_class_t}, // table
299 {'T', tm_tag_macro_t}, // trigger
300 {'v', tm_tag_variable_t}, // variable
301 {'i', tm_tag_struct_t}, // index
302 {'e', tm_tag_undef_t}, // event
303 {'U', tm_tag_undef_t}, // publication
304 {'R', tm_tag_undef_t}, // service
305 {'D', tm_tag_undef_t}, // domain
306 {'V', tm_tag_member_t}, // view
307 {'n', tm_tag_undef_t}, // synonym
308 {'x', tm_tag_undef_t}, // mltable
309 {'y', tm_tag_undef_t}, // mlconn
310 {'z', tm_tag_undef_t}, // mlprop
311 {'C', tm_tag_undef_t}, // ccflag
313 static TMParserMapGroup group_SQL[] = {
314 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
315 {_("Procedures"), TM_ICON_NAMESPACE, tm_tag_namespace_t | tm_tag_package_t},
316 {_("Indexes"), TM_ICON_STRUCT, tm_tag_struct_t},
317 {_("Tables"), TM_ICON_CLASS, tm_tag_class_t},
318 {_("Triggers"), TM_ICON_MACRO, tm_tag_macro_t},
319 {_("Views"), TM_ICON_VAR, tm_tag_field_t | tm_tag_member_t},
320 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
323 static TMParserMapEntry map_DOCBOOK[] = {
324 {'f', tm_tag_function_t},
325 {'c', tm_tag_class_t},
326 {'m', tm_tag_member_t},
327 {'d', tm_tag_macro_t},
328 {'v', tm_tag_variable_t},
329 {'s', tm_tag_struct_t},
331 static TMParserMapGroup group_DOCBOOK[] = {
332 {_("Chapter"), TM_ICON_NONE, tm_tag_function_t},
333 {_("Section"), TM_ICON_NONE, tm_tag_class_t},
334 {_("Sect1"), TM_ICON_NONE, tm_tag_member_t},
335 {_("Sect2"), TM_ICON_NONE, tm_tag_macro_t},
336 {_("Sect3"), TM_ICON_NONE, tm_tag_variable_t},
337 {_("Appendix"), TM_ICON_NONE, tm_tag_struct_t},
340 // no scope information
341 static TMParserMapEntry map_ERLANG[] = {
342 {'d', tm_tag_macro_t}, // macro
343 {'f', tm_tag_function_t}, // function
344 {'m', tm_tag_undef_t}, // module
345 {'r', tm_tag_struct_t}, // record
346 {'t', tm_tag_typedef_t}, // type
348 static TMParserMapGroup group_ERLANG[] = {
349 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
350 {_("Structs"), TM_ICON_STRUCT, tm_tag_struct_t},
351 {_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t},
352 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
355 // no scope information
356 static TMParserMapEntry map_CSS[] = {
357 {'c', tm_tag_class_t}, // class
358 {'s', tm_tag_struct_t}, // selector
359 {'i', tm_tag_variable_t}, // id
361 static TMParserMapGroup group_CSS[] = {
362 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
363 {_("ID Selectors"), TM_ICON_VAR, tm_tag_variable_t},
364 {_("Type Selectors"), TM_ICON_STRUCT, tm_tag_struct_t},
367 static TMParserMapEntry map_RUBY[] = {
368 {'c', tm_tag_class_t}, // class
369 {'f', tm_tag_method_t}, // method
370 {'m', tm_tag_namespace_t}, // module
371 {'S', tm_tag_member_t}, // singletonMethod
372 {'C', tm_tag_undef_t}, // constant
373 {'A', tm_tag_undef_t}, // accessor
374 {'a', tm_tag_undef_t}, // alias
375 {'L', tm_tag_undef_t}, // library
377 static TMParserMapGroup group_RUBY[] = {
378 {_("Modules"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
379 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
380 {_("Singletons"), TM_ICON_STRUCT, tm_tag_member_t},
381 {_("Methods"), TM_ICON_METHOD, tm_tag_method_t},
384 static TMParserMapEntry map_TCL[] = {
385 {'p', tm_tag_function_t}, // procedure
386 {'n', tm_tag_namespace_t}, // namespace
387 {'z', tm_tag_undef_t}, // parameter
389 static TMParserMapGroup group_TCL[] = {
390 {_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
391 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
392 {_("Methods"), TM_ICON_METHOD, tm_tag_member_t},
393 {_("Procedures"), TM_ICON_OTHER, tm_tag_function_t},
396 static TMParserMapEntry map_TCLOO[] = {
397 {'c', tm_tag_class_t}, // class
398 {'m', tm_tag_member_t}, // method
400 #define group_TCLOO group_TCL
402 static TMSubparserMapEntry subparser_TCLOO_TCL_map[] = {
403 {tm_tag_namespace_t, tm_tag_namespace_t},
404 {tm_tag_class_t, tm_tag_class_t},
405 {tm_tag_member_t, tm_tag_member_t},
406 {tm_tag_function_t, tm_tag_function_t},
409 static TMParserMapEntry map_SH[] = {
410 {'a', tm_tag_undef_t}, // alias
411 {'f', tm_tag_function_t}, // function
412 {'s', tm_tag_undef_t}, // script
413 {'h', tm_tag_undef_t}, // heredoc
415 static TMParserMapGroup group_SH[] = {
416 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
419 static TMParserMapEntry map_D[] = {
420 {'c', tm_tag_class_t}, // class
421 {'e', tm_tag_enumerator_t}, // enumerator
422 {'f', tm_tag_function_t}, // function
423 {'g', tm_tag_enum_t}, // enum
424 {'i', tm_tag_interface_t}, // interface
425 {'m', tm_tag_member_t}, // member
426 {'n', tm_tag_namespace_t}, // namespace
427 {'p', tm_tag_prototype_t}, // prototype
428 {'s', tm_tag_struct_t}, // struct
429 {'t', tm_tag_typedef_t}, // typedef
430 {'u', tm_tag_union_t}, // union
431 {'v', tm_tag_variable_t}, // variable
432 {'x', tm_tag_externvar_t}, // externvar
434 static TMParserMapGroup group_D[] = {
435 {_("Module"), TM_ICON_NONE, tm_tag_namespace_t},
436 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
437 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
438 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
439 {_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
440 {_("Structs"), TM_ICON_STRUCT, tm_tag_struct_t | tm_tag_union_t},
441 {_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t | tm_tag_enum_t},
442 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t},
443 {_("Extern Variables"), TM_ICON_VAR, tm_tag_externvar_t},
446 static TMParserMapEntry map_DIFF[] = {
447 {'m', tm_tag_function_t}, // modifiedFile
448 {'n', tm_tag_function_t}, // newFile
449 {'d', tm_tag_function_t}, // deletedFile
450 {'h', tm_tag_undef_t}, // hunk
452 static TMParserMapGroup group_DIFF[] = {
453 {_("Files"), TM_ICON_NONE, tm_tag_function_t},
456 static TMParserMapEntry map_VHDL[] = {
457 {'c', tm_tag_variable_t}, // constant
458 {'t', tm_tag_typedef_t}, // type
459 {'T', tm_tag_typedef_t}, // subtype
460 {'r', tm_tag_undef_t}, // record
461 {'e', tm_tag_class_t}, // entity
462 {'C', tm_tag_member_t}, // component
463 {'d', tm_tag_undef_t}, // prototype
464 {'f', tm_tag_function_t}, // function
465 {'p', tm_tag_function_t}, // procedure
466 {'P', tm_tag_namespace_t}, // package
467 {'l', tm_tag_variable_t}, // local
468 {'a', tm_tag_struct_t}, // architecture
469 {'q', tm_tag_variable_t}, // port
470 {'g', tm_tag_undef_t}, // generic
471 {'s', tm_tag_variable_t}, // signal
472 {'Q', tm_tag_member_t}, // process
473 {'v', tm_tag_variable_t}, // variable
474 {'A', tm_tag_typedef_t}, // alias
476 static TMParserMapGroup group_VHDL[] = {
477 {_("Package"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
478 {_("Entities"), TM_ICON_CLASS, tm_tag_class_t},
479 {_("Architectures"), TM_ICON_STRUCT, tm_tag_struct_t},
480 {_("Types"), TM_ICON_OTHER, tm_tag_typedef_t},
481 {_("Functions / Procedures"), TM_ICON_METHOD, tm_tag_function_t},
482 {_("Variables / Signals / Ports"), TM_ICON_VAR, tm_tag_variable_t},
483 {_("Processes / Blocks / Components"), TM_ICON_MEMBER, tm_tag_member_t},
486 static TMParserMapEntry map_LUA[] = {
487 {'f', tm_tag_function_t}, // function
488 {'X', tm_tag_undef_t}, // unknown
490 static TMParserMapGroup group_LUA[] = {
491 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
494 static TMParserMapEntry map_JAVASCRIPT[] = {
495 {'f', tm_tag_function_t}, // function
496 {'c', tm_tag_class_t}, // class
497 {'m', tm_tag_method_t}, // method
498 {'p', tm_tag_member_t}, // property
499 {'C', tm_tag_macro_t}, // constant
500 {'v', tm_tag_variable_t}, // variable
501 {'g', tm_tag_function_t}, // generator
502 {'G', tm_tag_undef_t}, // getter
503 {'S', tm_tag_undef_t}, // setter
504 {'M', tm_tag_undef_t}, // field
506 static TMParserMapGroup group_JAVASCRIPT[] = {
507 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
508 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
509 {_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
510 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
511 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
514 // no scope information
515 static TMParserMapEntry map_HASKELL[] = {
516 {'t', tm_tag_typedef_t}, // type
517 {'c', tm_tag_macro_t}, // constructor
518 {'f', tm_tag_function_t}, // function
519 {'m', tm_tag_namespace_t}, // module
521 static TMParserMapGroup group_HASKELL[] = {
522 {_("Module"), TM_ICON_NONE, tm_tag_namespace_t},
523 {_("Types"), TM_ICON_NONE, tm_tag_typedef_t},
524 {_("Type constructors"), TM_ICON_NONE, tm_tag_macro_t},
525 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
528 #define map_UNUSED1 map_HASKELL
529 #define group_UNUSED1 group_HASKELL
531 static TMParserMapEntry map_CSHARP[] = {
532 {'c', tm_tag_class_t}, // class
533 {'d', tm_tag_macro_t}, // macro
534 {'e', tm_tag_enumerator_t}, // enumerator
535 {'E', tm_tag_undef_t}, // event
536 {'f', tm_tag_field_t}, // field
537 {'g', tm_tag_enum_t}, // enum
538 {'i', tm_tag_interface_t}, // interface
539 {'l', tm_tag_undef_t}, // local
540 {'m', tm_tag_method_t}, // method
541 {'n', tm_tag_namespace_t}, // namespace
542 {'p', tm_tag_undef_t}, // property
543 {'s', tm_tag_struct_t}, // struct
544 {'t', tm_tag_typedef_t}, // typedef
546 #define group_CSHARP group_C
548 // no scope information
549 static TMParserMapEntry map_FREEBASIC[] = {
550 {'c', tm_tag_macro_t}, // constant
551 {'f', tm_tag_function_t}, // function
552 {'l', tm_tag_namespace_t}, // label
553 {'t', tm_tag_struct_t}, // type
554 {'v', tm_tag_variable_t}, // variable
555 {'g', tm_tag_externvar_t}, // enum
557 static TMParserMapGroup group_FREEBASIC[] = {
558 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
559 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_externvar_t},
560 {_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
561 {_("Types"), TM_ICON_NAMESPACE, tm_tag_struct_t},
562 {_("Labels"), TM_ICON_MEMBER, tm_tag_namespace_t},
565 // no scope information
566 static TMParserMapEntry map_HAXE[] = {
567 {'m', tm_tag_method_t}, // method
568 {'c', tm_tag_class_t}, // class
569 {'e', tm_tag_enum_t}, // enum
570 {'v', tm_tag_variable_t}, // variable
571 {'i', tm_tag_interface_t}, // interface
572 {'t', tm_tag_typedef_t}, // typedef
574 static TMParserMapGroup group_HAXE[] = {
575 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
576 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
577 {_("Methods"), TM_ICON_METHOD, tm_tag_method_t},
578 {_("Types"), TM_ICON_MACRO, tm_tag_typedef_t | tm_tag_enum_t},
579 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
582 static TMParserMapEntry map_REST[] = {
583 {'c', tm_tag_namespace_t}, // chapter
584 {'s', tm_tag_member_t}, // section
585 {'S', tm_tag_macro_t}, // subsection
586 {'t', tm_tag_variable_t}, // subsubsection
587 {'C', tm_tag_undef_t}, // citation
588 {'T', tm_tag_undef_t}, // target
589 {'d', tm_tag_undef_t}, // substdef
591 static TMParserMapGroup group_REST[] = {
592 {_("Chapter"), TM_ICON_NONE, tm_tag_namespace_t},
593 {_("Section"), TM_ICON_NONE, tm_tag_member_t},
594 {_("Subsection"), TM_ICON_NONE, tm_tag_macro_t},
595 {_("Subsubsection"), TM_ICON_NONE, tm_tag_variable_t},
598 // no scope information
599 static TMParserMapEntry map_HTML[] = {
600 {'a', tm_tag_member_t}, // anchor
601 {'c', tm_tag_undef_t}, // class
602 {'h', tm_tag_namespace_t}, // heading1
603 {'i', tm_tag_class_t}, // heading2
604 {'j', tm_tag_variable_t}, // heading3
605 {'C', tm_tag_undef_t}, // stylesheet
606 {'I', tm_tag_undef_t}, // id
607 {'J', tm_tag_undef_t}, // script
609 static TMParserMapGroup group_HTML[] = {
610 {_("Functions"), TM_ICON_NONE, tm_tag_function_t}, // javascript functions from subparser
611 {_("Anchors"), TM_ICON_NONE, tm_tag_member_t},
612 {_("H1 Headings"), TM_ICON_NONE, tm_tag_namespace_t},
613 {_("H2 Headings"), TM_ICON_NONE, tm_tag_class_t},
614 {_("H3 Headings"), TM_ICON_NONE, tm_tag_variable_t},
617 static TMSubparserMapEntry subparser_HTML_javascript_map[] = {
618 {tm_tag_function_t, tm_tag_function_t},
621 static TMParserMapEntry map_FORTRAN[] = {
622 {'b', tm_tag_undef_t}, // blockData
623 {'c', tm_tag_macro_t}, // common
624 {'e', tm_tag_undef_t}, // entry
625 {'E', tm_tag_enum_t}, // enum
626 {'f', tm_tag_function_t}, // function
627 {'i', tm_tag_interface_t}, // interface
628 {'k', tm_tag_member_t}, // component
629 {'l', tm_tag_undef_t}, // label
630 {'L', tm_tag_undef_t}, // local
631 {'m', tm_tag_namespace_t}, // module
632 {'M', tm_tag_member_t}, // method
633 {'n', tm_tag_undef_t}, // namelist
634 {'N', tm_tag_enumerator_t}, // enumerator
635 {'p', tm_tag_struct_t}, // program
636 {'P', tm_tag_undef_t}, // prototype
637 {'s', tm_tag_method_t}, // subroutine
638 {'t', tm_tag_class_t}, // type
639 {'v', tm_tag_variable_t}, // variable
640 {'S', tm_tag_undef_t}, // submodule
642 static TMParserMapGroup group_FORTRAN[] = {
643 {_("Module"), TM_ICON_CLASS, tm_tag_namespace_t},
644 {_("Programs"), TM_ICON_CLASS, tm_tag_struct_t},
645 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
646 {_("Functions / Subroutines"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
647 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t},
648 {_("Types"), TM_ICON_CLASS, tm_tag_class_t},
649 {_("Components"), TM_ICON_MEMBER, tm_tag_member_t},
650 {_("Blocks"), TM_ICON_MEMBER, tm_tag_macro_t},
651 {_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
654 static TMParserMapEntry map_MATLAB[] = {
655 {'f', tm_tag_function_t}, // function
656 {'s', tm_tag_struct_t}, // struct
658 static TMParserMapGroup group_MATLAB[] = {
659 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
660 {_("Structures"), TM_ICON_STRUCT, tm_tag_struct_t},
663 #define map_CUDA map_C
664 #define group_CUDA group_C
666 static TMParserMapEntry map_VALA[] = {
667 {'c', tm_tag_class_t}, // class
668 {'d', tm_tag_macro_t}, // macro
669 {'e', tm_tag_enumerator_t}, // enumerator
670 {'f', tm_tag_field_t}, // field
671 {'g', tm_tag_enum_t}, // enum
672 {'i', tm_tag_interface_t}, // interface
673 {'l', tm_tag_undef_t}, // local
674 {'m', tm_tag_method_t}, // method
675 {'n', tm_tag_namespace_t}, // namespace
676 {'p', tm_tag_undef_t}, // property
677 {'S', tm_tag_undef_t}, // signal
678 {'s', tm_tag_struct_t}, // struct
680 #define group_VALA group_C
682 static TMParserMapEntry map_ACTIONSCRIPT[] = {
683 {'f', tm_tag_function_t}, // function
684 {'c', tm_tag_class_t}, // class
685 {'i', tm_tag_interface_t}, // interface
686 {'P', tm_tag_package_t}, // package
687 {'m', tm_tag_method_t}, // method
688 {'p', tm_tag_member_t}, // property
689 {'v', tm_tag_variable_t}, // variable
690 {'l', tm_tag_variable_t}, // localvar
691 {'C', tm_tag_macro_t}, // constant
692 {'I', tm_tag_externvar_t}, // import
693 {'x', tm_tag_other_t}, // mxtag
695 static TMParserMapGroup group_ACTIONSCRIPT[] = {
696 {_("Imports"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
697 {_("Package"), TM_ICON_NAMESPACE, tm_tag_package_t},
698 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
699 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
700 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t| tm_tag_method_t},
701 {_("Properties"), TM_ICON_MEMBER, tm_tag_member_t},
702 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
703 {_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
704 {_("Other"), TM_ICON_OTHER, tm_tag_other_t},
707 static TMParserMapEntry map_NSIS[] = {
708 {'s', tm_tag_namespace_t}, // section
709 {'f', tm_tag_function_t}, // function
710 {'v', tm_tag_variable_t}, // variable
711 {'d', tm_tag_undef_t}, // definition
712 {'m', tm_tag_undef_t}, // macro
713 {'S', tm_tag_undef_t}, // sectionGroup
714 {'p', tm_tag_undef_t}, // macroparam
715 {'l', tm_tag_undef_t}, // langstr
716 {'i', tm_tag_undef_t}, // script
718 static TMParserMapGroup group_NSIS[] = {
719 {_("Sections"), TM_ICON_OTHER, tm_tag_namespace_t},
720 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
721 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
724 static TMParserMapEntry map_MARKDOWN[] = {
725 {'c', tm_tag_namespace_t}, //chapter
726 {'s', tm_tag_member_t}, //section
727 {'S', tm_tag_macro_t}, //subsection
728 {'t', tm_tag_variable_t}, //subsubsection
729 {'T', tm_tag_struct_t}, //l4subsection
730 {'u', tm_tag_union_t}, //l5subsection
731 {'n', tm_tag_undef_t}, //footnote
733 static TMParserMapGroup group_MARKDOWN[] = {
734 {_("Chapters"), TM_ICON_NONE, tm_tag_namespace_t},
735 {_("Sections"), TM_ICON_NONE, tm_tag_member_t},
736 {_("Subsections"), TM_ICON_NONE, tm_tag_macro_t},
737 {_("Subsubsections"), TM_ICON_NONE, tm_tag_variable_t},
738 {_("Level 4 sections"), TM_ICON_NONE, tm_tag_struct_t},
739 {_("Level 5 sections"), TM_ICON_NONE, tm_tag_union_t},
742 static TMParserMapEntry map_TXT2TAGS[] = {
743 {'s', tm_tag_member_t}, // section
745 #define group_TXT2TAGS group_REST
747 // no scope information
748 static TMParserMapEntry map_ABC[] = {
749 {'s', tm_tag_member_t}, // section
751 #define group_ABC group_REST
753 static TMParserMapEntry map_VERILOG[] = {
754 {'c', tm_tag_variable_t}, // constant
755 {'e', tm_tag_typedef_t}, // event
756 {'f', tm_tag_function_t}, // function
757 {'m', tm_tag_class_t}, // module
758 {'n', tm_tag_variable_t}, // net
759 {'p', tm_tag_variable_t}, // port
760 {'r', tm_tag_variable_t}, // register
761 {'t', tm_tag_function_t}, // task
762 {'b', tm_tag_undef_t}, // block
763 {'i', tm_tag_undef_t}, // instance
765 static TMParserMapGroup group_VERILOG[] = {
766 {_("Events"), TM_ICON_MACRO, tm_tag_typedef_t},
767 {_("Modules"), TM_ICON_CLASS, tm_tag_class_t},
768 {_("Functions / Tasks"), TM_ICON_METHOD, tm_tag_function_t},
769 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
772 static TMParserMapEntry map_R[] = {
773 {'f', tm_tag_function_t}, // function
774 {'l', tm_tag_other_t}, // library
775 {'s', tm_tag_other_t}, // source
776 {'g', tm_tag_undef_t}, // globalVar
777 {'v', tm_tag_undef_t}, // functionVar
778 {'z', tm_tag_undef_t}, // parameter
779 {'c', tm_tag_undef_t}, // vector
780 {'L', tm_tag_undef_t}, // list
781 {'d', tm_tag_undef_t}, // dataframe
782 {'n', tm_tag_undef_t}, // nameattr
784 static TMParserMapGroup group_R[] = {
785 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
786 {_("Other"), TM_ICON_NONE, tm_tag_other_t},
789 static TMParserMapEntry map_COBOL[] = {
790 {'f', tm_tag_function_t}, // fd
791 {'g', tm_tag_struct_t}, // group
792 {'P', tm_tag_class_t}, // program
793 {'s', tm_tag_namespace_t}, // section
794 {'D', tm_tag_interface_t}, // division
795 {'p', tm_tag_macro_t}, // paragraph
796 {'d', tm_tag_variable_t}, // data
797 {'S', tm_tag_externvar_t}, // sourcefile
799 static TMParserMapGroup group_COBOL[] = {
800 {_("Program"), TM_ICON_CLASS, tm_tag_class_t},
801 {_("File"), TM_ICON_METHOD, tm_tag_function_t},
802 {_("Divisions"), TM_ICON_NAMESPACE, tm_tag_interface_t},
803 {_("Sections"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
804 {_("Paragraph"), TM_ICON_OTHER, tm_tag_macro_t},
805 {_("Group"), TM_ICON_STRUCT, tm_tag_struct_t},
806 {_("Data"), TM_ICON_VAR, tm_tag_variable_t},
807 {_("Copies"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
810 static TMParserMapEntry map_OBJC[] = {
811 {'i', tm_tag_interface_t}, // interface
812 {'I', tm_tag_undef_t}, // implementation
813 {'P', tm_tag_undef_t}, // protocol
814 {'m', tm_tag_method_t}, // method
815 {'c', tm_tag_class_t}, // class
816 {'v', tm_tag_variable_t}, // var
817 {'E', tm_tag_field_t}, // field
818 {'f', tm_tag_function_t}, // function
819 {'p', tm_tag_undef_t}, // property
820 {'t', tm_tag_typedef_t}, // typedef
821 {'s', tm_tag_struct_t}, // struct
822 {'e', tm_tag_enum_t}, // enum
823 {'M', tm_tag_macro_t}, // macro
824 {'C', tm_tag_undef_t}, // category
826 #define group_OBJC group_C
828 static TMParserMapEntry map_ASCIIDOC[] = {
829 {'c', tm_tag_namespace_t}, //chapter
830 {'s', tm_tag_member_t}, //section
831 {'S', tm_tag_macro_t}, //subsection
832 {'t', tm_tag_variable_t}, //subsubsection
833 {'T', tm_tag_struct_t}, //l4subsection
834 {'u', tm_tag_undef_t}, //l5subsection
835 {'a', tm_tag_undef_t}, //anchor
837 static TMParserMapGroup group_ASCIIDOC[] = {
838 {_("Document"), TM_ICON_NONE, tm_tag_namespace_t},
839 {_("Section Level 1"), TM_ICON_NONE, tm_tag_member_t},
840 {_("Section Level 2"), TM_ICON_NONE, tm_tag_macro_t},
841 {_("Section Level 3"), TM_ICON_NONE, tm_tag_variable_t},
842 {_("Section Level 4"), TM_ICON_NONE, tm_tag_struct_t},
845 // no scope information
846 static TMParserMapEntry map_ABAQUS[] = {
847 {'p', tm_tag_class_t}, // part
848 {'a', tm_tag_member_t}, // assembly
849 {'s', tm_tag_interface_t}, // step
851 static TMParserMapGroup group_ABAQUS[] = {
852 {_("Parts"), TM_ICON_NONE, tm_tag_class_t},
853 {_("Assembly"), TM_ICON_NONE, tm_tag_member_t},
854 {_("Steps"), TM_ICON_NONE, tm_tag_interface_t},
857 static TMParserMapEntry map_RUST[] = {
858 {'n', tm_tag_namespace_t}, // module
859 {'s', tm_tag_struct_t}, // struct
860 {'i', tm_tag_interface_t}, // interface
861 {'c', tm_tag_class_t}, // implementation
862 {'f', tm_tag_function_t}, // function
863 {'g', tm_tag_enum_t}, // enum
864 {'t', tm_tag_typedef_t}, // typedef
865 {'v', tm_tag_variable_t}, // variable
866 {'M', tm_tag_macro_t}, // macro
867 {'m', tm_tag_field_t}, // field
868 {'e', tm_tag_enumerator_t}, // enumerator
869 {'P', tm_tag_method_t}, // method
871 static TMParserMapGroup group_RUST[] = {
872 {_("Modules"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
873 {_("Structures"), TM_ICON_STRUCT, tm_tag_struct_t},
874 {_("Traits"), TM_ICON_CLASS, tm_tag_interface_t},
875 {_("Implementations"), TM_ICON_CLASS, tm_tag_class_t},
876 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
877 {_("Typedefs / Enums"), TM_ICON_STRUCT, tm_tag_typedef_t | tm_tag_enum_t},
878 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_enumerator_t},
879 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
880 {_("Methods"), TM_ICON_MEMBER, tm_tag_field_t},
883 static TMParserMapEntry map_GO[] = {
884 {'p', tm_tag_namespace_t}, // package
885 {'f', tm_tag_function_t}, // func
886 {'c', tm_tag_macro_t}, // const
887 {'t', tm_tag_typedef_t}, // type
888 {'v', tm_tag_variable_t}, // var
889 {'s', tm_tag_struct_t}, // struct
890 {'i', tm_tag_interface_t}, // interface
891 {'m', tm_tag_member_t}, // member
892 {'M', tm_tag_undef_t}, // anonMember
893 {'n', tm_tag_undef_t}, // methodSpec
894 {'u', tm_tag_undef_t}, // unknown
895 {'P', tm_tag_undef_t}, // packageName
896 {'a', tm_tag_undef_t}, // talias
897 {'R', tm_tag_undef_t}, // receiver
899 static TMParserMapGroup group_GO[] = {
900 {_("Package"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
901 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
902 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
903 {_("Structs"), TM_ICON_STRUCT, tm_tag_struct_t},
904 {_("Types"), TM_ICON_STRUCT, tm_tag_typedef_t},
905 {_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
906 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
907 {_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
910 static TMParserMapEntry map_JSON[] = {
911 {'o', tm_tag_member_t}, // object
912 {'a', tm_tag_member_t}, // array
913 {'n', tm_tag_member_t}, // number
914 {'s', tm_tag_member_t}, // string
915 {'b', tm_tag_member_t}, // boolean
916 {'z', tm_tag_member_t}, // null
918 static TMParserMapGroup group_JSON[] = {
919 {_("Members"), TM_ICON_MEMBER, tm_tag_member_t},
922 /* Zephir, same as PHP */
923 #define map_ZEPHIR map_PHP
924 #define group_ZEPHIR group_PHP
926 static TMParserMapEntry map_POWERSHELL[] = {
927 {'f', tm_tag_function_t}, // function
928 {'v', tm_tag_variable_t}, // variable
930 static TMParserMapGroup group_POWERSHELL[] = {
931 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
932 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
935 static TMParserMapEntry map_JULIA[] = {
936 {'c', tm_tag_variable_t}, // constant
937 {'f', tm_tag_function_t}, // function
938 {'g', tm_tag_member_t}, // field
939 {'m', tm_tag_macro_t}, // macro
940 {'n', tm_tag_namespace_t}, // module
941 {'s', tm_tag_struct_t}, // struct
942 {'t', tm_tag_typedef_t}, // type
943 /* defined as externvar to get those excluded as forward type in symbols.c:goto_tag()
944 * so we can jump to the real implementation (if known) instead of to the import statement */
945 {'x', tm_tag_externvar_t}, // unknown
947 static TMParserMapGroup group_JULIA[] = {
948 {_("Constants"), TM_ICON_VAR, tm_tag_variable_t},
949 {_("Modules"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
950 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
951 {_("Fields"), TM_ICON_MEMBER, tm_tag_member_t},
952 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
953 {_("Structures"), TM_ICON_STRUCT, tm_tag_struct_t},
954 {_("Types"), TM_ICON_CLASS, tm_tag_typedef_t},
955 {_("Unknowns"), TM_ICON_OTHER, tm_tag_externvar_t},
958 static TMParserMapEntry map_CPREPROCESSOR[] = {
959 {'d', tm_tag_undef_t}, // macro
960 {'h', tm_tag_undef_t}, // header
961 {'D', tm_tag_undef_t}, // parameter
963 #define group_CPREPROCESSOR group_C
965 static TMParserMapEntry map_GDSCRIPT[] = {
966 {'c', tm_tag_class_t}, // class
967 {'m', tm_tag_method_t}, // method
968 {'v', tm_tag_variable_t}, // variable
969 {'C', tm_tag_variable_t}, // const
970 {'g', tm_tag_enum_t}, // enum
971 {'e', tm_tag_variable_t}, // enumerator
972 {'z', tm_tag_local_var_t}, // parameter
973 {'l', tm_tag_local_var_t}, // local
974 {'s', tm_tag_variable_t}, // signal
976 static TMParserMapGroup group_GDSCRIPT[] = {
977 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
978 {_("Methods"), TM_ICON_MACRO, tm_tag_method_t},
979 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
980 {_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
983 static TMParserMapEntry map_CLOJURE[] = {
984 {'f', tm_tag_function_t}, // function
985 {'n', tm_tag_namespace_t}, // namespace
987 static TMParserMapGroup group_CLOJURE[] = {
988 {_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
989 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
992 static TMParserMapEntry map_LISP[] = {
993 {'u', tm_tag_undef_t}, // unknown
994 {'f', tm_tag_function_t}, // function
995 {'v', tm_tag_variable_t}, // variable
996 {'m', tm_tag_macro_t}, // macro
997 {'c', tm_tag_field_t}, // const
999 static TMParserMapGroup group_LISP[] = {
1000 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
1001 {_("Macros"), TM_ICON_MACRO, tm_tag_macro_t},
1002 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
1003 {_("Constants"), TM_ICON_VAR, tm_tag_field_t},
1006 static TMParserMapEntry map_TYPESCRIPT[] = {
1007 {'f', tm_tag_function_t}, // function
1008 {'c', tm_tag_class_t}, // class
1009 {'i', tm_tag_interface_t}, // interface
1010 {'g', tm_tag_enum_t}, // enum
1011 {'e', tm_tag_enumerator_t}, // enumerator
1012 {'m', tm_tag_method_t}, // method
1013 {'n', tm_tag_namespace_t}, // namespace
1014 {'z', tm_tag_local_var_t}, // parameter
1015 {'p', tm_tag_member_t}, // property
1016 {'v', tm_tag_variable_t}, // variable
1017 {'l', tm_tag_local_var_t}, // local
1018 {'C', tm_tag_macro_t}, // constant
1019 {'G', tm_tag_undef_t}, // generator
1020 {'a', tm_tag_undef_t}, // alias
1022 static TMParserMapGroup group_TYPESCRIPT[] = {
1023 {_("Namespaces"), TM_ICON_NAMESPACE, tm_tag_namespace_t},
1024 {_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
1025 {_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
1026 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
1027 {_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
1028 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
1029 {_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
1030 {_("Other"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_enumerator_t},
1033 static TMParserMapEntry map_ADA[] = {
1034 {'P', tm_tag_package_t}, // packspec
1035 {'p', tm_tag_package_t}, // package
1036 {'T', tm_tag_typedef_t}, // typespec
1037 {'t', tm_tag_typedef_t}, // type
1038 {'U', tm_tag_undef_t}, // subspec
1039 {'u', tm_tag_typedef_t}, // subtype
1040 {'c', tm_tag_member_t}, // component
1041 {'l', tm_tag_enumerator_t}, // literal
1042 {'V', tm_tag_undef_t}, // varspec
1043 {'v', tm_tag_variable_t}, // variable
1044 {'f', tm_tag_undef_t}, // formal
1045 {'n', tm_tag_macro_t}, // constant
1046 {'x', tm_tag_undef_t}, // exception
1047 {'R', tm_tag_prototype_t}, // subprogspec
1048 {'r', tm_tag_function_t}, // subprogram
1049 {'K', tm_tag_prototype_t}, // taskspec
1050 {'k', tm_tag_method_t}, // task
1051 {'O', tm_tag_undef_t}, // protectspec
1052 {'o', tm_tag_undef_t}, // protected
1053 {'E', tm_tag_undef_t}, // entryspec
1054 {'e', tm_tag_undef_t}, // entry
1055 {'b', tm_tag_undef_t}, // label
1056 {'i', tm_tag_undef_t}, // identifier
1057 {'a', tm_tag_undef_t}, // autovar
1058 {'y', tm_tag_undef_t}, // anon
1060 static TMParserMapGroup group_ADA[] = {
1061 {_("Packages"), TM_ICON_NAMESPACE, tm_tag_package_t},
1062 {_("Types"), TM_ICON_STRUCT, tm_tag_typedef_t},
1063 {_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_prototype_t},
1064 {_("Tasks"), TM_ICON_METHOD, tm_tag_method_t},
1065 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
1066 {_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
1067 {_("Other"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_enumerator_t},
1070 static TMParserMapEntry map_BATCH[] = {
1071 {'l', tm_tag_other_t}, // label
1072 {'v', tm_tag_variable_t}, // variable
1074 static TMParserMapGroup group_BATCH[] = {
1075 {_("Labels"), TM_ICON_OTHER, tm_tag_other_t},
1076 {_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
1079 typedef struct
1081 TMParserMapEntry *entries;
1082 guint size;
1083 TMParserMapGroup *groups;
1084 guint group_num;
1085 } TMParserMap;
1087 #define MAP_ENTRY(lang) [TM_PARSER_##lang] = {map_##lang, G_N_ELEMENTS(map_##lang), group_##lang, G_N_ELEMENTS(group_##lang)}
1089 /* keep in sync with TM_PARSER_* definitions in the header */
1090 static TMParserMap parser_map[] = {
1091 MAP_ENTRY(C),
1092 MAP_ENTRY(CPP),
1093 MAP_ENTRY(JAVA),
1094 MAP_ENTRY(MAKEFILE),
1095 MAP_ENTRY(PASCAL),
1096 MAP_ENTRY(PERL),
1097 MAP_ENTRY(PHP),
1098 MAP_ENTRY(PYTHON),
1099 MAP_ENTRY(LATEX),
1100 MAP_ENTRY(BIBTEX),
1101 MAP_ENTRY(ASM),
1102 MAP_ENTRY(CONF),
1103 MAP_ENTRY(SQL),
1104 MAP_ENTRY(DOCBOOK),
1105 MAP_ENTRY(ERLANG),
1106 MAP_ENTRY(CSS),
1107 MAP_ENTRY(RUBY),
1108 MAP_ENTRY(TCL),
1109 MAP_ENTRY(SH),
1110 MAP_ENTRY(D),
1111 MAP_ENTRY(FORTRAN),
1112 MAP_ENTRY(GDSCRIPT),
1113 MAP_ENTRY(DIFF),
1114 MAP_ENTRY(VHDL),
1115 MAP_ENTRY(LUA),
1116 MAP_ENTRY(JAVASCRIPT),
1117 MAP_ENTRY(HASKELL),
1118 MAP_ENTRY(CSHARP),
1119 MAP_ENTRY(FREEBASIC),
1120 MAP_ENTRY(HAXE),
1121 MAP_ENTRY(REST),
1122 MAP_ENTRY(HTML),
1123 MAP_ENTRY(ADA),
1124 MAP_ENTRY(CUDA),
1125 MAP_ENTRY(MATLAB),
1126 MAP_ENTRY(VALA),
1127 MAP_ENTRY(ACTIONSCRIPT),
1128 MAP_ENTRY(NSIS),
1129 MAP_ENTRY(MARKDOWN),
1130 MAP_ENTRY(TXT2TAGS),
1131 MAP_ENTRY(ABC),
1132 MAP_ENTRY(VERILOG),
1133 MAP_ENTRY(R),
1134 MAP_ENTRY(COBOL),
1135 MAP_ENTRY(OBJC),
1136 MAP_ENTRY(ASCIIDOC),
1137 MAP_ENTRY(ABAQUS),
1138 MAP_ENTRY(RUST),
1139 MAP_ENTRY(GO),
1140 MAP_ENTRY(JSON),
1141 MAP_ENTRY(ZEPHIR),
1142 MAP_ENTRY(POWERSHELL),
1143 MAP_ENTRY(JULIA),
1144 MAP_ENTRY(CPREPROCESSOR),
1145 MAP_ENTRY(TCLOO),
1146 MAP_ENTRY(CLOJURE),
1147 MAP_ENTRY(LISP),
1148 MAP_ENTRY(TYPESCRIPT),
1149 MAP_ENTRY(BATCH),
1151 /* make sure the parser map is consistent and complete */
1152 G_STATIC_ASSERT(G_N_ELEMENTS(parser_map) == TM_PARSER_COUNT);
1155 TMTagType tm_parser_get_tag_type(gchar kind, TMParserType lang)
1157 TMParserMap *map = &parser_map[lang];
1158 guint i;
1160 for (i = 0; i < map->size; i++)
1162 TMParserMapEntry *entry = &map->entries[i];
1164 if (entry->kind == kind)
1165 return entry->type;
1167 return tm_tag_undef_t;
1171 gchar tm_parser_get_tag_kind(TMTagType type, TMParserType lang)
1173 TMParserMap *map = &parser_map[lang];
1174 guint i;
1176 for (i = 0; i < map->size; i++)
1178 TMParserMapEntry *entry = &map->entries[i];
1180 if (entry->type == type)
1181 return entry->kind;
1183 return '\0';
1187 gint tm_parser_get_sidebar_group(TMParserType lang, TMTagType type)
1189 TMParserMap *map;
1190 guint i;
1192 if (lang >= TM_PARSER_COUNT)
1193 return -1;
1195 map = &parser_map[lang];
1196 for (i = 0; i < map->group_num; i++)
1198 if (map->groups[i].types & type)
1199 return i + 1; // "Symbols" group is always first
1201 return -1;
1205 const gchar *tm_parser_get_sidebar_info(TMParserType lang, gint group, guint *icon)
1207 const gchar *name;
1208 TMParserMap *map;
1209 TMParserMapGroup *grp;
1211 if (lang >= TM_PARSER_COUNT)
1212 return NULL;
1214 if (group == 0)
1216 name = _("Symbols");
1217 *icon = TM_ICON_NAMESPACE;
1219 else
1221 map = &parser_map[lang];
1222 if (group > (gint)map->group_num)
1223 return NULL;
1225 grp = &map->groups[group - 1];
1226 name = grp->name;
1227 *icon = grp->icon;
1229 #ifdef GETTEXT_PACKAGE
1230 return g_dgettext(GETTEXT_PACKAGE, name);
1231 #else
1232 return name;
1233 #endif
1237 static void add_subparser(TMParserType lang, TMParserType sublang, TMSubparserMapEntry *map, guint map_size)
1239 guint i;
1240 GPtrArray *mapping;
1241 GHashTable *lang_map = g_hash_table_lookup(subparser_map, GINT_TO_POINTER(lang));
1243 if (!lang_map)
1245 lang_map = g_hash_table_new(g_direct_hash, g_direct_equal);
1246 g_hash_table_insert(subparser_map, GINT_TO_POINTER(lang), lang_map);
1249 mapping = g_ptr_array_new();
1250 for (i = 0; i < map_size; i++)
1251 g_ptr_array_add(mapping, &map[i]);
1253 g_hash_table_insert(lang_map, GINT_TO_POINTER(sublang), mapping);
1257 #define SUBPARSER_MAP_ENTRY(lang, sublang, map) add_subparser(TM_PARSER_##lang, TM_PARSER_##sublang, map, G_N_ELEMENTS(map))
1259 static void init_subparser_map(void)
1261 SUBPARSER_MAP_ENTRY(HTML, JAVASCRIPT, subparser_HTML_javascript_map);
1262 SUBPARSER_MAP_ENTRY(TCLOO, TCL, subparser_TCLOO_TCL_map);
1266 TMTagType tm_parser_get_subparser_type(TMParserType lang, TMParserType sublang, TMTagType type)
1268 guint i;
1269 GHashTable *lang_map;
1270 GPtrArray *mapping;
1272 if (!subparser_map)
1274 subparser_map = g_hash_table_new(g_direct_hash, g_direct_equal);
1275 init_subparser_map();
1278 lang_map = g_hash_table_lookup(subparser_map, GINT_TO_POINTER(lang));
1279 if (!lang_map)
1280 return tm_tag_undef_t;
1282 mapping = g_hash_table_lookup(lang_map, GINT_TO_POINTER(sublang));
1283 if (!mapping)
1284 return tm_tag_undef_t;
1286 for (i = 0; i < mapping->len; i++)
1288 TMSubparserMapEntry *entry = mapping->pdata[i];
1289 if (entry->orig_type == type)
1290 return entry->new_type;
1293 return tm_tag_undef_t;
1297 void tm_parser_verify_type_mappings(void)
1299 TMParserType lang;
1301 if (TM_PARSER_COUNT > tm_ctags_get_lang_count())
1302 g_error("More parsers defined in Geany than in ctags");
1304 for (lang = 0; lang < TM_PARSER_COUNT; lang++)
1306 const gchar *kinds = tm_ctags_get_lang_kinds(lang);
1307 TMParserMap *map = &parser_map[lang];
1308 gchar presence_map[256];
1309 TMTagType lang_types = 0;
1310 TMTagType group_types = 0;
1311 guint i;
1313 if (! map->entries || map->size < 1)
1314 g_error("No tag types in TM for %s, is the language listed in parser_map?",
1315 tm_ctags_get_lang_name(lang));
1317 if (map->size != strlen(kinds))
1318 g_error("Different number of tag types in TM (%d) and ctags (%d) for %s",
1319 map->size, (int)strlen(kinds), tm_ctags_get_lang_name(lang));
1321 memset(presence_map, 0, sizeof(presence_map));
1322 for (i = 0; i < map->size; i++)
1324 gboolean ctags_found = FALSE;
1325 gboolean tm_found = FALSE;
1326 guint j;
1328 for (j = 0; j < map->size; j++)
1330 /* check that for every type in TM there's a type in ctags */
1331 if (map->entries[i].kind == kinds[j])
1332 ctags_found = TRUE;
1333 /* check that for every type in ctags there's a type in TM */
1334 if (map->entries[j].kind == kinds[i])
1335 tm_found = TRUE;
1336 if (ctags_found && tm_found)
1337 break;
1339 if (!ctags_found)
1340 g_error("Tag type '%c' found in TM but not in ctags for %s",
1341 map->entries[i].kind, tm_ctags_get_lang_name(lang));
1342 if (!tm_found)
1343 g_error("Tag type '%c' found in ctags but not in TM for %s",
1344 kinds[i], tm_ctags_get_lang_name(lang));
1346 presence_map[(unsigned char) map->entries[i].kind]++;
1347 lang_types |= map->entries[i].type;
1350 for (i = 0; i < sizeof(presence_map); i++)
1352 if (presence_map[i] > 1)
1353 g_error("Duplicate tag type '%c' found for %s",
1354 (gchar)i, tm_ctags_get_lang_name(lang));
1357 for (i = 0; i < map->group_num; i++)
1358 group_types |= map->groups[i].types;
1360 if ((group_types & lang_types) != lang_types)
1361 g_warning("Not all tag types mapped to symbol tree groups for %s",
1362 tm_ctags_get_lang_name(lang));
1367 /* When the suffix of 'str' is an operator that should trigger scope
1368 * autocompletion, this function should return the length of the operator,
1369 * zero otherwise. */
1370 gint tm_parser_scope_autocomplete_suffix(TMParserType lang, const gchar *str)
1372 const gchar *sep = tm_parser_scope_separator(lang);
1374 if (g_str_has_suffix(str, sep))
1375 return strlen(sep);
1377 switch (lang)
1379 case TM_PARSER_C:
1380 case TM_PARSER_CPP:
1381 if (g_str_has_suffix(str, "."))
1382 return 1;
1383 else if (g_str_has_suffix(str, "->"))
1384 return 2;
1385 else if (lang == TM_PARSER_CPP && g_str_has_suffix(str, "->*"))
1386 return 3;
1387 default:
1388 break;
1390 return 0;
1394 /* Get the name of constructor method. Arguments of this method will be used
1395 * for calltips when creating an object using the class name
1396 * (e.g. after the opening brace in 'c = MyClass()' in Python) */
1397 const gchar *tm_parser_get_constructor_method(TMParserType lang)
1399 switch (lang)
1401 case TM_PARSER_D:
1402 return "this";
1403 case TM_PARSER_PYTHON:
1404 return "__init__";
1405 default:
1406 return NULL;
1411 /* determine anonymous tags from tag names only when corresponding
1412 * ctags information is not available */
1413 gboolean tm_parser_is_anon_name(TMParserType lang, gchar *name)
1415 guint i;
1416 char dummy;
1418 if (sscanf(name, "__anon%u%c", &i, &dummy) == 1) /* uctags tags files */
1419 return TRUE;
1420 else if (lang == TM_PARSER_C || lang == TM_PARSER_CPP) /* legacy Geany tags files */
1421 return sscanf(name, "anon_%*[a-z]_%u%c", &i, &dummy) == 1;
1422 else if (lang == TM_PARSER_FORTRAN) /* legacy Geany tags files */
1424 return sscanf(name, "Structure#%u%c", &i, &dummy) == 1 ||
1425 sscanf(name, "Interface#%u%c", &i, &dummy) == 1 ||
1426 sscanf(name, "Enum#%u%c", &i, &dummy) == 1;
1428 return FALSE;
1432 static gchar *replace_string_if_present(gchar *haystack, gchar *needle, gchar *subst)
1434 if (strstr(haystack, needle))
1436 gchar **split = g_strsplit(haystack, needle, -1);
1437 gchar *ret = g_strjoinv(subst, split);
1438 g_strfreev(split);
1439 return ret;
1441 return haystack;
1445 /* return updated scope or original scope if no change needed */
1446 gchar *tm_parser_update_scope(TMParserType lang, gchar *scope)
1448 switch (lang)
1450 case TM_PARSER_PHP:
1451 case TM_PARSER_ZEPHIR:
1452 /* PHP parser uses two different scope separators but this would
1453 * complicate things in Geany so make sure there's just one type */
1454 return replace_string_if_present(scope, "\\", "::");
1455 case TM_PARSER_TCL:
1456 case TM_PARSER_TCLOO:
1457 /* The TCL(OO) parser returns scope prefixed with :: which we don't
1458 * want. */
1459 if (g_str_has_prefix(scope, "::"))
1460 return g_strdup(scope + 2);
1461 break;
1463 return scope;
1467 /* whether or not to enable ctags roles for the given language and kind */
1468 gboolean tm_parser_enable_role(TMParserType lang, gchar kind)
1470 switch (lang)
1472 case TM_PARSER_GDSCRIPT:
1473 return kind == 'c' ? FALSE : TRUE;
1474 case TM_PARSER_GO:
1475 /* 'p' is used both for package definition tags and imported package
1476 * tags and we can't tell which is which just by kind. By disabling
1477 * roles for this kind, we only get package definition tags. */
1478 return kind == 'p' ? FALSE : TRUE;
1480 return TRUE;
1484 /* whether or not to enable ctags kinds for the given language */
1485 gboolean tm_parser_enable_kind(TMParserType lang, gchar kind)
1487 TMParserMap *map;
1488 guint i;
1490 if (lang >= TM_PARSER_COUNT)
1491 /* Fatal error but tm_parser_verify_type_mappings() will provide
1492 * better message later */
1493 return FALSE;
1495 map = &parser_map[lang];
1496 for (i = 0; i < map->size; i++)
1498 if (map->entries[i].kind == kind)
1499 return map->entries[i].type != tm_tag_undef_t;
1501 return FALSE;
1505 gchar *tm_parser_format_variable(TMParserType lang, const gchar *name, const gchar *type)
1507 if (!type)
1508 return NULL;
1510 switch (lang)
1512 case TM_PARSER_GO:
1513 return g_strconcat(name, " ", type, NULL);
1514 case TM_PARSER_PASCAL:
1515 case TM_PARSER_PYTHON:
1516 return g_strconcat(name, ": ", type, NULL);
1517 default:
1518 return g_strconcat(type, " ", name, NULL);
1523 gchar *tm_parser_format_function(TMParserType lang, const gchar *fname, const gchar *args,
1524 const gchar *retval, const gchar *scope)
1526 GString *str;
1528 if (!args) /* not a function */
1529 return NULL;
1531 str = g_string_new(NULL);
1533 if (scope)
1535 g_string_append(str, scope);
1536 g_string_append(str, tm_parser_scope_separator_printable(lang));
1538 g_string_append(str, fname);
1539 g_string_append_c(str, ' ');
1540 g_string_append(str, args);
1542 if (retval)
1544 switch (lang)
1546 case TM_PARSER_GDSCRIPT:
1547 case TM_PARSER_GO:
1548 case TM_PARSER_PASCAL:
1549 case TM_PARSER_PYTHON:
1551 /* retval after function */
1552 const gchar *sep;
1553 switch (lang)
1555 case TM_PARSER_PASCAL:
1556 sep = ": ";
1557 break;
1558 case TM_PARSER_GDSCRIPT:
1559 case TM_PARSER_PYTHON:
1560 sep = " -> ";
1561 break;
1562 default:
1563 sep = " ";
1564 break;
1566 g_string_append(str, sep);
1567 g_string_append(str, retval);
1568 break;
1570 default:
1571 /* retval before function */
1572 g_string_prepend_c(str, ' ');
1573 g_string_prepend(str, retval);
1574 break;
1578 return g_string_free(str, FALSE);
1582 const gchar *tm_parser_scope_separator(TMParserType lang)
1584 switch (lang)
1586 case TM_PARSER_C: /* for C++ .h headers or C structs */
1587 case TM_PARSER_CPP:
1588 case TM_PARSER_CUDA:
1589 case TM_PARSER_PHP:
1590 case TM_PARSER_POWERSHELL:
1591 case TM_PARSER_RUST:
1592 case TM_PARSER_TCL:
1593 case TM_PARSER_TCLOO:
1594 case TM_PARSER_ZEPHIR:
1595 return "::";
1597 case TM_PARSER_LATEX:
1598 case TM_PARSER_MARKDOWN:
1599 case TM_PARSER_TXT2TAGS:
1600 return "\"\"";
1602 /* these parsers don't report nested scopes but default "." for scope separator
1603 * might appear in the text so use something more improbable */
1604 case TM_PARSER_ASCIIDOC:
1605 case TM_PARSER_CONF:
1606 case TM_PARSER_REST:
1607 return "\x3";
1609 default:
1610 return ".";
1615 const gchar *tm_parser_scope_separator_printable(TMParserType lang)
1617 switch (lang)
1619 case TM_PARSER_ASCIIDOC:
1620 case TM_PARSER_CONF:
1621 case TM_PARSER_LATEX:
1622 case TM_PARSER_MARKDOWN:
1623 case TM_PARSER_REST:
1624 case TM_PARSER_TXT2TAGS:
1625 return " > ";
1627 default:
1628 return tm_parser_scope_separator(lang);
1633 gboolean tm_parser_has_full_scope(TMParserType lang)
1635 switch (lang)
1637 /* These parsers include full hierarchy in the tag scope, separated by tm_parser_scope_separator() */
1638 case TM_PARSER_ACTIONSCRIPT:
1639 case TM_PARSER_C:
1640 case TM_PARSER_CPP:
1641 case TM_PARSER_CUDA:
1642 case TM_PARSER_CSHARP:
1643 case TM_PARSER_COBOL:
1644 case TM_PARSER_D:
1645 case TM_PARSER_GDSCRIPT:
1646 case TM_PARSER_GO:
1647 case TM_PARSER_JAVA:
1648 case TM_PARSER_JAVASCRIPT:
1649 case TM_PARSER_JSON:
1650 case TM_PARSER_LATEX:
1651 case TM_PARSER_LUA:
1652 case TM_PARSER_MARKDOWN:
1653 case TM_PARSER_PHP:
1654 case TM_PARSER_POWERSHELL:
1655 case TM_PARSER_PYTHON:
1656 case TM_PARSER_R:
1657 case TM_PARSER_RUBY:
1658 case TM_PARSER_RUST:
1659 case TM_PARSER_SQL:
1660 case TM_PARSER_TCL:
1661 case TM_PARSER_TCLOO:
1662 case TM_PARSER_TXT2TAGS:
1663 case TM_PARSER_TYPESCRIPT:
1664 case TM_PARSER_VALA:
1665 case TM_PARSER_VHDL:
1666 case TM_PARSER_VERILOG:
1667 case TM_PARSER_ZEPHIR:
1668 return TRUE;
1670 /* These make use of the scope, but don't include nested hierarchy
1671 * (either as a parser limitation or a language semantic) */
1672 case TM_PARSER_ADA:
1673 case TM_PARSER_ASCIIDOC:
1674 case TM_PARSER_CLOJURE:
1675 case TM_PARSER_CONF:
1676 case TM_PARSER_ERLANG:
1677 case TM_PARSER_FORTRAN:
1678 case TM_PARSER_OBJC:
1679 case TM_PARSER_REST:
1680 /* Other parsers don't use scope at all (or should be somewhere above) */
1681 default:
1682 return FALSE;
1687 gboolean tm_parser_langs_compatible(TMParserType lang, TMParserType other)
1689 if (lang == TM_PARSER_NONE || other == TM_PARSER_NONE)
1690 return FALSE;
1691 if (lang == other)
1692 return TRUE;
1693 /* Accept CPP tags for C lang and vice versa */
1694 else if (lang == TM_PARSER_C && other == TM_PARSER_CPP)
1695 return TRUE;
1696 else if (lang == TM_PARSER_CPP && other == TM_PARSER_C)
1697 return TRUE;
1699 return FALSE;