Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Colomban Wendling lists.ban@herbesfolles.org Date: Fri, 17 Feb 2023 20:27:40 UTC Commit: 597b101c88bd45dffbcb36831cf0279780d5cc9e https://github.com/geany/geany/commit/597b101c88bd45dffbcb36831cf0279780d5cc...
Log Message: ----------- Add batch file ctags parser
Modified Paths: -------------- ctags/Makefile.am ctags/parsers/dosbatch.c meson.build src/filetypes.c src/tagmanager/tm_parser.c src/tagmanager/tm_parser.h src/tagmanager/tm_parsers.h tests/ctags/Makefile.am tests/ctags/simple.bat tests/ctags/simple.bat.tags tests/meson.build
Modified: ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -58,6 +58,7 @@ parsers = \ parsers/css.c \ parsers/diff.c \ parsers/geany_docbook.c \ + parsers/dosbatch.c \ parsers/erlang.c \ parsers/flex.c \ parsers/fortran.c \
Modified: ctags/parsers/dosbatch.c 44 lines changed, 44 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2009, David Fishburn +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +* +* This module contains functions for generating tags for DOS Batch language files. +*/ + +/* +* INCLUDE FILES +*/ +#include "general.h" /* must always come first */ + +#include <string.h> +#include "parse.h" +#include "routines.h" +#include "selectors.h" + +static tagRegexTable dosTagRegexTable [] = { + {"^:([A-Za-z_0-9]+)", "\1", + "l,label,labels", NULL}, + {"set[ \t]+([A-Za-z_0-9]+)[ \t]*=", "\1", + "v,variable,variables", NULL}, +}; + +/* +* FUNCTION DEFINITIONS +*/ + +extern parserDefinition* DosBatchParser (void) +{ + static const char *const extensions [] = { "bat", "cmd", NULL }; + parserDefinition* const def = parserNew ("DosBatch"); + static selectLanguage selectors[] = { selectByRexxCommentAndDosbatchLabelPrefix, + NULL }; + + def->extensions = extensions; + def->tagRegexTable = dosTagRegexTable; + def->tagRegexCount = ARRAY_SIZE (dosTagRegexTable); + def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; + def->selectLanguage = selectors; + return def; +}
Modified: meson.build 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -632,6 +632,7 @@ ctags = static_library('ctags', 'ctags/parsers/cxx/cxx_token_chain.h', 'ctags/parsers/cxx/cxx_token.h', 'ctags/parsers/diff.c', + 'ctags/parsers/dosbatch.c', 'ctags/parsers/erlang.c', 'ctags/parsers/flex.c', 'ctags/parsers/fortran.c',
Modified: src/filetypes.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -180,7 +180,7 @@ static void init_builtin_filetypes(void) FT_INIT( FORTH, NONE, "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, NONE, "Batch", NULL, SCRIPT, SCRIPT ); + FT_INIT( BATCH, BATCH, "Batch", NULL, SCRIPT, SCRIPT ); FT_INIT( POWERSHELL, POWERSHELL, "PowerShell", NULL, SOURCE_FILE, SCRIPT ); FT_INIT( RUST, RUST, "Rust", NULL, SOURCE_FILE, COMPILED ); FT_INIT( COFFEESCRIPT, NONE, "CoffeeScript", NULL, SOURCE_FILE, SCRIPT );
Modified: src/tagmanager/tm_parser.c 10 lines changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -1067,6 +1067,15 @@ static TMParserMapGroup group_ADA[] = { {_("Other"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_enumerator_t}, };
+static TMParserMapEntry map_BATCH[] = { + {'l', tm_tag_other_t}, // label + {'v', tm_tag_variable_t}, // variable +}; +static TMParserMapGroup group_BATCH[] = { + {_("Labels"), TM_ICON_OTHER, tm_tag_other_t}, + {_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, +}; + typedef struct { TMParserMapEntry *entries; @@ -1137,6 +1146,7 @@ static TMParserMap parser_map[] = { MAP_ENTRY(CLOJURE), MAP_ENTRY(LISP), MAP_ENTRY(TYPESCRIPT), + MAP_ENTRY(BATCH), }; /* 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 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -117,6 +117,7 @@ enum TM_PARSER_CLOJURE, TM_PARSER_LISP, TM_PARSER_TYPESCRIPT, + TM_PARSER_BATCH, TM_PARSER_COUNT };
Modified: src/tagmanager/tm_parsers.h 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -71,6 +71,7 @@ TclOOParser, \ ClojureParser, \ LispParser, \ - TypeScriptParser + TypeScriptParser, \ + DosBatchParser
#endif
Modified: tests/ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -295,6 +295,7 @@ test_sources = \ simple.abc \ simple.asciidoc \ simple.bas \ + simple.bat \ simple.clj \ simple.conf \ simple.d \
Modified: tests/ctags/simple.bat 30 lines changed, 30 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,30 @@ +REM USAGE: geany-run-helper DIRECTORY AUTOCLOSE COMMAND... + +REM unnecessary, but we get the directory +cd %1 +shift +REM save autoclose option and remove it +set autoclose=%1 +shift + +REM spawn the child +REM it's tricky because shift doesn't affect %*, so hack it out +REM https://en.wikibooks.org/wiki/Windows_Batch_Scripting#Command-line_arguments +set SPAWN= +:argloop +if -%1-==-- goto argloop_end + set SPAWN=%SPAWN% %1 + shift +goto argloop +:argloop_end +%SPAWN% + +REM show the result +echo: +echo: +echo:------------------ +echo:(program exited with code: %ERRORLEVEL%) +echo: + +REM and if wanted, wait on the user +if not %autoclose%==1 pause
Modified: tests/ctags/simple.bat.tags 8 lines changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,8 @@ +SPAWN�16384�0 +variable: SPAWN +argloop�524288�0 +other: argloop +argloop_end�524288�0 +other: argloop_end +autoclose�16384�0 +variable: autoclose
Modified: tests/meson.build 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -292,6 +292,7 @@ ctags_tests = files([ 'ctags/simple.abc.tags', 'ctags/simple.asciidoc.tags', 'ctags/simple.bas.tags', + 'ctags/simple.bat.tags', 'ctags/simple.clj.tags', 'ctags/simple.conf.tags', 'ctags/simple.d.tags',
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).