[antlr-interest] Modifying token text - is it possible?

Steve Bennett stevagewp at gmail.com
Tue Nov 20 04:30:06 PST 2007


According to http://www.cs.usfca.edu/~parrt/course/652/lectures/antlr-lexers.html
it ought to be possible to modify a token's text two ways:

FOO: '<'! ... ; // '<' does not become part of the token

FOO: '<' ...{ $setText (...); // $setText manually overrides the matched text.

Neither of these constructs seems to work for me...were they perhaps
taken out or changed to something else? I see there is a setText
method on Lexer, but can't make it work: does FOO: x=TOKEN {$x...};
notation actually work?

Steve


More information about the antlr-interest mailing list