[antlr-interest] Re: XPA astFactory.dupTree bug?

David Ryan oobles at hotmail.com
Wed Aug 18 00:19:18 PDT 2004


Yes, I've done that today.  I can confirm that it's working nicely.

David.

> Hi David,
> 
> this looks reasonable. I will add it to XPA and it will be part of the 
> next release. In anticipation of that, why not add this code to your 
> local copy such that you can start to work with it now?
> 
> Oliver
> 
> David Ryan wrote:
> > Oliver,
> > 
> > Thanks for the quick response agian.  Looking at the ASTFactory class
> > in ANTLR, it has the following:  
> > 
> > protected AST create(Class c) {
> >    AST t = null;
> >    try {
> >       t = (AST)c.newInstance(); // make a new one
> >    }
> >    catch (Exception e) {
> >       error("Can't create AST Node " + c.getName());
> >       return null;
> >    }
> >    return t;
> > }
> > 
> > public AST dup(AST t) {
> >    if ( t==null ) {
> >       return null;
> >    }
> >    AST dup_t = create(t.getClass());
> >    dup_t.initialize(t);
> >    return dup_t;
> > }
> > 
> > The dup method uses the AST class to create a new instance.  I think
> > the XMLStartAST requires the following methods.  I haven't had a
> > chance to try this yet, will give it a go today.
> > 
> > public XMLStartAST() {
> >    super();
> > }
> > 
> > public void initialize(AST ast) {
> >    super.initialize(ast);
> >    setAttributes(new AttributesImpl(((XMLStartAST)
> > ast).getAttributes()));
> > }
> > 
> > Regards,
> > David.
> > 
> > Oliver Zeigermann wrote:
> > 
> >>Tell me what is missing in the XMLStartAST and I will add it. What
> > 
> > would 
> > 
> >>be the meaning of an empty contructor for XMLStartAST?
> >>
> >>Oliver
> >>
> >>David Ryan wrote:
> >>
> >>>I've started doing some rather nasty re-arranging of my XML data
> >>>structures using antlr and XPA.  This has involved expanding the
> > 
> > tree
> > 
> >>>by copying parts of a tree, and then pasting them back into
> > 
> > multiple
> > 
> >>>parts of the tree.  One pass for collecting inputs, and second
> > 
> > pass
> > 
> >>>for paste.
> >>>
> >>>I've discovered that just re-inserting the same AST into multiple
> >>>parts of the tree can end in infinite loops.  I'm now trying to
> >>>duplicate the AST trees as I put them back into the tree.  The
> >>>XMLStartAST does not have an empty constructor to support the
> >>>astFactory.dupTree method.
> >>>
> >>>Is there another way to duplicate XMLStartAST trees?  Is this the
> >>>right way to go about expanding a tree?
> >>>
> >>>Thanks,
> >>>David.
> >>>
> >>>PS Wish I could make the antlr workshop.  Ashame the few thousand
> > 
> > km
> > 
> >>>makes it so difficult to get to. :)  Any Antlarians going to
> > 
> > oopsla? 
> > 
> >>>I'll probably make it there this year.
> >>>
> >>>
> >>>
> >>> 
> >>>Yahoo! Groups Links
> >>>
> >>>
> >>>
> >>> 
> >>>
> >>>
> > 
> > 
> > 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> >



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list