This is what it is supposed to do. In the first example, no nodes have been
accumulated yet, so there is nothing to become the first child yet. In the
second case you have accumulated a node already and therefore it becomes a
child as would any others already accumulated.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Hitesh Shetty
> Sent: Monday, August 09, 2010 9:11 AM
> To: [email protected]
> Subject: [antlr-interest] A basic question about AST construction
operators
> 
> Hi,
> 
> Im a newbie ANTLR user and I had a basic question about the AST
> construction operator '^' caret, When the AST construction operator '^'
> (caret) is used along with a normal rule such as
>    condStatement : 'expression' ^ x=statement1 (y=statement2)? ; The term
> 'expression' becomes the root for the tree and the next un-suffixed
element
> i.e $x becomes the first child and $y becomes the second child. This can
be
> rewritten as ^('expression' $x $y?).
> However when the operator '^' is used along with a subrule such as
>    expr : x=INT ('+' ^ y=INT)* ;
> The $x is chosen as the first child not the next unsuffixed element i.e
$y.
> For example input 1+2 is parsed as ^('+' 1 2) and not as ^('+' 2 1) Am I
missing
> something obvious or Is this the behaviour of the AST construction
operator
> ?
> Any pointers would be greatly appreciated.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to