[antlr-interest] Question on aborting rule based on pattern
Stanimir Stamenkov
stanio at myrealbox.com
Sun Jul 23 00:20:57 PDT 2006
/Rajeev Bharadhwaj/:
> I tried inserting the semantic predicate, it fires
> alright but it throws a SemanticException. This looks
> more like a mechanism to find syntax errors and abort
> the parsing. In my case, I want to catch the exception
> and stop matching ddd and continue parsing.
You need to put 'aaa' and 'ccc' productions as alternatives to some
rule, like:
aaa : "AAAA" SPACE bbb ccc
| ccc ;
bbb : ( ddd )+ ;
ddd : ha:ATOM { !"XXX".equals(ha.getText()) }?
":" SPACE eee SPACE ; // Rule 1
eee : hva:ATOM (":" hvap:ATOM)* ;
ccc : "XXX" ":" SPACE ((cccentry)+ ; // Rule 2
--
Stanimir
More information about the antlr-interest
mailing list