Related articles |
---|
Re: YACC error handling heirich@cs.ucsd.edu (1989-07-29) |
yacc error handling ajayk@microsoft.com (Ajay Kalhan) (1999-11-19) |
Re: yacc error handling ajayk@microsoft.com (Ajay Kalhan) (1999-11-21) |
Re: yacc error handling ewbank@lucent.com (Bryan Ewbank) (1999-11-23) |
Re: yacc error handling zalman@netcom11.netcom.com (Zalman Stern) (1999-11-28) |
Re: yacc error handling mschweis@u.arizona.edu (Michael C Schweisguth) (1999-12-07) |
Re: yacc error handling wfahle@bigfoot.com (Bill Fahle) (1999-12-24) |
From: | Michael C Schweisguth <mschweis@u.arizona.edu> |
Newsgroups: | comp.compilers |
Date: | 7 Dec 1999 00:34:15 -0500 |
Organization: | The University of Arizona |
References: | 99-11-117 99-11-128 99-11-134 99-11-172 |
Keywords: | yacc, design |
I Think That All You Have To Do Is Have A Global List Of All The
Memory You Allocate During The Parse, And Then, You Can Simply
Traverse The Linked List And Delete All The Allocated Memory. This Is
A Fairly Common Technique. If You Make A Tree Node, With Children A
And B, Then You Would Remove A And B From The Linked List And Add The
Tree Node To The List Since Deleting The Tree Node Also Deletes The
Children.
The Other Technique Is Deferred Dynamic Memory Allocation. You Only
Allocate At The Tips Of The Production. Hence, You Take Full
Advantadge Of The Yacc Stack. The Only Real Problem With The Yacc
Stack Is A Variable Size String. So, You Could Easily Create A String
Allocator Which Can Free All The Strings At Once. If A Token'S
Structure Is Large, You Could Use The Same Technique. If There Was No
Error, Than Perhaps The String Allocator Would Not Be Freed, But Kept.
Have Fun!
> Bryan Ewbank <ewbank@lucent.com> wrote:
> : Since there are parse errors, isn't the program going to exit? If so,
> : why bother cleaning up?
Zalman Stern <zalman@netcom11.netcom.com> wrote:
> This is precisely the attitude that makes makes compiler generation
> tools (e.g. original lex/yacc) such a pain to use in areas other than
f> traditional batch compiler type applications.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.