[antlr-interest] tree --> tree transformation

Bernhard Damberger bernied at gmail.com
Mon Jun 19 22:31:48 PDT 2006


I was trying to make a tree grammar with Antlr 3.0 that spits out
another modified tree.

options {
      tokenVocab = MyVocab;
      output=AST;
      ASTLabelType=CommonTree;
}

I tried it with and with out the ASTLabelType. In both cases the
compiler complains about Object attempting to being passed as Tokens
to the TreeAdaptor.

Is there something I am missing?

I just want to transform a tree from one form to another.

Two kinds of lines of code are causing problems:
              adaptor.setTokenBoundaries(retval.tree,retval.start,retval.stop);

In this case retval.start and retval.stop are Objects, not Tokens.

And

                  string_literal4=(Object)input.LT(1);
                  match(input,118,FOLLOW_118_in_statement63);
                  string_literal4_tree =(Object)adaptor.create(string_literal4);

on the third line because string_literal4 is expected to be a token,
but its a Object.

Any thoughts?

_bernhard


More information about the antlr-interest mailing list