[antlr-interest] gunit with custom AST nodes throws InvocationTargetException
Felix Dorner
felix_do at web.de
Fri Mar 28 04:09:55 PDT 2008
Hey,
Until yesterday my gUnit tests ran fine in "Interpreter" mode. I now
switched to a custom AST implementation (see below). Now, running the
gUnit test simply exits without any output. Generating the JUnit test,
and running that throws an InvocationTargetException when it tries to
run a parser rule by reflection. The Exception is caused by a
ClassCastException. Somewhere there's a cast from CommonTreeNode to my
AST type is executed (which obviously fails..)
Has anyone had the same problem?
Felix
package allure.parser.ast;
import org.antlr.runtime.Token;
import org.antlr.runtime.tree.CommonTree;
import allure.parser.symbols.Scope;
import allure.parser.symbols.Symbol;
public class AST extends CommonTree {
// The symbol that this node refers to
public Symbol symbol;
// The scope associated with this subtree
public Scope scope;
public AST(Token t){
super(t);
}
}
import org.antlr.runtime.Token;
import org.antlr.runtime.tree.CommonTreeAdaptor;
public class ASTAdaptor extends CommonTreeAdaptor {
public Object create(Token payload) {
return new AST(payload);
}
}
More information about the antlr-interest
mailing list