Parse tree creation question

"Nicolas" <lojedaortiz@interlink.com.ar>
11 Mar 2000 13:40:48 -0500

          From comp.compilers

Related articles
Parse tree creation question lojedaortiz@interlink.com.ar (Nicolas) (2000-03-11)
Re: Parse tree creation question qjackson@wave.home.com (Quinn Tyler Jackson) (2000-03-21)
Re: Parse tree creation question glouis@univ-lr.fr (Georges LOUIS) (2000-03-23)
Re: Parse tree creation question chrisd@reservoir.com (Chris Dodd) (2000-03-23)
| List of all articles for this month |
From: "Nicolas" <lojedaortiz@interlink.com.ar>
Newsgroups: comp.compilers
Date: 11 Mar 2000 13:40:48 -0500
Organization: Deja.com - Before you buy.
Keywords: parse, question

Hi,


I am creating my abstract syntax tree with bison. I have some rules like
this:


a: b c { $$ = gProgram = new a( $1, $2 ); } ;
b: d { $$ = new b( $1 ); } ;
c: e { $$ = new c( $1 ); } ;


Now, if the parsing phase doesn't fail, when a gets reduced, gProgram
is a pointer to the entire parse tree, so I can't deallocate it when I
am done working with it. But, if the parsing phase fails for any
reason, I can't deallocate the nodes constructed up to the momento of
failure, since I have no pointer to them.


Any help on how to remedy this would be extremely helpful.


Thank you very much,
Nicols


PS: I thought the possibility of creating an object "pool", and
allocating the objects from there. That way I could maintain a list of
created objects and deallocate them when I am done. But I don't know if
this is the best approach.
[That's what I do, in compilers where I do enough work after a parse
failure to go to the effort of freeing the space. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.