[ jEdit-devel ] Questions about the edit modes XML syntax
I've made many improvements to the batch.xml edit mode, that I'd like to contribute eventually.
But I'm still blocked by a few problems, that I'd like to resolve first:
1) The Windows batch language uses the ^ (caret) as an escape character.
By analogy with several other languages which use the \ character for that purpose, and where the corresponding edit modes use ESCAPE="\" properties to handle that, I tried adding ESCAPE="^" properties in batch.xml rules.
But I've been unable to make it work. Basically, my rules always fire, whether there's a ^ or not in front of special operators or literals, and whether I insert ESCAPE="^" properties or not in the rules handling them.
Any suggestion on what I might have done (or understood) wrong?
2) I've got an issue with (spans) that begin and end on the same line.
if %VARIABLE%==1 (echo This is TRUE) else (echo This is FALSE)
In this case, the EOL_SPAN_REGEXP rule for the first echo command eats up the remainder of the line, and so the last 3 parenthesis are not coloured like the first one.
This is all the more surprising that the edit mode perfectly detects all parenthesis, and auto-indents blocks correctly if I press Enter at the beginning and end of each (span):
(And in this cases, the parenthesis are all coloured correctly.)
if %VARIABLE%==1 (
echo This is TRUE
) else (
echo This is FALSE
3) Is there a way to delegate the first token of a line to one rule set, and the remainder of the line to another?
This would be useful to prevent rules from firing if a keyword coincidentally appears as an argument of another command.
echo For example:
+--- This "For" triggers my rule for the "for" keyword, which I do not want to fire here.
As far as I can tell, all the documented rule types allow giving a fixed type to the token(s) they catch, and delegating the rest to another set of rules.
Basically, I'd like to consider only the first token for analysis as a keyword or function, and anything that follows should be only be considered as operators or undefined (null).
Actually this would be useful for any shell language, not just batch: They all allow inserting variables anywhere, including in the command name.
4) Related to #3: It would be very convenient to have AT_COMMAND_START and AT_COMMAND_END properties, that would be true when a character is at the beginning or end of a span OR a line.
The property AT_LINE_START is unusable for the purpose of detecting the first keyword in a command line.
For example I tried using it to detect commands with special syntaxes (if, for, rem, echo, ...) that needed to be handled separately.
But this broke when multiple commands are chained on the same line, as shown in the item #2 example above.