[antlr-interest] Re: Limits of tree generation (C++)
marcschellens
m_schellens at hotmail.com
Thu Oct 9 02:58:08 PDT 2003
The next stage of processing that tree knows only to read
the first node.
As I understood, the nodes are reference counted.
Isn't it therefore more effective to keep it like it is,
or is there a caveeat?
thanks,
marc
--- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:
> 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 h...]
> 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