[antlr-interest] Changes in ASTFactory breaks custom AST classes
Terence Parr
parrt at jguru.com
Mon Dec 9 12:13:12 PST 2002
On Sunday, December 8, 2002, at 05:44 AM, Marco Hunsicker wrote:
> Hi all,
>
> I've just updated to the current ANTLR distro (2.7.2a6-20021130) and
> noticed that my dereived ASTFactory did not work as expected anymore
Damn...
> (I only use the Java stuff). I took a look at antlr.ASTFactory.java
> and realized that the dup(AST) method changed (of course, the whole
> class was expanded, but this is the one change that has bitten me).
>
>
> 2.7.2a2 looked like
> <pre>
> public AST dup(AST t) {
> return create(t); // if t==null, create returns null}
> }
> </pre>
>
>
> 2.7.2a6 does
> <pre>
> public AST dup(AST t) {
> if ( t==null ) {
> return null;
> }
> // don't just call
> AST dup_t = create(t.getClass());
> dup_t.initialize(t.getType(), t.getText());
> // ^
> // why not use initialize(t) ???
> return dup_t;
> }
> </pre>
Ah! Right...should be as you say...cut-n-paste + stupidity error ;)
> 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?
Nope...you're right.
> Another minor thing I've noticed is that the new "classHeaderPrefix"
> option (cool!) has been only implemented for lexers. I hope this is
> not intentional?
Ah. Thanks...i'll fix.
> Anyway, many thanks for creating such an exceptional piece of
> software. Love it!
You are most welcome!
Ter
--
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