[antlr-interest] Error in generated tree parser with rewrite rules - possible bug?
Benjamin Niemann
pink at odahoda.de
Fri Nov 16 19:06:55 PST 2007
Hi Lorenzo,
Lorenzo Dalla Vecchia wrote:
> I've built a simple tree parser to parse a tree and rewrite it (so the
> output is also a tree).
Are you using the upcoming V3.1? 3.0 does not support treeparsers with
output=AST.
> 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.
More information about the antlr-interest
mailing list