[antlr-interest] beta6, alternation produces non compiling code.

Johannes Luber jaluber at gmx.de
Wed Feb 28 03:21:52 PST 2007


Dr. Kocher, Hartmut wrote:
> The problem is with lexer vs. parser rules: Lexer rules are upper case. Parser rules are lower case.
> ELEM must be a lexer rule. Therefore, it must be named starting with
an upper case letter.
> List is a parser rule. Therefore it must be lower case. That's why
your first approach doesn't work.
> 
> Hope this helps
> 
> Dr. Hartmut Kocher
> Cortex Brainware

Thanks!

I'm still reading the ANTLR Reference book and the few chapters I've
already read didn't mention this. It explains why an example grammar I
wrote didn't work, too. Maybe Terrence should put that info into the
book somewhat sooner.

Johannes Luber

> -----Ursprüngliche Nachricht-----
> Von: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] Im Auftrag von Johannes Luber
> Gesendet: Mittwoch, 28. Februar 2007 12:06
> An: antlr-interest at antlr.org
> Betreff: Re: [antlr-interest] beta6, alternation produces non compiling code.
> 
> Hello!
> 
> I'm wondering myself, if I miss something, but
> 
>> Grammar list;
>>
>> list : ELEM (COMMA ELEM)* ;
>>
>> COMMA : ',' ;
>> ELEM : 'a'..'z' | 'A'..'Z'  ;
> 
> doesn't look different to me than
> 
>> list.g:
>> ------
>> grammar list;
>> list : elem (',' elem)* ;
>> elem : 'a'..'z'|'A'..'Z' ;
>> ------
> 
> (unless you count the COMMA). Why doesn't work the latter?
> 
> Best regards,
> Johannes Luber
> 
> 
> 
> --------------------------------------------------------------------
> Pharmatechnik GmbH & Co. KG
> Münchner Straße 15
> D-82319 Starnberg
> 
> Sitz der Gesellschaft: Starnberg
> HRA: 64434, HRB: 66369, Amtsgericht München
> Geschäftsführer: Dr. Detlef Graessner, Werner Torns, Stephan Jörgens
> 




More information about the antlr-interest mailing list