[antlr-interest] Limits of tree generation (C++)

mzukowski at yci.com mzukowski at yci.com
Tue Oct 7 09:31:59 PDT 2003


You are using the same node twice--l1 is a node already and when you add it
the second time it already has a sibling of r1.  So copy the node first.
Note l1 may be a whole tree since it is calling expr.  There are methods for
this, not sure what it is in C++, in java I think it is called dupTree or
something.

Monty

-----Original Message-----
From: marcschellens [mailto:m_schellens at hotmail.com] 
Sent: Tuesday, October 07, 2003 1:16 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Limits of tree generation (C++)

I have:

comp_assign_expr!
    : #(a1:PLUS_EQ l1:expr r1:expr) 
        { #comp_assign_expr=#([ASSIGN,":="],([PLUS,"+"],l1,r1),l1);} 
    ; 

and get for example (for l1 = VAR, r1 = 1):

Tree parser output:
<:=
  <+ VAR 1 >VAR 1
>

But I think it should be:

Tree parser output:
<:=
  <+ VAR 1 >VAR // no 1
>

The problem is obviously, that I use one ASTNode (l1) twice in the
output tree.
Using ANTLR 2.7.2, how can I archieve what I want?
thanks,
marc



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list