[antlr-interest] exception handling for tree parser rules...

Jeff Vincent JVincent at Novell.Com
Mon Nov 3 08:53:07 PST 2003


Hey,
 
I have a 'block' rule in my tree grammar that defines a code block and
a new nested variable scope for a run-time scripting language.  When
this rule first executes, I create a child scope in the symbol table,
then process the rule normally.  When the parser exits this rule, I
delete the nested scope and return back to the parent.  However, if an
exception occurs, I need to detect this and remove the child scope
before propogating the exception back up the stack.  I would like to do
this in a 'finally' clause as part of a try-catch.  However, I am unable
to do this in the tree parser using the antlr grammar.
 
Am I doing it wrong or can I not specify a finally clause?
 
Thanks,
 
Jeff
 
//What I WANT my subrule to look like for reference.
 
  #( BLOCK
   {   stci = thr.pushLevel();
   }
   ( comboList 
    exception
     catch [AbortException aex] {
      throw aex;
     }
     catch [ContinueException cex] {
      throw cex;
     }
     catch [ReturnException rex] {
      throw rex;
     }
     catch [BreakException bex] {
      throw bex;
     }
     catch [ExitException eex] {
      throw eex;
     }
     finally {  //<------ANTLR doesn't like this.
      stci = thr.popLevel();
     }
   )?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20031103/634c86d8/attachment.html


More information about the antlr-interest mailing list