[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/21] yacc.c: prefer YYSYMBOL_YYERROR to YYSYMBOL_error
From: |
Akim Demaille |
Subject: |
[PATCH 07/21] yacc.c: prefer YYSYMBOL_YYERROR to YYSYMBOL_error |
Date: |
Wed, 1 Apr 2020 08:37:33 +0200 |
* data/skeletons/bison.m4 (b4_symbol_sid): Map "error" to YYSYMBOL_YYERROR.
* data/skeletons/yacc.c: Adjust.
---
TODO | 16 ----------------
data/skeletons/bison.m4 | 7 ++++---
data/skeletons/yacc.c | 8 ++++----
3 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/TODO b/TODO
index e417fdb3..f314682a 100644
--- a/TODO
+++ b/TODO
@@ -53,22 +53,6 @@ would actually also make the following point gracefully
handled (status of
YYERRCODE, YYUNDEFTOK, etc.). Possibly we could also define YYEMPTY (twice:
as a token and as a symbol). And YYEOF.
-It seems to work well. Yet we have a weird case: the "error" token:
-
-enum yysymbol_type_t
-{
- YYSYMBOL_YYEMPTY = -2,
- YYSYMBOL_YYEOF = 0,
- YYSYMBOL_error = 1,
- YYSYMBOL_YYUNDEF = 2,
- YYSYMBOL_YYACCEPT = 61,
- ...
-
-YYSYMBOL_error looks weird. We should maybe rename this as
-"YYSYMBOL_YYERROR", even though it should not be confonded with the YYERROR
-macro.
-
-
** Consistency
YYUNDEFTOK is an internal symbol number, as YYTERROR.
But YYERRCODE is an external token number.
diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index 20de1b7e..d54ea2b7 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -413,9 +413,10 @@ m4_define([b4_symbol_sid],
[m4_case([$1],
[-2], [[YYSYMBOL_YYEMPTY]],
[0], [[YYSYMBOL_YYEOF]],
- [m4_bmatch(m4_quote(b4_symbol([$1], [tag])),
- [^\$accept$], [[YYSYMBOL_YYACCEPT]],
- [^\$undefined$], [[YYSYMBOL_YYUNDEF]],
+ [m4_case(m4_quote(b4_symbol([$1], [tag])),
+ [$accept], [[YYSYMBOL_YYACCEPT]],
+ [error], [[YYSYMBOL_YYERROR]],
+ [$undefined], [[YYSYMBOL_YYUNDEF]],
[m4_quote(b4_symbol_if([$1], [has_id],
[[YYSYMBOL_]]m4_quote(_b4_symbol([$1],
[id]))))])])])
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 5c5a3964..d9ded757 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -1147,7 +1147,7 @@ yyexpected_tokens (const yyparse_context_t *yyctx,
]b4_lac_if([[
int yyx;
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
- if (yyx != YYSYMBOL_error && yyx != YYSYMBOL_YYUNDEF)
+ if (yyx != YYSYMBOL_YYERROR && yyx != YYSYMBOL_YYUNDEF)
switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes,
&yyps->yyes_capacity, yyps->yyssp, yyx]],
[[yyctx->yyesa, yyctx->yyes,
yyctx->yyes_capacity, yyctx->yyssp, yyx]])[))
{
@@ -1175,7 +1175,7 @@ yyexpected_tokens (const yyparse_context_t *yyctx,
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_error
+ if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (!yyarg)
@@ -1998,8 +1998,8 @@ yyerrlab1:
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
- yyn += YYSYMBOL_error;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_error)
+ yyn += YYSYMBOL_YYERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
--
2.26.0
- [PATCH 00/21] Use, Akim Demaille, 2020/04/01
- [PATCH 01/21] style: comment changes about token numbers, Akim Demaille, 2020/04/01
- [PATCH 02/21] yacc.c: introduce an enum that defines the symbol's number, Akim Demaille, 2020/04/01
- [PATCH 04/21] yacc.c: use yysymbol_type_t instead of int for yytoken, Akim Demaille, 2020/04/01
- [PATCH 03/21] regen, Akim Demaille, 2020/04/01
- [PATCH 06/21] regen, Akim Demaille, 2020/04/01
- [PATCH 05/21] yacc.c: also define a symbol number for the empty token, Akim Demaille, 2020/04/01
- [PATCH 08/21] regen, Akim Demaille, 2020/04/01
- [PATCH 07/21] yacc.c: prefer YYSYMBOL_YYERROR to YYSYMBOL_error,
Akim Demaille <=
- [PATCH 09/21] bistromathic: use symbol numbers instead of YYTRANSLATE, Akim Demaille, 2020/04/01
- [PATCH 11/21] regen, Akim Demaille, 2020/04/01
- [PATCH 10/21] yysymbol_type_t: always assign an enumerator, Akim Demaille, 2020/04/01
- [PATCH 12/21] yacc.c: revert to not using yysymbol_type_t in the yytranslate table, Akim Demaille, 2020/04/01
- [PATCH 13/21] regen, Akim Demaille, 2020/04/01
- [PATCH 14/21] yacc.c: fix more errors from make maintainer-check-g++, Akim Demaille, 2020/04/01
- [PATCH 15/21] regen, Akim Demaille, 2020/04/01
- [PATCH 16/21] glr.c: use yysymbol_type_t, YYSYMBOL_YYEOF etc., Akim Demaille, 2020/04/01
- [PATCH 18/21] regen, Akim Demaille, 2020/04/01
- [PATCH 17/21] glr.c, yacc.c: propagate yysymbol_type_t, Akim Demaille, 2020/04/01