[antlr-interest] Another update to Honey Badger
Terence Parr
parrt at cs.usfca.edu
Sat Jan 21 15:42:59 PST 2012
Hi, I have made an update to Honey Badger to allow special lexer commands to do the usual things without resorting to actions in the target language. This renders lexers almost always language neutral. Without actions in the parser, because of the parse trees, we should be very language neutral for honey badger grammars.
In the lexer, you now have the choice of these commands:
skip
more
popMode
mode(x)
pushMode(x)
type(x)
channel(x)
You can combine them with a comma and you can only have these commands at the end of an outer alternative:
WS : (' '|'\n')+ -> skip ;
WS : (' '|'\n')+ -> channel(HIDDEN) ;
CURLY : '{' -> more, pushMode(BLOCKS) ;
You can check it out here on the updated example page:
http://www.antlr.org/wiki/display/ANTLR4/Examples
http://www.antlr.org/depot/antlr4/main/CHANGES.txt
Download here:
http://antlr.org/download/antlr-4.0ea-complete.jar
I will update the examples soon.
Note that the old-style actions still work; these new commands simply translate to the raw actions. Obviously, if you need to do some logic before sending the token type, you will need to use an action in the target language.
Enjoy,
Ter
More information about the antlr-interest
mailing list