[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 00/13] Better error messages
From: |
Akim Demaille |
Subject: |
[PATCH 00/13] Better error messages |
Date: |
Sat, 18 Jan 2020 16:39:59 +0100 |
This series of patches builds on top of the previous one
(https://lists.gnu.org/r/bison-patches/2020-01/msg00044.html). It
brings the following features with parse.error=custom or detailed
(which I prefer to my previous proposal, 'rich').
Comments and feedback would be most useful. It is again also
available on Savannah, and here:
https://github.com/akimd/bison/pull/22.
1. Faithfulness
The token strings are no longer doubly-quoted, and no longer depend on
the current locale. So for instance
%token MAXWELL "ββΓπΈβ = -βπ΅β/βt"
gives with an UTF-8 able locale
static const char *const yytname[] =
{
"$end", "error", "$undefined", "\"ββΓπΈβ = -βπ΅β/βt\"",
"$accept", "e", YY_NULLPTR
};
With the C locale, you get
static const char *const yytname[] =
{
"$end", "error", "$undefined",
"\"\\342\\210\\207\\342\\203\\227\\303\\227\\360\\235\\220\\270\\342\\203\\227
= -\\342\\210\\202\\360\\235\\220\\265\\342\\203\\227/\\342\\210\\202t\"",
"$accept", "e", YY_NULLPTR
};
With custom/detailed, you always get
static const char *const yy_sname[] =
{
"$end", "error", "$undefined", "ββΓπΈβ = -βπ΅β/βt",
"$accept", "e", YY_NULLPTR
};
2. Internationalization
Token aliases can be (selectively) translated. For instance in the
gramnar file
%token NUMBER _("number")
in which case the yysymbol_name function returns _("number") instead
of "number". It is the user responsibility to define a _ function
(and N_).
data/skeletons/bison.m4 | 13 +-
data/skeletons/c.m4 | 2 +-
data/skeletons/glr.c | 126 ++++----
data/skeletons/yacc.c | 55 +++-
src/output.c | 89 +++++-
src/parse-gram.c | 657 +++++++++++++++++++---------------------
src/parse-gram.h | 131 ++++----
src/parse-gram.y | 28 +-
src/scan-gram.l | 25 +-
src/symtab.c | 3 +-
src/symtab.h | 7 +-
tests/calc.at | 77 +++--
tests/local.at | 5 +-
tests/regression.at | 24 +-
14 files changed, 691 insertions(+), 551 deletions(-)
--
2.24.1
- [PATCH 00/13] Better error messages,
Akim Demaille <=
- [PATCH 01/13] glr.c: move some functions after the definition of types, Akim Demaille, 2020/01/18
- [PATCH 02/13] c: use yysymbol_name in traces, Akim Demaille, 2020/01/18
- [PATCH 03/13] yacc.c: add support for parse.error detailed, Akim Demaille, 2020/01/18
- [PATCH 04/13] yacc.c: tests: check detailed error messages, Akim Demaille, 2020/01/18
- [PATCH 05/13] regen, Akim Demaille, 2020/01/18
- [PATCH 06/13] bison: use detailed error messages, Akim Demaille, 2020/01/18
- [PATCH 07/13] regen, Akim Demaille, 2020/01/18
- [PATCH 09/13] tests: check that detailed error messages preserve UTF-8 characters, Akim Demaille, 2020/01/18
- [PATCH 08/13] yacc.c: escape trigraphs in detailed parse.error, Akim Demaille, 2020/01/18