[antlr-interest] Calling code at rule exit
David Ray
ray at soartech.com
Wed Nov 16 08:51:16 PST 2005
Hello,
I have some code that I would like to be called whenever a rule exits
whether it exits normally or due to an error (I'm using the default
error handler, so reportError() is called and the exception never
actually leaves the method). I'm maintaining a variable scope stack and
I need to push/pop it in rules that introduce a new scope. Right now, if
an error occurs, the pop is never called and my stack is left in a bad
state.
If this were C++, I'd just make a sentry object and call pop in the
destructor, but since I'm doing this in Java I'm not sure if there is a
good way to do that. Does anyone know of a Java equivalent to C++
sentry objects, or some way I can do this in ANTLR?
Thanks,
Dave Ray
ray at soartech.com
More information about the antlr-interest
mailing list