help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

%destructor feedback


From: Wolfgang Spraul
Subject: %destructor feedback
Date: Sun, 16 Oct 2005 01:58:57 +0200
User-agent: KMail/1.8.1

Under %destructor, the bison 2.1 manual says:

"this feature is still experimental, as there has not been enough user 
feedback."

Well, I can help with that: I am using %destructor for a while now and I like 
it. It works well. One problem I have is that there is no %destructor-param 
same as the %parse-param or %lex-param. I would suggest to either use the 
%parse-param for yydestruct() as well, or to introduce a separate 
%destructor-param (I would prefer the latter).
When using pure-parsers, I usually have some state object that needs to be 
passed around. Currently, I am running sed after bison to add my own 
'destructor-param' :-)

In the latest bison 2.1, the stack cleanup was fixed in several cases. The 
behavior is now cleaner (and bug free as far as I can tell), but it's not 
well documented with regards to yydestruct():

Let's say you have an action that gets an object passed in which has a 
destructor. When using YYABORT inside the action, the destructor for this 
object is always called. When using YYERROR, it is never called, i.e. the 
action needs to destruct passed objects itself before using YYERROR. That's 
because the YYERROR will always do a yyvsp-=yylen (and yyssp-=yylen), and 
thus remove those items from the stack before cleanup, whereas YYABORT will 
not do that.

One could lean either way on the question whether YYABORT/YYERROR should or 
should not destruct objects passed to actions. At least with 2.1 the behavior 
is clean, and I'm fine (I'm mostly using YYABORT now and prefer the built-in 
cleanup). It's imaginable that someone would want YYERROR to behave the same 
as YYABORT, i.e. destruct objects passed into actions, I don't have enough 
overview to make a judgment on that.

Regards,
Wolfgang




reply via email to

[Prev in Thread] Current Thread [Next in Thread]