[Top][All Lists]

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

Re: %destructor feedback

From: Frank Heckenbach
Subject: Re: %destructor feedback
Date: Fri, 30 Dec 2005 02:58:51 +0100
User-agent: semail 20050409

Akim Demaille wrote:

> Le 27 déc. 05 à 18:46, Akim Demaille a écrit :
> > Le 22 déc. 05 à 19:49, Joel E. Denny a écrit :
> >
> >> Would it be worthwhile to warn about unmentioned typed $$ as well?
> >
> > The correct handling of $$ is troublesome when there are midrule
> > actions.
> More generally, what exactly do we want in case of midrule actions?
> Say (every symbol is typed):
>       exp: A { act1 } B { act2 } { action };
> should act1 complain about not using $1?

I don't think so. $1 might be used by act2 or action which we don't
know at this point.

> But what about its $$,
> which is its actual value.  We can't do anything about it, we
> don't know its type.

Bison could remember whether it is mentioned (assuming it's in an
assignment), and if so, warn later if $2 is never used.

> should act2 complain about $1 even if act1 uses it?

Again, I don't think so. If act1 uses $1, and act2 doesn't, this
seems fine.

> Finally, should action warn about $$, $1, and $3 even if they were
> used in midrule actions?

For $1 and $3 I don't think so. For $$ (assuming the target symbol
is typed), I think it should warn if not mentioned, as $$ in the
mid-rule actions refers to something different.

Of course, I'm saying this all without much knowledge of the actual
implementation. Perhaps the following approach would work:

- For each $n and $$ have two flags, `set' and `used'. All flags are
  initialized false.

- For $n with a typed symbol, the corresponding `set' flag becomes

- If the target symbol of the rule is typed, the `used' flag for $$
  becomes true.

- Special case for the implicit action: If there is no action, and
  $1 and $$ are typed, `set' for $$ and `used' for $1 become true.

- When $$ is mentioned in an action, the corresponding `set' flag
  (for $n in a mid-rule action, for $$ otherwise) becomes true.

- When $n is mentioned in an action, the corresponding `used' flag
  becomes true.

- At the end of a rule, for each $n or $$ for which exactly one of
  `set' and `used' is true, emit a warning. (Though AFAICS the case
  that `set' is false and `used' is true can only happen using
  $<...>, or when using a single YYSTYPE, not `%union'; otherwise
  Bison's type-checking would catch it already.)


Frank Heckenbach, address@hidden
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)

reply via email to

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