[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
yacc.c: introduce yysymbol_name
From: |
Akim Demaille |
Subject: |
yacc.c: introduce yysymbol_name |
Date: |
Sat, 11 Jan 2020 16:15:26 +0100 |
commit 46cce832fd797e7cd8e4124bd35c7ea4435d3b90
Author: Akim Demaille <address@hidden>
Date: Sat Jan 11 11:43:13 2020 +0100
yacc.c: introduce yysymbol_name
Provide the users with a public API to get the name of the tokens. A
thin wrapper around yytname.
* data/skeletons/yacc.c (yysymbol_name): New.
Use it.
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 6143f96d..6093ee79 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -609,6 +609,15 @@ static const char *const yytname[] =
{
]b4_tname[
};
+
+/* The user-facing name of the symbol whose (internal) number is
+ YYSYMBOL. No bounds checking. */
+static const char *yysymbol_name (int yysymbol) YY_ATTRIBUTE_UNUSED;
+static const char *
+yysymbol_name (int yysymbol)
+{
+ return yytname[yysymbol];
+}
#endif
# ifdef YYPRINT
@@ -885,7 +894,7 @@ do {
\
{ \
YYDPRINTF ((stderr, \
"LAC: initial context established for %s\n", \
- yytname[yytoken])); \
+ yysymbol_name(yytoken))); \
yy_lac_established = 1; \
{ \
int yy_lac_status = \
@@ -937,7 +946,7 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
{
yy_state_t *yyes_prev = yyssp;
yy_state_t *yyesp = yyes_prev;
- YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken]));
+ YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name(yytoken)));
if (yytoken == YYUNDEFTOK)
{
YYDPRINTF ((stderr, " Always Err\n"));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- yacc.c: introduce yysymbol_name,
Akim Demaille <=