[antlr-interest] Checking whether an optional rule matched or not

Achint Mehta achintmehta at gmail.com
Fri Aug 21 23:52:06 PDT 2009


Hi Kevin,

The changes suggested by you solved the problem.

Thanks.

Regards,
Achint

On Sat, Aug 22, 2009 at 2:43 AM, Kevin J. Cummings <
cummings at kjchome.homeip.net> wrote:

> On 08/22/2009 01:46 AM, Mark Wright wrote:
> > Hi Achint,
> >
> > Maybe something like:
> >
> > first
> > @init { bool second_rule_matched = false; }
> >   : (second)? { second_rule_matched = true; } third
>
>     : (second { second_rule_matches = true; })? third
> > {
> >     if(second_rule_matched)
> >       cout<<" Second rule matched"<<endl;
> > }
> > ;
>
> Put the assignment action inside the optional subrule.
>
> --
> Kevin J. Cummings
> kjchome at rcn.com
> cummings at kjchome.homeip.net
> cummings at kjc386.framingham.ma.us
> Registered Linux User #1232 (http://counter.li.org)
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090822/e5f51bd4/attachment.html 


More information about the antlr-interest mailing list