bison-patches
[Top][All Lists]
Advanced

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

Re: FYI: default %printer/%destructor


From: Joel E. Denny
Subject: Re: FYI: default %printer/%destructor
Date: Thu, 14 Sep 2006 21:22:10 -0400 (EDT)

On Thu, 14 Sep 2006, Akim Demaille wrote:

> Or better yet (?), no %symbol-default, but:
> 
>   %printer { cerr << @$ << ": " << $$; } <*>

So, this means all symbols with types, right?  I was actually thinking of 
this syntax before %symbol-default, but then I rejected it because I 
couldn't figure out what to do about type-less symbols....

>   %printer { cerr << @$; } <->

I like this.  Small difference though: what about <!>?  In my mind, "!" = 
"not", and it looks slightly odd, which is what we mean to imply, I think.

In the case of no %union and no <...> usage (that is, the user defines his 
own YYSTYPE or uses the default int), are all symbols considered typed or 
untyped?  That is, does <*> or <!> apply?  I'm leaning toward untyped and 
<!>.  That way, when you refactor the last <...> out of your grammar, the 
<!> %destructor won't suddenly quit applying to all other grammar symbols. 
So maybe <*> means tagged symbols and <!> means tagless symbols (rather 
than typed and untyped since someone might argue that all symbols are 
typed with #define YYSTYPE int).

Bison would warn about no $$ in:

  %printer { cerr << @$; } <!>

because these symbols might actually have values.  But this would be fine:

  %printer(!) { cerr << @$; } <!>

I talk about (!) in the `no $$ in %destructor = no unset value warnings?' 
thread.

By the way, currently, the default destructor applies to midrule values.  
I think it should only apply to midrule values for which $$ is actually 
used.  I don't think even <!> should apply if $$ isn't used in this case.  
That is, when $$ isn't used, not only does the midrule not have a type, it 
doesn't even have a value; it's just a midrule.




reply via email to

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