[Top][All Lists]

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

Re: %destructor feedback

From: Akim Demaille
Subject: Re: %destructor feedback
Date: Thu, 20 Oct 2005 15:32:14 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

>>> "Joel" == Joel E Denny <address@hidden> writes:

 > 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.

That's also what I had in mind when I first implemented this, but
since Paul's changes, that's no longer what happens in yacc.c.  I tend
to think that usually, when an error is found, you will most probably
get rid of all the RHS, so "let bison do it" seems the right default
value.  It is for YYACCEPT that I find it weird.  But the full
symmetry has value too.

 > 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 copied this idea from Lemon, another parser generator.  But there's
a huge difference bw Lemon and Bison: the latter is bound by the past,
including that thingy called PO(*#&$(*#$SIX Yacc.  And in that
tradition, no action means $$ = $1;.  So that would mean free everyone
but $1?  Gee, not beautiful.  I still dunno how to do that nicely.
Also, we have that "nice" feature: $-1 etc.  and I have not sorted out
all the details.

Maybe that does not deserve that much attention: it seems pretty weird
not to use a value.  A warning seems a better feature.

 > 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?

In the present case, I was thinking about clearing even before running
the user action, so that would not matter.  Or rather, it would be

reply via email to

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