[antlr-interest] Curious behaviour: unused rule has unknown effects

Rodrigo C. L. tapetedepadaria at gmail.com
Tue Mar 24 11:27:23 PDT 2009


Defining the literals as tokens is the same as putting them in the lexer?

 -- Rodrigo C. Lopes
 -- Também em r.cerqueira.lopes at gmail.com





2009/3/24 Jim Idle <jimi at temporal-wave.com>:
> 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
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list