parser: improve the error message for symbol class redefinition

Currently our error messages include both "symbol redeclared" and
"symbol redefined", and they mean something different.  This is
obscure, let's make this clearer.

I think the idea between 'definition' vs. 'declaration' is that in the
case of the nonterminals, the actual definition is its set of rules,
so %nterm would be about declaration.  The case of %token is less
clear.

* src/symtab.c (complain_class_redefined): New.
(symbol_class_set): Use it.
Simplify the logic of this function to clearly skip its body when the
preconditions are not met.
* tests/input.at (Symbol class redefinition): New.
This commit is contained in:
Akim Demaille
2018-12-09 08:14:35 +01:00
parent afdefecab6
commit 20b0746793
3 changed files with 74 additions and 18 deletions

5
TODO
View File

@@ -7,6 +7,11 @@ Several features are not available in all the backends.
- token constructors: Java and C
* Short term
** consistency
nonterminal vs non terminal vs non-terminal
token vs terminal
redeclaration vs redefinition
** yacc.c
Now that ylwrap is fixed, we should include foo.tab.h from foo.tab.c rather
than duplicating it.