bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Factor %FLAG at scan level.


From: Joel E. Denny
Subject: Re: [PATCH] Factor %FLAG at scan level.
Date: Thu, 9 Apr 2009 00:45:56 -0400 (EDT)

On Wed, 8 Apr 2009, Akim Demaille wrote:

> > Even though that approach is
> > not actually possible, the user still has an opportunity to share code
> > between the two by specifying that %printer invoke operator<< instead.
> > If we make the symbol_type object directly accessible in %printer, the
> > user can even write a single %printer that invokes operator<< for all
> > symbols, which are specified by <*> and <>.
> 
> This would be a significant change of interface: %printer and %destructor work
> on the semantic value only, after the dispatch on the type, while symbol_type
> is the triple.

%printer and %destructor have access to $$ and @$.  The dispatch on symbol 
type effectively means they have access to the symbol type too.  If they 
have access to all the parts, why not give them access to the whole as 
well?

> And this is a nice feature IMHO, as it is modular: you don't
> have to write a single %printer which must handle the dispatching, so you
> would have to concentrate the code there.  Rather, it is scattered along the
> %type directives.

I'm not suggesting we change that.  I'm just suggesting that %printer also 
have access to the symbol_type object as well.  Otherwise, the user will 
have to put the parts together by constructing his own temporary 
symbol_type object in order to invoke operator<< from within %printer.

By the way, why "symbol_type"?  Why not just "symbol"?  Isn't the symbol 
type just one field of the triple?  Maybe I'm misunderstanding something 
fundamental.

> BTW, I'm using the attached script in my production parser to factor
> case-clauses that are equal.  I don't know if compilers do it by default, but
> I doubt they would all do it.  It would be nice from Bison to do it for us.

I agree.




reply via email to

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