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

Gabriele Palma gabrielepalma82 at gmail.com
Tue Mar 24 05:56:09 PDT 2009


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.

2009/3/24 Sam Barnett-Cormack <s.barnett-cormack at lancaster.ac.uk>:
> Gabriele Palma wrote:
>> I'm modifying my working grammar. I created a new rule which does
>> something previously done by another rule. I renamed the old rule and
>> it is now unreferenced in the whole grammar, while old reference now
>> go to the new rule. Everything seems fine, the grammar recognizes my
>> test inputs.
>>
>> But if i try to completely remove the old rule the grammar breaks and
>> no longer recognizes my working input test.
>>
>> Current file -> successfully generate code -> test -> everything ok
>> Current file -> remove unreferenced rule -> succesfully generate code
>> -> test -> grammar does not recognizes my input
>>
>> I double checked and the rule is not referenced in any way, if i do a
>> text search on the rule name the only instance found is in the rule
>> definition.
>>
>> I'm failing at undestanding the effect that an unreferenced rule has
>> on the generated grammar.
>>
>> Am I missing anything?
>
> Is it a lexer rule, or a parser rule?
>
> Sam
>


More information about the antlr-interest mailing list