[Feature/Help Request] Add more items to function list for Windows batch files
-
Hi,
currently the function list shows only labels (:name) for batch files. I additionally need these items:- call
- start
- goto
My request is to have these items added to functionlist.xml.
Can someone help my with the code to do so myself in the meantime?
Thank you very much. -
I strongly advise against showing more then just functions/sub-routines (i.e. labels in batch files) in the FunctionList tree but considering the following …
CALL [drive:][path]filename [batch-parameters] CALL :label arguments START ["title"] [start-arguments] [command/program] [parameters] GOTO [:]label
… what parts of the commands would you like to show up in the tree?
-
Hello bege10,
To fully distinguish the different GOTO, CALL and START commands, of your batch file, I suppose that you need all the contents of the line, starting with these commands :-)
If so, here is, below, a batch parser, which should work nice !!
-
Open your active functionList.xml file
-
Change the present batch_label id parser contents by the parser, below :
<parser id=“batch_label” displayName=“BAT Label” commentExpr=“^[\t ](::|REM).?$”>
<function
mainExpr=“^[\t ]*\K.+?$”
displayMode=“$functionName”>
<functionName>
<nameExpr expr=“(call |goto |start |(?<=:)).+?$”/>
</functionName>
</function>
</parser>
Notes :
-
The commentExpr string is, either, the word
REM
or the symbol::
, preceded by possible leading space/tabulation characters and followed by any range, even null, or characters -
Then, the
mainExpr
string, from which the different entities, to display in the FunctionList window, will be extracted, is any, non-null, range of characters, which follows possible leading space/tabulation characters ( and different from comment ranges ! ) -
Finally, the
expr
string is, either :- The word call, goto or start, followed by a space and any non null range of characters
- Any non null range of characters, following a colon (
:
)
IMPORTANT :
The functionList regex engine does NOT act as the Notepad++ one. By default, it considers that the dot meta-character (
.
) match, absolutely, any character ( standard or EOL ones )But, as the Notepad++ regex engine does, it considers that the
^
and$
assertions stand for the beginning and the end of any lineSo, when you want to match, from any location, all the remaining characters of a line, TWO syntaxes are possible :
.+?$
which matches any non-null range of any character, ( standard or EOL ones ), till the nearest EOL location, due to the lazy quantifier+?
OR
(?-s).+
which matches any non-null range of standard characters only, due to the in-line modifier(?-s)
Of course, if the range of characters may be a zero-length string, prefer the syntax
.*?$
OR(?-s).*
Best Regards,
guy038
-