[antlr-interest] Help with simple grammer.

ooobles oobles at hotmail.com
Thu Jun 12 18:56:29 PDT 2003


I've been working on a grammer for a simple list based language.  I 
have a problem with getting operator precedance right.  Hopefully 
someone might spare a minute to help me out?  I'm sure it can be 
solved simply.  I'd like to create a grammer that can parse something 
like:

definition: identA functionX(  identB  functionY( identC | identD | 
identE )  identF )

there is only three real elements to the grammer.
   1. a sequence..    A B C
   2. a function..    F(  )
   3. an optional sequence..  A | B | C

so far I've go a grammer like:


definition: IDENTIFIER COLON sequence
    ;

sequence: pipexpr ( sequence )?
    ;

pipeexpr: element ( '|' pipeexpr )?

element: IDENTIFIER  
       |  identifier '(' sequence ')'
       ;


This will compile in Antlr without warnings.  But it seems that the 
following would be parsed as valid

def: identA | identB identC

Is this case something that should be checked in code, or is there a 
better way to express the grammer?

Thanks,
David.





 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list