[antlr-interest] Checking whether an optional rule matched or not
Kevin J. Cummings
cummings at kjchome.homeip.net
Fri Aug 21 23:43:45 PDT 2009
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)
More information about the antlr-interest
mailing list