mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
gram: correct token numbering in precedence declarations
In a precedence declaration, when tokens are declared with a litteral character (e.g., 'a') or with a identifier (e.g., B), Bison behaved differently: the litteral tokens would be numbered first, and then the other ones, leading to the following grammar: %right A B 'c' 'd' being numbered as such: 'c' 'd' A B. * src/parse-gram.y (symbol.prec): Set the symbol number when reading the symbols. * tests/conflicts.at (Token declaration order: literals vs. identifiers): New. Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
committed by
Akim Demaille
parent
02879b4e81
commit
5202b6ac1d
24
NEWS
24
NEWS
@@ -284,11 +284,27 @@ GNU Bison NEWS
|
||||
It used to be an error only if used in non GLR mode, _and_ if there are
|
||||
reduce/reduce conflicts.
|
||||
|
||||
** Token numbering has changed to preserve the user-defined order
|
||||
** Tokens are numbered in their order of appearance
|
||||
|
||||
When declaring %token A B, the numbering for A is inferior to B. Up to now,
|
||||
when declaring associativity at the same time, with %left (or %right,
|
||||
%precedence, %nonassoc), B was inferior to A.
|
||||
Contributed by Valentin Tolmer.
|
||||
|
||||
With '%token A B', A had a number less than the one of B. However,
|
||||
precedence declarations used to generate a reversed order. This is now
|
||||
fixed, and introducing tokens with any of %token, %left, %right,
|
||||
%precedence, or %nonassoc yields the same result.
|
||||
|
||||
When mixing declarations of tokens with a litteral character (e.g., 'a')
|
||||
or with an identifier (e.g., B) in a precedence declaration, Bison
|
||||
numbered the litteral characters first. For example
|
||||
|
||||
%right A B 'c' 'd'
|
||||
|
||||
would lead to the tokens declared in this order: 'c' 'd' A B. Again, the
|
||||
input order is now preserved.
|
||||
|
||||
These changes were made so that one can remove useless precedence and
|
||||
associativity declarations (i.e., map %nonassoc, %left or %right to
|
||||
%precedence, or to %token) and get exactly the same output.
|
||||
|
||||
** Useless precedence and associativity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user