[antlr-interest] problem with tree rewrite

Miguel Ping mblp at mega.ist.utl.pt
Thu Mar 29 17:14:37 PDT 2007

Hi all,

It seems I'm having trouble telling antlr v3 how to rewrite my tree. I
got this rule:

selectedTable :
           subQuery alias? -> ^(subQuery ^(ALIAS_REFERENCE alias)? )

but when running, I got this RuntimeException: "more than one node as
root (...)"

It seems antlr thinks that I'm trying to specify 2 root nodes with the
"^" operator, but I want a tree with subQuery as root, and with a
subtree with ALIAS_REFERENCE as (sub)root if alias exists. I double
checked documentation, and it seems the syntax is valid:
from http://www.antlr.org/wiki/display/ANTLR3/Tree+construction

classDefinition[MantraAST mod] :
		-> ^('class' ID {$mod} ^('extends' $sup)? ^('implements' $i+)?
		     variableDefinition* ctorDefinition* methodDefinition*

So what am I missing?

Thanks in advance,
Miguel Ping

More information about the antlr-interest mailing list