[antlr-interest] Tree grammar code gen problem
Bill Andersen
andersen at ontologyworks.com
Wed Feb 13 07:55:45 PST 2008
Folks,
I'm doing my first ANTLR (3) tree grammar and am running into a
problem with generated Java code. The grammar is a tree grammar meant
to output another AST.
The grammar file options look like:
options {
language=Java;
tokenVocab=NFL;
output=AST;
TokenLabelType=CommonToken;
ASTLabelType=CommonTree;
}
Some sample generated Java code I'm seeing looks like this:
protected TreeAdaptor adaptor = new CommonTreeAdaptor();
public final term_return term() throws RecognitionException {
term_return retval = new term_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
CommonTree QSTRING1=null;
...
Later in this method I'm seeing
QSTRING1_tree = (CommonTree)adaptor.create(QSTRING1);
But TreeAdaptor.create has only one one-arg version and that is
supposed to take a Token.
Any idea what's going on? I admit I don't have much experience with
this, but I've looked on the web and in the ANTLR 3 book with no
luck. Any help appreciated!
.billl
More information about the antlr-interest
mailing list