找不到符号 - antlr错误

时间:2015-12-14 14:17:18

标签: antlr

我得到"找不到符号错误"在insertchild函数上:

  

calculatorParser.java:330:错误:找不到符号   tempTree.InsertChild(((ValueContext)_localctx).e14.tree); ^符号:   方法InsertChild(Tree)location:类型为Tree的变量tempTree

我做错了什么?

exp returns [Tree tree] : 
    LBRACKET 
    e1=value{$tree.insertChild($e1.tree);}
    RBRACKET
    | e2=value{$tree.insertChild($e2.tree);}
;

value returns [Tree tree]:
                            e3=exp DOLLAR e4=exp {
                                                    Tree tempTree= new Tree('$');
                                                    tempTree.InsertChild($e3.tree);
                                                    tempTree.InsertChild($e4.tree);
                                                    $tree=tempTree;
                                                }

这是树结构:

public Tree(String value){
    this.value = value;
    childList = new LinkedList<Tree>();
}
//Insert a subtree as a child
public void insertChild(Tree child){
    childList.addLast(child);
}

0 个答案:

没有答案