[antlr-interest] How can I insert an action when a su-brule failsas well as when this is not present?
Dave Dutcher
dave at tridecap.com
Fri Mar 27 10:27:56 PDT 2009
> From: Gabriel Petrovay
> Subject: [antlr-interest] How can I insert an action when a su-brule
failsas well as when this is not present?
>
> 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 think you can do this:
R : sr1 { /* found sr1 */ } ( sr2 { /* found sr2 */ } | { /* no sr2 */ } );
Although I'm pretty new at Antlr myself, so no guarantees that's the best
way.
Dave
More information about the antlr-interest
mailing list