bug-bison
[Top][All Lists]
Advanced

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

Re: %destructor feedback


From: Joel E. Denny
Subject: Re: %destructor feedback
Date: Tue, 3 Jan 2006 02:45:20 -0500 (EST)

On Fri, 30 Dec 2005, Frank Heckenbach wrote:

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

If I read that right, the effect of your algorithm is close to the 
following:

1. $n for a RHS symbol is considered typed if declared so with, for 
example, %type.

2. $n for the return of a mid-rule is considered typed if that mid-rule 
references $$.

3. A warning is issued for any typed $n not referenced anywhere among the 
rules appearing to the right of it.

4. $$ in the final rule is considered typed if the LHS symbol is declared 
so with, for example, %type.

5. $$ in a mid-rule is considered typed if its corresponding $n is 
referenced anywhere among the rules appearing to the right of it.

6. A warning is issued for any unreferenced typed $$.

This makes sense to me.  However, I'd be satisfied with just 1, 3, 4, and 
6.

Joel





reply via email to

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