[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
I have a feature request.. (which may be due to some misunderstanding,
which which case a clarification would be appreciated).
Suppose you parse some input into an abstract syntax tree. Then
you have a class
class MyAnalysis extends DepthFirstAdapter
that you use to sniff through the tree doing things. Now suppose
that in the course of sniffing through the tree, you come across
a fatal error in the input- not a parse error, but perhaps a semantic
error (e.g., duplicate identifier).
It would be nice if you could throw an exception at this point.
However, none of the methods in DepthFirstAdapter declare any
exceptions, so neither can any methods of class MyAnalysis. There's
no way to do this except by throwing one of the uncaught exceptions
(eg, RuntimeException), which would be an ugly hack.
In the case I'm thinking of, the error really is fatal because
one of the object that was going to annotate the tree can't be
created, so were the DFS to continue, a null object will eventually
get referenced and it would crash that way.
So the feature request is that the methods of DepthFirstAdapter
declare throwing some new exception created for this purpose
(call it SemanticException or whatever).
Does this make sense? Or is there another way to get around this
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com