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"
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)
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
48 } TMSubparserMapEntry
;
57 static GHashTable
*subparser_map
= NULL
;
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_undef_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
[] = {
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
},
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
[] = {
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
},
1072 TMParserMapEntry
*entries
;
1074 TMParserMapGroup
*groups
;
1078 #define MAP_ENTRY(lang) [TM_PARSER_##lang] = {map_##lang, G_N_ELEMENTS(map_##lang), group_##lang, G_N_ELEMENTS(group_##lang)}
1080 /* keep in sync with TM_PARSER_* definitions in the header */
1081 static TMParserMap parser_map
[] = {
1085 MAP_ENTRY(MAKEFILE
),
1103 MAP_ENTRY(GDSCRIPT
),
1107 MAP_ENTRY(JAVASCRIPT
),
1110 MAP_ENTRY(FREEBASIC
),
1118 MAP_ENTRY(ACTIONSCRIPT
),
1120 MAP_ENTRY(MARKDOWN
),
1121 MAP_ENTRY(TXT2TAGS
),
1127 MAP_ENTRY(ASCIIDOC
),
1133 MAP_ENTRY(POWERSHELL
),
1135 MAP_ENTRY(CPREPROCESSOR
),
1139 MAP_ENTRY(TYPESCRIPT
),
1141 /* make sure the parser map is consistent and complete */
1142 G_STATIC_ASSERT(G_N_ELEMENTS(parser_map
) == TM_PARSER_COUNT
);
1145 TMTagType
tm_parser_get_tag_type(gchar kind
, TMParserType lang
)
1147 TMParserMap
*map
= &parser_map
[lang
];
1150 for (i
= 0; i
< map
->size
; i
++)
1152 TMParserMapEntry
*entry
= &map
->entries
[i
];
1154 if (entry
->kind
== kind
)
1157 return tm_tag_undef_t
;
1161 gchar
tm_parser_get_tag_kind(TMTagType type
, TMParserType lang
)
1163 TMParserMap
*map
= &parser_map
[lang
];
1166 for (i
= 0; i
< map
->size
; i
++)
1168 TMParserMapEntry
*entry
= &map
->entries
[i
];
1170 if (entry
->type
== type
)
1177 gint
tm_parser_get_sidebar_group(TMParserType lang
, TMTagType type
)
1182 if (lang
>= TM_PARSER_COUNT
)
1185 map
= &parser_map
[lang
];
1186 for (i
= 0; i
< map
->group_num
; i
++)
1188 if (map
->groups
[i
].types
& type
)
1195 const gchar
*tm_parser_get_sidebar_info(TMParserType lang
, gint group
, guint
*icon
)
1198 TMParserMapGroup
*grp
;
1200 if (lang
>= TM_PARSER_COUNT
)
1203 map
= &parser_map
[lang
];
1204 if (group
>= (gint
)map
->group_num
)
1207 grp
= &map
->groups
[group
];
1209 #ifdef GETTEXT_PACKAGE
1210 return g_dgettext(GETTEXT_PACKAGE
, grp
->name
);
1217 static void add_subparser(TMParserType lang
, TMParserType sublang
, TMSubparserMapEntry
*map
, guint map_size
)
1221 GHashTable
*lang_map
= g_hash_table_lookup(subparser_map
, GINT_TO_POINTER(lang
));
1225 lang_map
= g_hash_table_new(g_direct_hash
, g_direct_equal
);
1226 g_hash_table_insert(subparser_map
, GINT_TO_POINTER(lang
), lang_map
);
1229 mapping
= g_ptr_array_new();
1230 for (i
= 0; i
< map_size
; i
++)
1231 g_ptr_array_add(mapping
, &map
[i
]);
1233 g_hash_table_insert(lang_map
, GINT_TO_POINTER(sublang
), mapping
);
1237 #define SUBPARSER_MAP_ENTRY(lang, sublang, map) add_subparser(TM_PARSER_##lang, TM_PARSER_##sublang, map, G_N_ELEMENTS(map))
1239 static void init_subparser_map(void)
1241 SUBPARSER_MAP_ENTRY(HTML
, JAVASCRIPT
, subparser_HTML_javascript_map
);
1242 SUBPARSER_MAP_ENTRY(TCLOO
, TCL
, subparser_TCLOO_TCL_map
);
1246 TMTagType
tm_parser_get_subparser_type(TMParserType lang
, TMParserType sublang
, TMTagType type
)
1249 GHashTable
*lang_map
;
1254 subparser_map
= g_hash_table_new(g_direct_hash
, g_direct_equal
);
1255 init_subparser_map();
1258 lang_map
= g_hash_table_lookup(subparser_map
, GINT_TO_POINTER(lang
));
1260 return tm_tag_undef_t
;
1262 mapping
= g_hash_table_lookup(lang_map
, GINT_TO_POINTER(sublang
));
1264 return tm_tag_undef_t
;
1266 for (i
= 0; i
< mapping
->len
; i
++)
1268 TMSubparserMapEntry
*entry
= mapping
->pdata
[i
];
1269 if (entry
->orig_type
== type
)
1270 return entry
->new_type
;
1273 return tm_tag_undef_t
;
1277 void tm_parser_verify_type_mappings(void)
1281 if (TM_PARSER_COUNT
> tm_ctags_get_lang_count())
1282 g_error("More parsers defined in Geany than in ctags");
1284 for (lang
= 0; lang
< TM_PARSER_COUNT
; lang
++)
1286 const gchar
*kinds
= tm_ctags_get_lang_kinds(lang
);
1287 TMParserMap
*map
= &parser_map
[lang
];
1288 gchar presence_map
[256];
1289 TMTagType lang_types
= 0;
1290 TMTagType group_types
= 0;
1293 if (! map
->entries
|| map
->size
< 1)
1294 g_error("No tag types in TM for %s, is the language listed in parser_map?",
1295 tm_ctags_get_lang_name(lang
));
1297 if (map
->size
!= strlen(kinds
))
1298 g_error("Different number of tag types in TM (%d) and ctags (%d) for %s",
1299 map
->size
, (int)strlen(kinds
), tm_ctags_get_lang_name(lang
));
1301 memset(presence_map
, 0, sizeof(presence_map
));
1302 for (i
= 0; i
< map
->size
; i
++)
1304 gboolean ctags_found
= FALSE
;
1305 gboolean tm_found
= FALSE
;
1308 for (j
= 0; j
< map
->size
; j
++)
1310 /* check that for every type in TM there's a type in ctags */
1311 if (map
->entries
[i
].kind
== kinds
[j
])
1313 /* check that for every type in ctags there's a type in TM */
1314 if (map
->entries
[j
].kind
== kinds
[i
])
1316 if (ctags_found
&& tm_found
)
1320 g_error("Tag type '%c' found in TM but not in ctags for %s",
1321 map
->entries
[i
].kind
, tm_ctags_get_lang_name(lang
));
1323 g_error("Tag type '%c' found in ctags but not in TM for %s",
1324 kinds
[i
], tm_ctags_get_lang_name(lang
));
1326 presence_map
[(unsigned char) map
->entries
[i
].kind
]++;
1327 lang_types
|= map
->entries
[i
].type
;
1330 for (i
= 0; i
< sizeof(presence_map
); i
++)
1332 if (presence_map
[i
] > 1)
1333 g_error("Duplicate tag type '%c' found for %s",
1334 (gchar
)i
, tm_ctags_get_lang_name(lang
));
1337 for (i
= 0; i
< map
->group_num
; i
++)
1338 group_types
|= map
->groups
[i
].types
;
1340 if ((group_types
& lang_types
) != lang_types
)
1341 g_warning("Not all tag types mapped to symbol tree groups for %s",
1342 tm_ctags_get_lang_name(lang
));
1347 /* When the suffix of 'str' is an operator that should trigger scope
1348 * autocompletion, this function should return the length of the operator,
1349 * zero otherwise. */
1350 gint
tm_parser_scope_autocomplete_suffix(TMParserType lang
, const gchar
*str
)
1352 const gchar
*sep
= tm_parser_scope_separator(lang
);
1354 if (g_str_has_suffix(str
, sep
))
1361 if (g_str_has_suffix(str
, "."))
1363 else if (g_str_has_suffix(str
, "->"))
1365 else if (lang
== TM_PARSER_CPP
&& g_str_has_suffix(str
, "->*"))
1374 /* Get the name of constructor method. Arguments of this method will be used
1375 * for calltips when creating an object using the class name
1376 * (e.g. after the opening brace in 'c = MyClass()' in Python) */
1377 const gchar
*tm_parser_get_constructor_method(TMParserType lang
)
1383 case TM_PARSER_PYTHON
:
1391 /* determine anonymous tags from tag names only when corresponding
1392 * ctags information is not available */
1393 gboolean
tm_parser_is_anon_name(TMParserType lang
, gchar
*name
)
1398 if (sscanf(name
, "__anon%u%c", &i
, &dummy
) == 1) /* uctags tags files */
1400 else if (lang
== TM_PARSER_C
|| lang
== TM_PARSER_CPP
) /* legacy Geany tags files */
1401 return sscanf(name
, "anon_%*[a-z]_%u%c", &i
, &dummy
) == 1;
1402 else if (lang
== TM_PARSER_FORTRAN
) /* legacy Geany tags files */
1404 return sscanf(name
, "Structure#%u%c", &i
, &dummy
) == 1 ||
1405 sscanf(name
, "Interface#%u%c", &i
, &dummy
) == 1 ||
1406 sscanf(name
, "Enum#%u%c", &i
, &dummy
) == 1;
1412 static gchar
*replace_string_if_present(gchar
*haystack
, gchar
*needle
, gchar
*subst
)
1414 if (strstr(haystack
, needle
))
1416 gchar
**split
= g_strsplit(haystack
, needle
, -1);
1417 gchar
*ret
= g_strjoinv(subst
, split
);
1425 /* return updated scope or original scope if no change needed */
1426 gchar
*tm_parser_update_scope(TMParserType lang
, gchar
*scope
)
1431 case TM_PARSER_ZEPHIR
:
1432 /* PHP parser uses two different scope separators but this would
1433 * complicate things in Geany so make sure there's just one type */
1434 return replace_string_if_present(scope
, "\\", "::");
1436 case TM_PARSER_TCLOO
:
1437 /* The TCL(OO) parser returns scope prefixed with :: which we don't
1439 if (g_str_has_prefix(scope
, "::"))
1440 return g_strdup(scope
+ 2);
1447 /* whether or not to enable ctags roles for the given language and kind */
1448 gboolean
tm_parser_enable_role(TMParserType lang
, gchar kind
)
1452 case TM_PARSER_GDSCRIPT
:
1453 return kind
== 'c' ? FALSE
: TRUE
;
1455 /* 'p' is used both for package definition tags and imported package
1456 * tags and we can't tell which is which just by kind. By disabling
1457 * roles for this kind, we only get package definition tags. */
1458 return kind
== 'p' ? FALSE
: TRUE
;
1464 /* whether or not to enable ctags kinds for the given language */
1465 gboolean
tm_parser_enable_kind(TMParserType lang
, gchar kind
)
1470 if (lang
>= TM_PARSER_COUNT
)
1471 /* Fatal error but tm_parser_verify_type_mappings() will provide
1472 * better message later */
1475 map
= &parser_map
[lang
];
1476 for (i
= 0; i
< map
->size
; i
++)
1478 if (map
->entries
[i
].kind
== kind
)
1479 return map
->entries
[i
].type
!= tm_tag_undef_t
;
1485 gchar
*tm_parser_format_variable(TMParserType lang
, const gchar
*name
, const gchar
*type
)
1493 return g_strconcat(name
, " ", type
, NULL
);
1494 case TM_PARSER_PASCAL
:
1495 case TM_PARSER_PYTHON
:
1496 return g_strconcat(name
, ": ", type
, NULL
);
1498 return g_strconcat(type
, " ", name
, NULL
);
1503 gchar
*tm_parser_format_function(TMParserType lang
, const gchar
*fname
, const gchar
*args
,
1504 const gchar
*retval
, const gchar
*scope
)
1508 if (!args
) /* not a function */
1511 str
= g_string_new(NULL
);
1515 g_string_append(str
, scope
);
1516 g_string_append(str
, tm_parser_scope_separator_printable(lang
));
1518 g_string_append(str
, fname
);
1519 g_string_append_c(str
, ' ');
1520 g_string_append(str
, args
);
1526 case TM_PARSER_GDSCRIPT
:
1528 case TM_PARSER_PASCAL
:
1529 case TM_PARSER_PYTHON
:
1531 /* retval after function */
1535 case TM_PARSER_PASCAL
:
1538 case TM_PARSER_GDSCRIPT
:
1539 case TM_PARSER_PYTHON
:
1546 g_string_append(str
, sep
);
1547 g_string_append(str
, retval
);
1551 /* retval before function */
1552 g_string_prepend_c(str
, ' ');
1553 g_string_prepend(str
, retval
);
1558 return g_string_free(str
, FALSE
);
1562 const gchar
*tm_parser_scope_separator(TMParserType lang
)
1566 case TM_PARSER_C
: /* for C++ .h headers or C structs */
1568 case TM_PARSER_CUDA
:
1570 case TM_PARSER_POWERSHELL
:
1571 case TM_PARSER_RUST
:
1573 case TM_PARSER_TCLOO
:
1574 case TM_PARSER_ZEPHIR
:
1577 case TM_PARSER_LATEX
:
1578 case TM_PARSER_MARKDOWN
:
1579 case TM_PARSER_TXT2TAGS
:
1582 /* these parsers don't report nested scopes but default "." for scope separator
1583 * might appear in the text so use something more improbable */
1584 case TM_PARSER_ASCIIDOC
:
1585 case TM_PARSER_CONF
:
1586 case TM_PARSER_REST
:
1595 const gchar
*tm_parser_scope_separator_printable(TMParserType lang
)
1599 case TM_PARSER_ASCIIDOC
:
1600 case TM_PARSER_CONF
:
1601 case TM_PARSER_LATEX
:
1602 case TM_PARSER_MARKDOWN
:
1603 case TM_PARSER_REST
:
1604 case TM_PARSER_TXT2TAGS
:
1608 return tm_parser_scope_separator(lang
);
1613 gboolean
tm_parser_has_full_scope(TMParserType lang
)
1617 /* These parsers include full hierarchy in the tag scope, separated by tm_parser_scope_separator() */
1618 case TM_PARSER_ACTIONSCRIPT
:
1621 case TM_PARSER_CUDA
:
1622 case TM_PARSER_CSHARP
:
1623 case TM_PARSER_COBOL
:
1625 case TM_PARSER_GDSCRIPT
:
1627 case TM_PARSER_JAVA
:
1628 case TM_PARSER_JAVASCRIPT
:
1629 case TM_PARSER_JSON
:
1630 case TM_PARSER_LATEX
:
1632 case TM_PARSER_MARKDOWN
:
1634 case TM_PARSER_POWERSHELL
:
1635 case TM_PARSER_PYTHON
:
1637 case TM_PARSER_RUBY
:
1638 case TM_PARSER_RUST
:
1641 case TM_PARSER_TCLOO
:
1642 case TM_PARSER_TXT2TAGS
:
1643 case TM_PARSER_TYPESCRIPT
:
1644 case TM_PARSER_VALA
:
1645 case TM_PARSER_VHDL
:
1646 case TM_PARSER_VERILOG
:
1647 case TM_PARSER_ZEPHIR
:
1650 /* These make use of the scope, but don't include nested hierarchy
1651 * (either as a parser limitation or a language semantic) */
1653 case TM_PARSER_ASCIIDOC
:
1654 case TM_PARSER_CLOJURE
:
1655 case TM_PARSER_CONF
:
1656 case TM_PARSER_ERLANG
:
1657 case TM_PARSER_FORTRAN
:
1658 case TM_PARSER_OBJC
:
1659 case TM_PARSER_REST
:
1660 /* Other parsers don't use scope at all (or should be somewhere above) */
1667 gboolean
tm_parser_langs_compatible(TMParserType lang
, TMParserType other
)
1669 if (lang
== TM_PARSER_NONE
|| other
== TM_PARSER_NONE
)
1673 /* Accept CPP tags for C lang and vice versa */
1674 else if (lang
== TM_PARSER_C
&& other
== TM_PARSER_CPP
)
1676 else if (lang
== TM_PARSER_CPP
&& other
== TM_PARSER_C
)