[antlr-interest] Help with simple grammer.

Matthew Douglass mdouglass at exapted.com
Thu Jun 12 23:45:16 PDT 2003


And of course it hits me right AFTER I sent that, that I didn't
differentiate between your sequences and optional sequences...  Rereading it
I'm a little unclear as to where sequences like A B C are acceptable and
where sequences like A | B | C are acceptable.  So maybe you can help me out
with that (or just wait for someone with more knowhow to jump in)
Sorry,
Matthew
----- Original Message -----
From: "ooobles" <oobles at hotmail.com>
To: <antlr-interest at yahoogroups.com>
Sent: Thursday, June 12, 2003 6:56 PM
Subject: [antlr-interest] Help with simple grammer.


>
> 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/
>
>
>



 

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




More information about the antlr-interest mailing list