Parse tree creation question

"Nicolas" <>
11 Mar 2000 13:40:48 -0500

          From comp.compilers

Related articles
Parse tree creation question (Nicolas) (2000-03-11)
Re: Parse tree creation question (Quinn Tyler Jackson) (2000-03-21)
Re: Parse tree creation question (Georges LOUIS) (2000-03-23)
Re: Parse tree creation question (Chris Dodd) (2000-03-23)
| List of all articles for this month |

From: "Nicolas" <>
Newsgroups: comp.compilers
Date: 11 Mar 2000 13:40:48 -0500
Organization: - Before you buy.
Keywords: parse, question


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

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,

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.