[antlr-interest] Re: Heterogeneous AST - simple calculator pa rser
koud0002
robertkoudelka at power-solutions.com.au
Sun Feb 10 18:38:12 PST 2002
The problem is with the heterogeneous AST construction.
If I use the default AST the grammar works as expected.
However, when I add the parser option:
ASTLabelType = "CalcAST";
the tokens definition:
tokens {
UNARY_MINUS<AST=UnaryMinusNode>;
PLUS<AST=PlusNode>;
MINUS<AST=MinusNode>;
STAR<AST=MultNode>;
DIV<AST=DivNode>;
INT<AST=IntNode>;
}
and call the following methods on a parser object:
parser.setASTNodeType("CalcAST");
parser.setASTNodeClass("CalcAST");
it breaks.
I get: "unexpected end of subtree" error when tree-walking the
expression: (- 8) + 7 * 2
Expression: -1 does not yield this error but still gives incorrect
result of 1.
What do I need to do to get my hetorogeneous AST working properly.
Robert
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list