[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/13] c: use yysymbol_name in traces
From: |
Akim Demaille |
Subject: |
[PATCH 02/13] c: use yysymbol_name in traces |
Date: |
Sat, 18 Jan 2020 16:40:01 +0100 |
Only parse.error verbose and simple will get the original yytname: the
other options will rely on a different table. So let's move on top of
the yysymbol_name function.
* data/skeletons/c.m4 (yy_symbol_print): Use yysymbol_name.
* data/skeletons/glr.c (yytokenName): Rename as...
(yysymbol_name): this.
The change of naming scheme is unfortunate, but it's definitely glr.c
which is "wrong".
---
data/skeletons/c.m4 | 2 +-
data/skeletons/glr.c | 14 +++++++-------
src/parse-gram.c | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 0987ef77..c98bed1a 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -662,7 +662,7 @@ b4_locations_if([, [[YYLTYPE const * const yylocationp],
[yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
YYFPRINTF (yyo, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
+ yytype < YYNTOKENS ? "token" : "nterm", yysymbol_name (yytype));
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
YYFPRINTF (yyo, ": ");
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index cf6b1d8a..98b3f1e2 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -693,7 +693,7 @@ yyMemoryExhausted (yyGLRStack* yystackp)
#if ]b4_error_verbose_if([[1]], [b4_api_PREFIX[DEBUG]])[
/** A printable representation of TOKEN. */
static inline const char*
-yytokenName (yySymbol yytoken)
+yysymbol_name (yySymbol yytoken)
{
return yytoken == YYEMPTY ? "" : yytname[yytoken];
}
@@ -1738,11 +1738,11 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
if (yyx->yystate->yyposn < yys->yyposn + 1)
YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, empty>\n",
- yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
+ yyindent, "", yysymbol_name (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1));
else
YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
- yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
+ yyindent, "", yysymbol_name (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1, YY_CAST (long, yys->yyposn + 1),
YY_CAST (long, yyx->yystate->yyposn)));
for (yyi = 1; yyi <= yynrhs; yyi += 1)
@@ -1751,10 +1751,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
{
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
YY_FPRINTF ((stderr, "%*s%s <empty>\n", yyindent+2, "",
- yytokenName (yystos[yystates[yyi]->yylrState])));
+ yysymbol_name (yystos[yystates[yyi]->yylrState])));
else
YY_FPRINTF ((stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
- yytokenName (yystos[yystates[yyi]->yylrState]),
+ yysymbol_name (yystos[yystates[yyi]->yylrState]),
YY_CAST (long, yystates[yyi-1]->yyposn + 1),
YY_CAST (long, yystates[yyi]->yyposn)));
}
@@ -2111,7 +2111,7 @@ yyreportSyntaxError (yyGLRStack*
yystackp]b4_user_formals[)
if (yytoken != YYEMPTY)
{
int yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
- yyarg[yycount++] = yytokenName (yytoken);
+ yyarg[yycount++] = yysymbol_name (yytoken);
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
@@ -2131,7 +2131,7 @@ yyreportSyntaxError (yyGLRStack*
yystackp]b4_user_formals[)
yycount = 1;
break;
}
- yyarg[yycount++] = yytokenName (yyx);
+ yyarg[yycount++] = yysymbol_name (yyx);
}
}
}
diff --git a/src/parse-gram.c b/src/parse-gram.c
index ab4eeea7..00b4b545 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1121,7 +1121,7 @@ static void
yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep,
YYLTYPE const * const yylocationp)
{
YYFPRINTF (yyo, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
+ yytype < YYNTOKENS ? "token" : "nterm", yysymbol_name (yytype));
YY_LOCATION_PRINT (yyo, *yylocationp);
YYFPRINTF (yyo, ": ");
--
2.24.1
- [PATCH 00/13] Better error messages, Akim Demaille, 2020/01/18
- [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 <=
- [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
- [PATCH 10/13] parsers: support translatable token aliases, Akim Demaille, 2020/01/18
- [PATCH 12/13] tests: check token internationalization, Akim Demaille, 2020/01/18