[antlr-interest] Question on aborting rule based on pattern

Stanimir Stamenkov stanio at myrealbox.com
Mon Jul 24 00:35:53 PDT 2006


/Rajeev Bharadhwaj/:

> Does it automatically switch to ccc without catching 
> SemanticException
> 
> Does it assume that '"AAAA" SPACE bbb ccc' rule 
> failed, hence any actions added to the end after ccc 
> are not executed but those between bbb and ccc are 
> executed?

As far as I know (and I'm pretty new to ANTLR, too) when there are 
alternatives which might match the same thing with the specified 
look ahead ANTLR is switching into guessing mode and doesn't 
propagate recognition exceptions but just catches them to try the 
next alternative. In this regard my suggestion was not useful as 
"AAAA" and "XXX" literals (the starting of 'aaa' and 'ccc' rules) 
are different and no guessing will take place, I suppose. You may 
see if my other reply (using a syntactic predicate) will help you more.

-- 
Stanimir


More information about the antlr-interest mailing list