[antlr-interest] antlrworks 3.0ea8 unreachable error

Terence Parr parrt at cs.usfca.edu
Mon Mar 20 15:40:10 PST 2006

stick with one grammar file for now though you can say "lexer grammar  
foo;" and put in separate file.
On Mar 20, 2006, at 3:32 PM, Martin d'Anjou wrote:

> On Mon, 20 Mar 2006, O.E. Dragon wrote:
>> On Mon, 20 Mar 2006 18:05:26 -0500 (EST)
>> "Martin d'Anjou" <mdanjou at neterion.com> 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"
>>> When I change "ID" to lower case "id", it works...
>>> Am I missing something?
>> By convention, grammar rule that start with a lower case letter are
>> expected to be parser rules, and those starting with an upper case
>> letter are lexer rules.
>> I don't know how ANTLR v3 works but in v2 you need to put parser  
>> rules
>> in a separate grammar section.
> I have looked at the examples for v3, but I don't find how to  
> create a seperate section for lexer rules. The closest is the  
> ruby.g file, where it has the GVAR token defined in terms of ID,  
> but I don't see what it is that explicitely seperates the grammar  
> and the lexer.
> Martin

More information about the antlr-interest mailing list