[Top][All Lists]

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

Re: %destructor feedback

From: Joel E. Denny
Subject: Re: %destructor feedback
Date: Mon, 17 Oct 2005 02:34:22 -0400 (EDT)

On Sun, 16 Oct 2005, Wolfgang Spraul wrote:

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.

It seems like this behavior ought to be consistent between YYERROR and YYABORT.

Another inconsistency is that, while your above description is accurate for yacc.c, it is not accurate for glr.c. That is, a GLR parser doesn't call destructors in either case.

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

I prefer that the clean-up *not* happen automatically for either YYABORT or YYERROR -- as in GLR parsing. This would allow for a simple consistent rule: if the user's semantic action executes, then the user's semantic action is responsible for cleaning up RHS semantic values... regardless of how the user's semantic action terminates.

I've also noticed that the bison documentation says:

  Note that in the future, Bison might also consider that right hand
  side members that are not mentioned in the action can be destroyed.

If this is implemented, I believe that it should be implemented consistently for all three cases: the user's semantic action completes successfully, it calls YYABORT, or it calls YYERROR.

What does everyone else think?


reply via email to

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