[antlr-interest] antlrworks 3.0ea8 unreachable error

Martin d'Anjou mdanjou at neterion.com
Mon Mar 20 16:56:40 PST 2006


On Mon, 20 Mar 2006, Terence Parr wrote:
>
> On Mar 20, 2006, at 3:05 PM, Martin d'Anjou wrote:
>
>> The following highly simplified grammar:
>> 
>> grammar mygrammar;
>> def	:	ID;
>> ID	:	LETTER;
>> LETTER	:	'a';
>> 
>> Gives me this error in antlrworks:
>> "The following token definitions are unreachable: LETTER"
>
> ID is a letter is an 'a' hence the two are equivalent.  ANTLR chooses first. 
> You want
>
> ID : LETTER+ ;
>
> fragment LETTER : 'a' ;

Awesome. "fragment" works. Thanks.

Martin


More information about the antlr-interest mailing list