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.
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---