[antlr-interest] Heterogenous Nodes lead to "addChild: Child not found, ignoring"
Florian Friedemann
cerbff at cs.tu-berlin.de
Fri Oct 24 03:20:57 PDT 2008
Hi,
Currently I'm trying to create ASTs containing heterogenous nodes as
described in the ANTLR wiki
However, whenever I use this feature on the right hand side of the rewrite
operator I get runtime warnings that addChild couldn't find the child and
the generated AST doesn't contain the heterogenous node.
I even tried a very simple implementation with the tree containing no
additional information so I really wonder what I might have missed.
The rule in the Grammar looks like this:
tmplId : name -> name ID<Id>; // the generated ID node doesn't show up in
the tree
the Id class looks like this:
class Id extends CommonTree {
public Id(Token tok) {
this.token = tok;
}
public Id(int ttype) {
this.token = new CommonToken(ttype, "");
}
public Id(Id node) {
super(node);
}
public Tree dupNode() {
return new Id(this);
}
public String toString() {
return (token!=null?token.getText():"") + "<Id>";
}
}
Versions:
ANTLRWorks: 1.2
ANTLR: 3.1
options:
backtracking=false;
output=AST;
ASTLabelType=CommonTree;
PS:
Strange enough... if I only return the ID<Id> and print out the resulting
tree of that rule it seems to yield the expected output (from toString())
so the created tree is not null or something like that.
Thanks in advance.
More information about the antlr-interest
mailing list