I have never seen a case whereby the second part of your tree cannot be
moved to another rule, but I will believe it is possible. Anyway, you just
need to use rewrite rules rather than annotating the tokens with tree
construction.

->^(X ^(Y other))

And do not use 'Literals' in your parser/tree parser, make real lexer
tokens.

Jim

> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> On Behalf Of Manfred Wölfel
> Sent: Monday, September 06, 2010 7:38 AM
> To: [email protected]
> Subject: [antlr-dev] Nested trees
> 
>   Is there a way to make a sequence
> 'X'^ ('Y'^ other)
> yield a tree like (X (Y other)) instead of just Y? Because whenever it
> encounters ^ it makes the token root of a new tree forgetting about the
> past.
> The above mentioned code is straightforward generated from a different
> language. So it's hard to move the code in brackets into a separate rule
or use
> rewrite rules.

_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to