[antlr-interest] How do I set token type in ANTLR 3.1b1?
Gavin Lambert
antlr at mirality.co.nz
Mon Jun 9 02:18:59 PDT 2008
At 21:02 9/06/2008, Vaclav Barta wrote:
>Note the use of text in (for example)
>MacroScopeLexer.mAsciiStringLiteral() - action { text = ""; } is
>translated into
>
>if ( state.backtracking == 0 )
>{
> text = "";
>}
That's correct behaviour. Now if you had written { $text = ""; }
and it was still outputting 'text = "";' then you might have had
an argument... ;)
>when I cut the grammar down to include just the
AsciiStringLiteral
>rule (available in
http://www.mangrove.cz/antlr-3.1b1-trouble/sample ),
>mAsciiStringLiteral() starts using Text...
Because that's what you wrote. Unless you use the $ prefix (which
you're supposed to use whenever you refer to any ANTLR-provided
parameters, fields, etc) then ANTLR will leave your code
alone. It assumes you know what you're doing.
More information about the antlr-interest
mailing list