[antlr-interest] Using a different Tree class
Andreas Ravnestad
andreas.ravnestad at gmail.com
Fri Dec 7 11:13:51 PST 2007
Hi!
How can I make Antlr use a different Tree class (not CommonTree)?
Currently I have this in the grammar:
grammar XQFT;
options {
output=AST;
ASTLabelType=XQFTTree;
}
Where XQFTTree extends CommonTree. And then, this is the test program:
XQFTParser.module_return result = parser.module();
XQFTTree tree = (XQFTTree)result.getTree();
And that will currently produce this error:
Exception in thread "main" java.lang.ClassCastException:
org.antlr.runtime.tree.CommonTree cannot be cast to
no.ntnu.xqft.parse.XQFTTree
at no.ntnu.xqft.parse.XQFTParser.module(Unknown Source)
at no.ntnu.xqft.test.TreeTest.execute(Unknown Source)
at no.ntnu.xqft.test.TreeTest.main(Unknown Source)
I'm sure I'm just missing a small detail here.
Thanks,
Andreas
More information about the antlr-interest
mailing list