[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiler error handling

Will Hartung wrote:
> How are folks handling errors during the compile phase?
> I have the system walking the tree and generating code. But when I encounter
> an error, I can't throw an exception (as outXXX doesn't allow it).

How about throwing a RuntimeException derived exception? You can catch
it and change it in a checked exception out of the tree walking code.


  walk_tree(ast); // or whatever
catch(CompileRuntimeException e)
  throw new CompileException(e);

There's no nice solution to this problem.  Either we impose an exception
on all out/in/... methods, or we use unchecked exceptions.

> It's working fine, I'm just curious if this is "the way it's done" or am I
> missing something. In the Thesis, there was a section where Etienne talked
> about having a bunch of nested AnalysisAdapter anonymous classes. I admit
> that it wasn't particularly clear what he was doing here to me.

Look in the mailing-list archive for discussion and example of AST

Good luck!

Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/