[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no $$ in %destructor = no unset value warnings?
From: |
Joel E. Denny |
Subject: |
Re: no $$ in %destructor = no unset value warnings? |
Date: |
Sat, 21 Oct 2006 14:56:41 -0400 (EDT) |
On Thu, 14 Sep 2006, Joel E. Denny wrote:
> On Thu, 14 Sep 2006, Akim Demaille wrote:
>
> > It is inconsistent, you are right, but I would have chosen the other
> > possibility: just like we invite users to YYUSE (or whatever the
> > macro) in rule actions, we should do that in destructors and printers.
> > Not because it is always wrong not to use the value, but because it's
> > always possibly an error.
I'm thinking of implementing this warning for no $$ in %destructor or
%printer.
> I was thinking of a user-defined YYSTYPE (no %union) with no <...> usage.
> In this case, Bison would have no idea what symbols truly have semantic
> values. So, I think we need the ability to remove the destructor for
> specific symbols. There might even be cases where nearly all symbols of a
> particular type need a destructor, but a few don't. Finally, I still like
> the idea of a %destructor that doesn't access $$ but perhaps just prints a
> message, and I don't think Bison should warn about rules that don't use
> such a $$/$n.
I still agree with the above.
> You once discussed the possibility of named semantic values in grammar
> rules:
>
> exp(sum): exp(term1) '+' exp(term2) {
> $sum = $term1 + $term2
> }
>
> And instead of USE($1), you suggested empty parens, for which I still
> prefer (!). I think empty parens make a nice default value name:
>
> grammar(): defs() rules() epilogue(!) {
> $grammar = new_grammar( $defs, $rules );
> }
I don't plan on implementing the above any time soon...
> Maybe something similar is useful with %destructor/%printer:
>
> %destructor(!) { printf ("A SYM was discarded.\n"); } SYM
>
> Because the user has explicitly declared that SYM does not need to destroy
> its value, Bison would not warn about unused SYM values in %destructor or
> semantic actions.
... but I'm thinking about implementing this now as a solution to the
issues I discussed at the top of this email. Before I get too far into
this, what do people think?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: no $$ in %destructor = no unset value warnings?,
Joel E. Denny <=