bison-patches
[Top][All Lists]
Advanced

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

Re: FYI: default %printer/%destructor


From: Hans Aberg
Subject: Re: FYI: default %printer/%destructor
Date: Fri, 24 Nov 2006 21:35:15 +0100

On 24 Nov 2006, at 20:49, Joel E. Denny wrote:

What about default names?

Another problem is that all existing grammars would implicitly declare all
values to be unused even when they're not.  For example:

  exp: exp '+' exp { $$ = $1; } ;

There's no warning about $3.

You would need a rule telling, in the case of multiple occurrences, when the default names can be used. One rule could be that only the leftmost occurrence gets the default. So the above could be written
  exp: exp '+' exp { $exp = $1; };
Or if the LHS does not get a default name:
  exp: exp '+' exp { $$ = $exp; };
Alternatively, if there are multiple occurrences, none can be used.

Write the rule above properly:
  exp: exp '+' exp { $$ = $1 + $3; };
with alternate forms (depending on which defulat rule used):
  exp: exp '+' exp { $exp = $1 + $3; };
  exp: exp '+' exp { $$ = $exp + $3; };
Perhaps these forms are confusing: then none should be usable.

As for warnings: isn't best to treat it as compiler options? After all, tokens can produce values as well. If one worries about unused variables, one could turn these options temporarily on.

  Hans Aberg






reply via email to

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