diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-09-30 08:45:50 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-10-06 09:54:25 +0200 |
commit | 126c4622de27197bbe4c6a713f28d114839e636f (patch) | |
tree | f6d5ee9aba84bd5ae9400719550fec3bc14ccaef /src | |
parent | dd64eaf9db2833af8e8c3a0637b5c47de58a640c (diff) | |
download | bison-126c4622de27197bbe4c6a713f28d114839e636f.tar.gz |
style: isolate complain_symbol_undeclared
* src/symtab.c (complain_symbol_undeclared): New.
Use it.
Use quote on the guilty symbol (like GCC does, and we also do
elsewhere).
* tests/input.at: Adjust.
Diffstat (limited to 'src')
-rw-r--r-- | src/symtab.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/symtab.c b/src/symtab.c index 1e28dd4c..c7d308ac 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -27,7 +27,11 @@ #include <hash.h> #include "complain.h" +#include "getargs.h" #include "gram.h" +#include "quote.h" + + /*----------------------------------------------------------------. | Symbols sorted by tag. Allocated by table_sort, after which no | @@ -317,6 +321,16 @@ complain_class_redeclared (symbol *sym, symbol_class class, location second) } } +static void +complain_symbol_undeclared (symbol *sym) +{ + assert (sym->content->status != declared); + complain (&sym->location, + sym->content->status == needed ? complaint : Wother, + _("symbol %s is used, but is not defined as a token" + " and has no rules"), + quote (sym->tag)); +} void symbol_location_as_lhs_set (symbol *sym, location loc) @@ -520,12 +534,7 @@ symbol_check_defined (symbol *sym) sym_content *s = sym->content; if (s->class == unknown_sym) { - assert (s->status != declared); - complain (&sym->location, - s->status == needed ? complaint : Wother, - _("symbol %s is used, but is not defined as a token" - " and has no rules"), - sym->tag); + complain_symbol_undeclared (sym); s->class = nterm_sym; s->number = nvars++; } |