[antlr-interest] About tree duplication ?

Mathieu Clabaut mathieu.clabaut at gmail.com
Thu Nov 17 04:24:12 PST 2005


 Thank you Ric for your explanations.... but ..

On 17/11/05, Ric Klaren <ric.klaren at gmail.com> wrote:
> Keep in mind that the antlr tree objects are references or reference
> counted objects. Basically they behave like pointers.
> >  For example, the following creation rules
> >           ##= #([OR_SERVICE,"||"],
> >                    #([TWOWAY,"<>"],#s3,
> >                       #([SOURCE,":<"], #f3),
> >                       #([DESTINATION,":>"],#t3)
> >                    ),
> >                    #([TWOWAY,"<>"],#s3,
> >                       #([SOURCE,":<"], #t3),
> >                       #([DESTINATION,":>"],#f3)
> >                    )
>
> This is really bad practice since you link a node into the tree at
> multiple spots, potentially creating loops in the tree that will hang
> the normal tree traversal functions.

 It may be bad practice, but it is not really said in antlr
documentation (not complaining, just stating).
 You can know it is bad practice if you have a suficiant insight of
how antlr translate the #xx notations  (I could have imagine that
antlr  check how many time a reference is use in tree construction...)
and how the AST class are made (or when you meet such a problem, which
force you to dig deeper in the backstage)...

 Anyway thank you for your help... I'll review my code to check If I
other simlilar cases in....

-mathieu



--
____________http://www.gnu.org/philosophy/no-word-attachments.fr.html
Mathieu CLABAUT                         mailto:mathieu.clabaut at gmail.com
           F2F5 442F F2AC E1D5 9D31  3EFC 842A BC4A 123B 9A65


More information about the antlr-interest mailing list