[antlr-interest] Calling code at rule exit

Akhilesh Mritunjai virtualaspirin at yahoo.com
Wed Nov 16 10:43:35 PST 2005


I know its like using an elephant gun to kill a
cockroach, but have you given a thought in using AOP
frameworks like AspectJ and kins.

I believe ANTLR gives options to add exception
handlers, but dunno about finalizers... and even they
don't apply to complete method body, afaik. AOP hacks
are only things guaranteed to work.

- Akhilesh


--- David Ray <ray at soartech.com> wrote:

> 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
> 



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


More information about the antlr-interest mailing list