[antlr-interest] operator inside a string

Gavin Lambert antlr at mirality.co.nz
Wed Jul 8 02:59:15 PDT 2009


At 21:31 8/07/2009, Bob Night wrote:
>Thanks! That solved my problem.
>
>But to be honest I still don't understand what causes the change 
>of behaviour.

Maybe you need to read the book :)  Or possibly just the wiki.

Lexer rules start with an uppercase letter.  Parser rules start 
with a lowercase letter.  Lexer rules turn characters into 
tokens.  Parser rules turn tokens into trees, or generate 
templated output, or carry out other actions.

The spaces were disappearing because they were turning into WS 
tokens (which were hidden), since to the parser, all lexer rules 
are equal.  By making a lexer rule that outputs a single token, it 
preserves everything in the quotes regardless of any other lexer 
rules.



More information about the antlr-interest mailing list