[antlr-interest] nodes, hidden tokens, garbage collection

John Allen Green greenj at ix.netcom.com
Tue Apr 2 15:33:19 PST 2002


Hi all,

There's an old issue with hidden tokens: they are doubly-linked, therefore,
they must be manually cleaned up at the time that you delete the AST.

(Simply deleting the AST doesn't take care of them because they refer to
each other, so their reference count never drops to zero. If you don't,
then they are a memory leak.)

I'm just starting to look at a bit of a design issue. I'm adding an API to
my parser so that nodes can be added, deleted, moved around, etc.
Obviously, hidden tokens will be a bit of an issue.

To make things even more fun, I've got backwards links in my custom AST
type from child to parent and from sibling to previous sibling, for
purposes of my API. (Don't ask) So, because of that, I've got the same sort
of issue with regular AST nodes as with the existing hiddenToken objects.

Like I said - I've just started considering the issues and thinking about
design options. I'm wondering if anybody has any advice.

For example:
- has anybody on this list done this sort of thing before?
- has anybody used, or considered using, a garbage collector with Antlr AST?
- any other words of wisdom?

Thanks in advance,
John Green



 

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



More information about the antlr-interest mailing list