diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2018-12-13 08:19:54 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2018-12-14 05:10:18 +0100 |
commit | aadf6c0bf355359c7cee6e69d80a4b9c8ab91340 (patch) | |
tree | eebf1bed6d4edf86e4391505668d4b4c41337406 /src/symtab.c | |
parent | dbb855895fbafe5226b3ac607eee4b22837c7ff7 (diff) | |
download | bison-aadf6c0bf355359c7cee6e69d80a4b9c8ab91340.tar.gz |
parser: reprecate %nterm back
After having spent quite some time on cleaning the handling of symbol
declarations in the grammar files, I believe we should keep it.
It looks like it's a duplicate of %type, but it is not. While POSIX
Yacc requires %type to apply only to nonterminal symbols, it appears
that both byacc and bison accept it for tokens too. And some
experienced users do actually expect this feature to group
symbols (terminal or not) by type ("On the other hand, it is generally
more useful IMHO to group terminals and non-terminals with the same
type tag together",
http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00000.html).
Even Bison's own parser does this today (see CHAR).
Basically reverts 7928c3e6fbdf47ff81184966cee937e6aa694b94.
* src/scan-gram.l (%nterm): Dedeprecate, but issue a Wyacc warning.
* tests/input.at: Adjust expectations.
(Yacc warnings on symbols): New.
* src/symtab.c (symbol_class_set): Fix error introduced in
20b07467938cf880a1d30eb30d6e191843a21fec.
Diffstat (limited to 'src/symtab.c')
-rw-r--r-- | src/symtab.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/symtab.c b/src/symtab.c index 0caf063a..7bc604b7 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -450,12 +450,11 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring) complain_class_redeclared (sym, class, loc); else { - s->class = class; - if (class == nterm_sym && s->class != nterm_sym) s->number = nvars++; else if (class == token_sym && s->number == NUMBER_UNDEFINED) s->number = ntokens++; + s->class = class; if (declaring) { |