Ok, thank you!

Karim


On Tue, Jan 18, 2011 at 6:15 PM, Jim Idle <[email protected]> wrote:

> The rewrites do not [always] duplicate the nodes, they change the pointers
> and so on. Hence you need to keep all the stuff around. It is not as
> inefficient as you think and it is keeping pointers to the input source
> and so on too, so you must keep it all around until you have finished
> using it. Just tear it all down and rerun it when ready to do the codegen.
> It won't take anytime at all to do that.
>
> Jim
>
> > -----Original Message-----
> > From: [email protected] [mailto:antlr-interest-
> > [email protected]] On Behalf Of Karim Chichakly
> > Sent: Tuesday, January 18, 2011 3:07 PM
> > To: [email protected] interest
> > Subject: [antlr-interest] C Runtime Multiple Serial Tree Walkers - What
> > can be freed when?
> >
> > I am using the C runtime.  I have a lexer and a parser.  Then I run a
> > constant expression reduction tree walker, which rewrites some nodes
> > (rewrite = false).  Then I run a semantic analysis tree walker, which
> > also rewrites some nodes (rewrite = false).  Then, at a much later time
> > determined by the user, I run a code generation tree walker.  I have to
> > keep the final tree (from the semantic analyzer) around as long as the
> > program is running, which could be hours.
> >
> > The C runtime example that does something similar, polydiff, keeps all
> > of the separate node streams and all of the intermediate trees around
> > until it no longer needs the final tree.  The Java version keeps
> > overwriting the nodes variable (which holds the node stream), so
> > presumably that is getting freed before the start of each tree walker
> > pass.  But also it keeps all the intermediate trees.
> >
> > If I try to free the first tree generated by the parser after running
> > the first tree walker (which gives me a different tree), the program
> > crashes on the free.  If I try to free the node stream, the tree
> > becomes invalid and I crash the next time I try to access it.
> >
> > I don't honestly have to keep all intermediate tree results and node
> > streams around forever, do I?  What can I safely get rid of and when?
> >
> > Thanks,
> >
> > Karim
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> > email-address
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to