[antlr-interest] How can I insert an action when a su-brule fails as well as when this is not present?
Gabriel Petrovay
gabriel.petrovay at 28msec.com
Fri Mar 27 09:46:04 PDT 2009
Hi,
I would like to perform a custom action when a subrule fails (=does not
match).
For example:
r : sr1 { /* action when sr1 is matched */ } (sr2)?
I would like an action to be executed when the subrule 2 does not match. I
already tries to make a new rule out of sr2 like this:
r : sr1 { /* action when sr1 is matched */ } (sr2)?
sr2 : 'KW' ss1 ;
As you can see in my case sr2 is prefixed with the keyword 'KW'. ANTLR
generates for this in the code or rule r an if expression to check if after
matching sr1 the keyword 'KW' is next. If not, sr2 if not even called. This
is what I want to capture. The missing sr2. Are there any other solutions
besides using a debug token stream which I want to avoid.
Thanks!
Regards,
Gabriel
--
MSc Gabriel Petrovay
MCSA, MCDBA, MCAD
Mobile: +41(0)787978034
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090327/77a0e140/attachment.html
More information about the antlr-interest
mailing list