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:
Valentin Tolmer
2013-03-05 12:29:50 +01:00
committed by Akim Demaille
parent 02879b4e81
commit 5202b6ac1d
3 changed files with 117 additions and 6 deletions

View File

@@ -503,8 +503,17 @@ symbols.prec:
;
symbol.prec:
symbol { $$ = $1; }
| symbol INT { $$ = $1; symbol_user_token_number_set ($1, $2, @2); }
symbol
{
$$ = $1;
symbol_class_set ($1, token_sym, @1, false);
}
| symbol INT
{
$$ = $1;
symbol_user_token_number_set ($1, $2, @2);
symbol_class_set ($1, token_sym, @1, false);
}
;
/* One or more symbols to be %typed. */