Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 03 Nov 2024 16:53:52 UTC Commit: dcd2f3e6201c5a51252bedb005df3f3c5b285bf8 https://github.com/geany/geany/commit/dcd2f3e6201c5a51252bedb005df3f3c5b285b...
Log Message: ----------- Use Forth and Meson optlib-based ctags parsers
This patch also updates update-ctags.py to update parsers in the optlib directory.
Modified Paths: -------------- ctags/Makefile.am ctags/optlib/forth.c ctags/optlib/meson.c data/filedefs/filetypes.Meson.conf meson.build scripts/update-ctags.py src/filetypes.c src/tagmanager/tm_parser.c src/tagmanager/tm_parser.h src/tagmanager/tm_parsers.h
Modified: ctags/Makefile.am 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -11,6 +11,8 @@ AM_CFLAGS = \ noinst_LTLIBRARIES = libctags.la
parsers = \ + optlib/forth.c \ + optlib/meson.c \ parsers/cxx/cxx.c \ parsers/cxx/cxx_debug.c \ parsers/cxx/cxx_debug.h \
Modified: ctags/optlib/forth.c 76 lines changed, 76 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,76 @@ +/* + * Generated by ./misc/optlib2c from optlib/forth.ctags, Don't edit this manually. + */ +#include "general.h" +#include "parse.h" +#include "routines.h" +#include "field.h" +#include "xtag.h" +#include "selectors.h" + + +static void initializeForthParser (const langType language CTAGS_ATTR_UNUSED) +{ +} + +extern parserDefinition* ForthParser (void) +{ + static const char *const extensions [] = { + "fth", + "forth", + "fs", + "4th", + "f", + NULL + }; + + static const char *const aliases [] = { + NULL + }; + + static const char *const patterns [] = { + NULL + }; + + static kindDefinition ForthKindTable [] = { + { + true, 'w', "word", "words", + }, + { + true, 'v', "variable", "variables", + }, + { + true, 'c', "constant", "constants", + }, + }; + static tagRegexTable ForthTagRegexTable [] = { + {"^[[:space:]]*\\.*", "", + "", "{exclusive}", NULL, false}, + {"^:[[:space:]]+([^[:space:]]+)", "\1", + "w", "{exclusive}", NULL, false}, + {"^variable[[:space:]]+([^[:space:]]+)", "\1", + "v", "{exclusive}{icase}", NULL, false}, + {"^[[:alnum:]]+[[:space:]]+constant[[:space:]]+([^[:space:]]+)", "\1", + "c", "{exclusive}{icase}", NULL, false}, + }; + + static selectLanguage selectors[] = { selectFortranOrForthByForthMarker, NULL }; + + parserDefinition* const def = parserNew ("Forth"); + + def->versionCurrent= 0; + def->versionAge = 0; + def->enabled = true; + def->extensions = extensions; + def->patterns = patterns; + def->aliases = aliases; + def->selectLanguage= selectors; + def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; + def->kindTable = ForthKindTable; + def->kindCount = ARRAY_SIZE(ForthKindTable); + def->tagRegexTable = ForthTagRegexTable; + def->tagRegexCount = ARRAY_SIZE(ForthTagRegexTable); + def->initialize = initializeForthParser; + + return def; +}
Modified: ctags/optlib/meson.c 261 lines changed, 261 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,261 @@ +/* + * Generated by ./misc/optlib2c from optlib/meson.ctags, Don't edit this manually. + */ +#include "general.h" +#include "parse.h" +#include "routines.h" +#include "field.h" +#include "xtag.h" + + +static void initializeMesonParser (const langType language) +{ + + addLanguageRegexTable (language, "main"); + addLanguageRegexTable (language, "mline_string"); + addLanguageRegexTable (language, "string"); + addLanguageRegexTable (language, "comment"); + addLanguageRegexTable (language, "skipPair"); + addLanguageRegexTable (language, "common"); + addLanguageRegexTable (language, "skipToArgEnd"); + + addLanguageTagMultiTableRegex (language, "main", + "^[ \t\n]+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^#", + "", "", "{tenter=comment}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^'''", + "", "", "{tenter=mline_string}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^'", + "", "", "{tenter=string}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^[[({]", + "", "", "{tenter=skipPair}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^(jar|executable|shared_module|(both_|shared_|static_)?library)[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\3", "B", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^custom_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "c", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^(alias|run)_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\2", "r", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^benchmark[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "b", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^import[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "m", "{tenter=skipToArgEnd}{_role=imported}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^project[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "P", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^subdir[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "S", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^test[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "t", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^([a-zA-Z_][a-zA-Z_0-9]*)[ \t\n]*=([^=]|$)", + "\1", "V", "{_advanceTo=2start}", NULL); + addLanguageTagMultiTableRegex (language, "main", + "^.", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "mline_string", + "^'''", + "", "", "{tleave}", NULL); + addLanguageTagMultiTableRegex (language, "mline_string", + "^[^']+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "mline_string", + "^.", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "string", + "^[^\\']+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "string", + "^\\.", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "string", + "^'", + "", "", "{tleave}", NULL); + addLanguageTagMultiTableRegex (language, "string", + "^.", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "comment", + "^[^\n]+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "comment", + "^\n", + "", "", "{tleave}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^[ \t\n]+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^#", + "", "", "{tenter=comment}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^'''", + "", "", "{tenter=mline_string}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^'", + "", "", "{tenter=string}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^[[({]", + "", "", "{tenter=skipPair}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^(jar|executable|shared_module|(both_|shared_|static_)?library)[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\3", "B", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^custom_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "c", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^(alias|run)_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\2", "r", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^benchmark[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "b", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^import[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "m", "{tenter=skipToArgEnd}{_role=imported}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^[])}]", + "", "", "{tleave}", NULL); + addLanguageTagMultiTableRegex (language, "skipPair", + "^.", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^[ \t\n]+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^#", + "", "", "{tenter=comment}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^'''", + "", "", "{tenter=mline_string}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^'", + "", "", "{tenter=string}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^[[({]", + "", "", "{tenter=skipPair}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^(jar|executable|shared_module|(both_|shared_|static_)?library)[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\3", "B", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^custom_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "c", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^(alias|run)_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\2", "r", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^benchmark[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "b", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "common", + "^import[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "m", "{tenter=skipToArgEnd}{_role=imported}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^[ \t\n]+", + "", "", "", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^#", + "", "", "{tenter=comment}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^'''", + "", "", "{tenter=mline_string}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^'", + "", "", "{tenter=string}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^[[({]", + "", "", "{tenter=skipPair}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^(jar|executable|shared_module|(both_|shared_|static_)?library)[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\3", "B", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^custom_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "c", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^(alias|run)_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\2", "r", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^benchmark[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "b", "{tenter=skipToArgEnd}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^import[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*", + "\1", "m", "{tenter=skipToArgEnd}{_role=imported}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^[])}]", + "", "", "{tleave}", NULL); + addLanguageTagMultiTableRegex (language, "skipToArgEnd", + "^.", + "", "", "", NULL); +} + +extern parserDefinition* MesonParser (void) +{ + static const char *const extensions [] = { + NULL + }; + + static const char *const aliases [] = { + NULL + }; + + static const char *const patterns [] = { + "meson.build", + NULL + }; + + static roleDefinition MesonModuleRoleTable [] = { + { true, "imported", "imported" }, + }; + static kindDefinition MesonKindTable [] = { + { + true, 'P', "project", "projects", + }, + { + true, 'V', "variable", "variables", + }, + { + true, 'S', "subdir", "subdirs", + }, + { + true, 'B', "build", "build targets", + }, + { + true, 'c', "custom", "custom targets", + }, + { + true, 't', "test", "tests", + }, + { + true, 'b', "benchmark", "benchmark targets", + }, + { + true, 'r', "run", "run targets", + }, + { + true, 'm', "module", "modules", + ATTACH_ROLES(MesonModuleRoleTable), + }, + }; + + parserDefinition* const def = parserNew ("Meson"); + + def->versionCurrent= 0; + def->versionAge = 0; + def->enabled = true; + def->extensions = extensions; + def->patterns = patterns; + def->aliases = aliases; + def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; + def->kindTable = MesonKindTable; + def->kindCount = ARRAY_SIZE(MesonKindTable); + def->initialize = initializeMesonParser; + + return def; +}
Modified: data/filedefs/filetypes.Meson.conf 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -8,6 +8,7 @@ identifiers=add_global_arguments add_global_link_arguments add_languages add_pro
[settings] lexer_filetype=Python +tag_parser=Meson extension=build comment_single=# mime_type=text/x-meson
Modified: meson.build 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -596,6 +596,8 @@ ctags = static_library('ctags', 'ctags/main/xtag.c', 'ctags/main/xtag.h', 'ctags/main/xtag_p.h', + 'ctags/optlib/forth.c', + 'ctags/optlib/meson.c', 'ctags/parsers/abaqus.c', 'ctags/parsers/abc.c', 'ctags/parsers/ada.c',
Modified: scripts/update-ctags.py 7 lines changed, 7 insertions(+), 0 deletions(-) =================================================================== @@ -29,6 +29,13 @@ for f in cxx_parser_src_files: shutil.copy(f, dstdir + '/parsers/cxx')
+os.chdir(dstdir + '/optlib') +optlib_parser_dst_files = glob.glob('*.c') +os.chdir(srcdir + '/optlib') +print('Copying optlib parsers... ({} files)'.format(len(optlib_parser_dst_files))) +for f in optlib_parser_dst_files: + shutil.copy(f, dstdir + '/optlib') + print('Copying dsl files...') for f in ['dsl/es.c', 'dsl/es.h', 'dsl/optscript.c', 'dsl/optscript.h']: shutil.copy(srcdir + '/' + f, dstdir + '/' + f)
Modified: src/filetypes.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -177,7 +177,7 @@ static void init_builtin_filetypes(void) FT_INIT( CMAKE, NONE, "CMake", NULL, SOURCE_FILE, SCRIPT ); FT_INIT( NSIS, NSIS, "NSIS", NULL, SOURCE_FILE, SCRIPT ); FT_INIT( ADA, ADA, "Ada", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( FORTH, NONE, "Forth", NULL, SOURCE_FILE, SCRIPT ); + FT_INIT( FORTH, FORTH, "Forth", NULL, SOURCE_FILE, SCRIPT ); FT_INIT( ASCIIDOC, ASCIIDOC, "Asciidoc", NULL, SOURCE_FILE, MARKUP ); FT_INIT( ABAQUS, ABAQUS, "Abaqus", NULL, SOURCE_FILE, SCRIPT ); FT_INIT( BATCH, BATCH, "Batch", NULL, SCRIPT, SCRIPT );
Modified: src/tagmanager/tm_parser.c 36 lines changed, 36 insertions(+), 0 deletions(-) =================================================================== @@ -1169,6 +1169,40 @@ static TMParserMapGroup group_LDSCRIPT[] = { {"unused", TM_ICON_NONE, tm_tag_undef_t}, };
+static TMParserMapEntry map_FORTH[] = { + {'w', tm_tag_function_t}, // word + {'v', tm_tag_variable_t}, // variable + {'c', tm_tag_macro_t}, // constant +}; +static TMParserMapGroup group_FORTH[] = { + {N_("Words"), TM_ICON_METHOD, tm_tag_function_t}, + {N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, + {N_("Constants"), TM_ICON_MACRO, tm_tag_macro_t}, +}; + +static TMParserMapEntry map_MESON[] = { + {'P', tm_tag_namespace_t}, // project + {'V', tm_tag_local_var_t}, // variable + {'S', tm_tag_macro_t}, // subdir + {'B', tm_tag_other_t}, // build + {'c', tm_tag_enumerator_t}, // custom + {'t', tm_tag_field_t}, // test + {'b', tm_tag_function_t}, // benchmark + {'r', tm_tag_member_t}, // run + {'m', tm_tag_package_t}, // module +}; +static TMParserMapGroup group_MESON[] = { + {N_("Projects"), TM_ICON_CLASS, tm_tag_namespace_t}, + {N_("Modules"), TM_ICON_NAMESPACE, tm_tag_package_t}, + {N_("Variables"), TM_ICON_NONE, tm_tag_local_var_t}, + {N_("Subdirs"), TM_ICON_OTHER, tm_tag_macro_t}, + {N_("Build Targets"), TM_ICON_METHOD, tm_tag_other_t}, + {N_("Custom Targets"), TM_ICON_METHOD, tm_tag_enumerator_t}, + {N_("Benchmark Targets"), TM_ICON_METHOD, tm_tag_function_t}, + {N_("Run Targets"), TM_ICON_METHOD, tm_tag_member_t}, + {N_("Tests"), TM_ICON_NONE, tm_tag_field_t}, +}; + typedef struct { TMParserMapEntry *entries; @@ -1244,6 +1278,8 @@ static TMParserMap parser_map[] = { MAP_ENTRY(RAKU), MAP_ENTRY(OCAML), MAP_ENTRY(LDSCRIPT), + MAP_ENTRY(FORTH), + MAP_ENTRY(MESON), }; /* make sure the parser map is consistent and complete */ G_STATIC_ASSERT(G_N_ELEMENTS(parser_map) == TM_PARSER_COUNT);
Modified: src/tagmanager/tm_parser.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -142,6 +142,8 @@ enum TM_PARSER_RAKU, TM_PARSER_OCAML, TM_PARSER_LDSCRIPT, + TM_PARSER_FORTH, + TM_PARSER_MESON, TM_PARSER_COUNT };
Modified: src/tagmanager/tm_parsers.h 4 lines changed, 3 insertions(+), 1 deletions(-) =================================================================== @@ -76,6 +76,8 @@ AutoItParser, \ Perl6Parser, \ OcamlParser, \ - LdScriptParser + LdScriptParser, \ + ForthParser, \ + MesonParser
#endif
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).