[antlr-interest] Changes in ASTFactory breaks custom AST classes

Terence Parr parrt at jguru.com
Mon Dec 9 12:14:26 PST 2002

On Monday, December 9, 2002, at 02:16  AM, Ric Klaren wrote:
>> The problem (at least for me) lies in the fact that the duplicated
>> node gets only initialized with the type and text! All other
>> information stored in the original node is lost. I now simply
>> override dup(AST) too, changing it back to the old behavior (I only
>> use homogenous trees) but I'd rather expect dup(AST) to initialize the
>> duplicated node via dup_t.initialize(t) or am I missing something 
>> here?
> Hmmm I really think that should not be an initialize in there. A (near)
> complete copy of the object should be made (in C++ mode I use a clone
> method for it that goes through the copy constructor. Dunno if the java
> clone does the same thing) The semantics of the clone in C++ are to 
> copy
> the object except for the down/right links.

The only problem is that in java, clone will dup the thing bit-by-bit 
and then I'll have to wack the pointers to null and also it won't go 
thru the create() method of the factory.  Gotta be consistent I'd say.  
Make sense?

Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco


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

More information about the antlr-interest mailing list