[antlr-interest] [SPAM] Re: Re: Optional expression rule alternative

Olivier Lefevre lefevrol at yahoo.com
Fri Feb 11 10:46:42 PST 2011


On 2/11/2011 7:34 PM, Bart Kiers wrote:
> You can still do that:
> rule [boolean z]
>    :  {z}? (rule1 | rule2 | rule3 | ... | rule23 | rule24)
>    |       (rule1 | rule2 | rule3 | ... | rule23)
>    ;

Yes but the rule1 | ... | rule23 train is huge: that is what
I meant by "without too much verbatim repetition". So I'll
pack off the first 23 rules into yet another rule; not ideal
but that'll do.

I knew about predicates (although I haven't used them so far)
but they didn't occur to me in this context because they are
presented as a solution for grammar ambiguities, not as
switches driven "from outside" as here.

Thanks again,

-- O.L.



More information about the antlr-interest mailing list