[prev in list] [next in list] [prev in thread] [next in thread] 

List:       antlr-interest
Subject:    [antlr-interest] beta6, alternation produces non compiling code.
From:       jaluber () gmx ! de (Johannes Luber)
Date:       2007-02-28 11:21:52
Message-ID: 45E565D0.7090701 () gmx ! de
[Download RAW message or body]

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
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic