[antlr-interest] Syntactic predicate for single alternatives

Prashant Deva prashant.deva at gmail.com
Wed Jan 11 20:43:40 PST 2006


> At the program rule I think statement2 is an alternative to statement1 in
> the following construct:  (statement1)* statement2
>
No, statement2 is not an alternative in this case. It just follows
statement1. Which is why you get the syntactic predicate ignored warning,
cause there is no need for it.

To make statement2 an alternative, write  the rule like this -




program
    :
        (DO THIS)=>  (statement1)*

        | (statement2)?
    ;

Notice the '|' operator which separates 2 alternatives.

--
Prashant Deva
Creator, ANTLR Studio
Founder, Placid Systems, www.placidsystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060112/40266890/attachment.html


More information about the antlr-interest mailing list