[antlr-interest] Error in generated tree parser with rewrite rules - possible bug?

Lorenzo Dalla Vecchia lor.dv at tiscali.it
Fri Nov 16 04:18:28 PST 2007


Hi.

I've built a simple tree parser to parse a tree and rewrite it (so the output is also a tree).


tree grammar MyGrammar;

options {
 output       = AST;
 ASTLabelType = CommonTree;
}

tokens {
 ...some tokens used for rewrite...
}

...parser rules... with tree rewrite (new 3.0 syntax)


ANTLR Tool compiles the grammar correctly, but the resulting Java file has several errors.

- if I don't rewrite all rules, many errors "The method create(Token) in the type TreeAdaptor is not applicable for the arguments (CommonTree)"

- even after putting rewrite rules everywhere, each rule method has an error "retval.stop cannot be resolved or is not a field", inside a adaptor.setToeknBoundaries call

- if I comment out the setTokenBoundaries calls in the generated code, I get runtime ClassCastException about trying to cast CommonTree to token

What could be the issue? May it be a bug in tree parsers with AST output?
Thanks.

--
Lorenzo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071116/7da3f9d6/attachment-0001.html 


More information about the antlr-interest mailing list