|Subject:||Re: [Question / Bison 1.875c]: %destructorS not being called at all?|
|Date:||Thu, 04 Mar 2004 20:02:17 -0500|
|User-agent:||Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02|
Shouldn't these "%destructor"s be called automatically? Or am I doing something wrong (or misunderstanding anything)? In either case, has anybody seen this behavior before, and how can I ensure that memory allocated by "malloc" in semantic actions gets properly freed by "%destructor"s ?
As I understand it, the %destructors are only called if the parser needs
to throw away a token. If your parser didn't have an error condition,
or a parser split in the case of GLR, the parser will probably have
successfully passed the tokens to the actions you defined. As such, it
didn't throw any tokens away and didn't call %destructor. The moment
tokens reach action code (even the default action) it becomes your job
to clean them up (typically you will place token values in a parse tree
of some sort, and you don't want bison to deallocate parts of it behind
Also see the 'Destructor Decl' topic in the bison info file.
|[Prev in Thread]||Current Thread||[Next in Thread]|