bison-patches
[Top][All Lists]
Advanced

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

Re: no-default-precedence


From: Frank Heckenbach
Subject: Re: no-default-precedence
Date: Fri, 16 May 2003 05:42:25 +0200

Paul Eggert wrote:

> Frank Heckenbach <address@hidden> writes:
> 
> > This patch implements a feature I suggested in a discussion in
> > bug-bison (Subject: Controlling the effects of precedence
> > declarations), to not assign precedence to rules which have no
> > explicit `%prec' declaration, even if the last terminal symbol
> > mentioned in their components has a declared precedence, so one can
> > control more precisely which rules should have a precedence.
> 
> Thanks for the patch and for the discussion.  For a change on this
> order, we'll need to have you sign copyright assignment papers for
> Bison.

I had assumed it was small enough not to require one, but no
problem.

> I assume you know the procedure; not, please let me know and
> I'll send you instructions separately.

I know the procedure, but I don't have the forms and the pointers on
www.gnu.org don't seem to work, so please send them ...

> Since we already have %prec, it might be better to be consistent and
> call the new symbol %default-prec, not %default-precedence.

OK.

> Can you see the use for some easily-implemented generalizations of
> your idea?  For example, suppose part of the grammar has no default
> precedence, but part of the grammar has a default.  Perhaps the
> grammar is the result of a collaboration between two people with
> different opinions; or perhaps it simply makes more technical sense to
> have a default in the "expression" part of the grammar, but not in the
> "statement" part.
> 
> Perhaps it would be better to have a directive like this:
> 
> %default-prec 0  // this means no default precedence
> %default-prec 1  // this means use the last terminal's precedence (the 
> default)
> %default-prec SYMBOL // this means the default precedence is that of SYMBOL
> 
> and allow you to intersperse this directive with the grammar.  So:
> 
>    %default-prec '*';
>    a: b c;
>    %default-prec 1
> 
> would be equivalent to (though more wordy than):
> 
>    a: b c %prec '*';

Agreed to the 0/1 part. I'm not convinced whether SYMBOL is useful
(does one regularly have a bunch of rules which should all get the
same precedence which is not that of a terminal in those rules?), so
I haven't implemented this yet (but, of course, the syntax allows
for such an extension in the future).

> > +You might prefer to explicitly specify the precedence of all rules
> > +that need one.  Then you will see any shift/reduce conflict until
> > +you tell Bison how to resolve it (by changing your grammar or adding
> > +an explicit precedence).
> 
> This needs a motivating example.
>
> > +  PERCENT_NO_DEF_PREC   "%no-default-precedence"
> 
> The PERCENT name should not abbreviate.
>
> > +/* Nonzero if %no-default-precedence was specified.  */
> > +int no_default_precedence = 0;
> 
> This should be bool, not int.  (Though this will change if the above
> suggestions are adopted.)

OK.

Frank

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

Attachment: bison-20030320.diff-no-default-prec
Description: Binary data


reply via email to

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