bison-patches
[Top][All Lists]
Advanced

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

Re: no-default-precedence


From: Paul Eggert
Subject: Re: no-default-precedence
Date: 15 May 2003 12:49:36 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

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 assume you know the procedure; not, please let me know and
I'll send you instructions separately.

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

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 '*';

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




reply via email to

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