[antlr-interest] Curious behaviour: unused rule has unknown effects
Jim Idle
jimi at temporal-wave.com
Tue Mar 24 10:25:12 PDT 2009
Gabriele Palma wrote:
> It is a parser rule.
>
> toBeRemoved returns [String out]
> : 'switch' '(' expression ')' '{' ( case_statement |
> default_statement | statement )* '}'
> ;
>
> It was a switch statement rule. I now have a new switch statement rule
> which better fits my needs.
> "toBeRemoved" doesn't show up anywhere in the grammar except in this line.
>
Yes, but you are using literal 'strings' in the rule and this defines
lexer token rules and without eh whole grammar, who knows what is going
on? This is one of the reasons that I advise everyone, at least when
starting out, not to use literals in the parser rules; unless you
completely understand what is going on, then you get in to all sorts of
trouble. Take the literals out of your parser and put them in the lexer,
then you will at least be able to judge the parser rules as they are.
Jim
More information about the antlr-interest
mailing list