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 _______________________________________________ [email protected] http://lists.gnu.org/mailman/listinfo/help-bison
