[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/16] all: prefer YYERRCODE to YYERROR
From: |
Akim Demaille |
Subject: |
[PATCH 06/16] all: prefer YYERRCODE to YYERROR |
Date: |
Sun, 26 Apr 2020 16:40:41 +0200 |
We will not keep YYERRCODE anyway, it causes backward compatibility
issues. So as a first step, let all the skeletons use that name,
until we have a better one.
* data/skeletons/bison.m4, data/skeletons/glr.c,
* data/skeletons/glr.cc, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java,
* data/skeletons/yacc.c, doc/bison.texi, tests/headers.at,
* tests/input.at:
here.
---
data/skeletons/bison.m4 | 2 +-
data/skeletons/glr.c | 6 +++---
data/skeletons/glr.cc | 8 ++++----
data/skeletons/lalr1.cc | 8 ++++----
data/skeletons/lalr1.d | 8 ++++----
data/skeletons/lalr1.java | 6 +++---
data/skeletons/yacc.c | 8 ++++----
doc/bison.texi | 4 ++--
src/parse-gram.c | 8 ++++----
tests/headers.at | 2 +-
tests/input.at | 2 +-
11 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index 33359f10..a7f45bf0 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -427,7 +427,7 @@ m4_define([b4_symbol_kind],
m4_case([$1],
[-2], [[YYEMPTY]],
[0], [[YYEOF]],
- [1], [[YYERROR]],
+ [1], [[YYERRCODE]],
[2], [[YYUNDEF]],
[m4_case(b4_symbol([$1], [tag]),
[$accept], [[YYACCEPT]],
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 5686e0b3..6b046349 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -2107,7 +2107,7 @@ yypcontext_expected_tokens (const yyGLRStack* yystackp,
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol_prefix[YYERROR
+ if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (!yyarg)
@@ -2365,8 +2365,8 @@ yyrecoverSyntaxError (yyGLRStack*
yystackp]b4_user_formals[)
int yyj = yypact[yys->yylrState];
if (! yypact_value_is_default (yyj))
{
- yyj += ]b4_symbol_prefix[YYERROR;
- if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] ==
]b4_symbol_prefix[YYERROR
+ yyj += ]b4_symbol(1, kind)[;
+ if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == ]b4_symbol(1, kind)[
&& yyisShiftAction (yytable[yyj]))
{
/* Shift the error token. */
diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc
index e931dd4b..b5f46ccd 100644
--- a/data/skeletons/glr.cc
+++ b/data/skeletons/glr.cc
@@ -354,10 +354,10 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
]m4_define([b4_declare_symbol_enum],
[[typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type
yysymbol_kind_t;
-#define ]b4_symbol_prefix[YYEMPTY
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
-#define ]b4_symbol_prefix[YYERROR
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYERROR
-#define ]b4_symbol_prefix[YYEOF
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
-#define ]b4_symbol_prefix[YYUNDEF
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
+#define ]b4_symbol_prefix[YYEMPTY
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
+#define ]b4_symbol_prefix[YYERRCODE
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYERRCODE
+#define ]b4_symbol_prefix[YYEOF
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
+#define ]b4_symbol_prefix[YYUNDEF
]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
]])[
]b4_percent_code_get([[provides]])[
]m4_popdef([b4_parse_param])dnl
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 93106d39..ca75acf3 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -1135,9 +1135,9 @@ b4_dollar_popdef])[]dnl
yyn = yypact_[+yystack_[0].state];
if (!yy_pact_value_is_default_ (yyn))
{
- yyn += symbol_kind::]b4_symbol_prefix[YYERROR;
+ yyn += symbol_kind::]b4_symbol(1, kind)[;
if (0 <= yyn && yyn <= yylast_
- && yycheck_[yyn] == symbol_kind::]b4_symbol_prefix[YYERROR)
+ && yycheck_[yyn] == symbol_kind::]b4_symbol(1, kind)[)
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -1251,7 +1251,7 @@ b4_dollar_popdef])[]dnl
for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
{
symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
- if (yysym != symbol_kind::]b4_symbol_prefix[YYERROR
+ if (yysym != symbol_kind::]b4_symbol(1, kind)[
&& yysym != symbol_kind::]b4_symbol_prefix[YYUNDEF
&& yyparser_.yy_lac_check_ (yysym))
{
@@ -1274,7 +1274,7 @@ b4_dollar_popdef])[]dnl
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck_[yyx + yyn] == yyx && yyx !=
symbol_kind::]b4_symbol_prefix[YYERROR
+ if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::]b4_symbol(1,
kind)[
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
{
if (!yyarg)
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d
index 85242b14..0569f3df 100644
--- a/data/skeletons/lalr1.d
+++ b/data/skeletons/lalr1.d
@@ -624,8 +624,8 @@ m4_popdef([b4_at_dollar])])dnl
yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
{
- yyn += SymbolKind.]b4_symbol_prefix[YYERROR;
- if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] ==
SymbolKind.]b4_symbol_prefix[YYERROR)
+ yyn += SymbolKind.]b4_symbol(1, kind)[;
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] ==
SymbolKind.]b4_symbol(1, kind)[)
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -731,14 +731,14 @@ m4_popdef([b4_at_dollar])])dnl
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
- if (yycheck_[x + yyn] == x && x !=
SymbolKind.]b4_symbol_prefix[YYERROR
+ if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol(1, kind)[
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
++count;
if (count < 5)
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
- if (yycheck_[x + yyn] == x && x !=
SymbolKind.]b4_symbol_prefix[YYERROR
+ if (yycheck_[x + yyn] == x && x != SymbolKind.]b4_symbol(1,
kind)[
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
{
res ~= count++ == 0 ? ", expecting " : " or ";
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index e4273895..bd19787b 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -733,9 +733,9 @@ b4_dollar_popdef[]dnl
yyn = yypact_[yystate];
if (!yyPactValueIsDefault (yyn))
{
- yyn += SymbolKind.]b4_symbol_prefix[YYERROR.getCode ();
+ yyn += SymbolKind.]b4_symbol(1, kind)[.getCode ();
if (0 <= yyn && yyn <= YYLAST_
- && yycheck_[yyn] ==
SymbolKind.]b4_symbol_prefix[YYERROR.getCode ())
+ && yycheck_[yyn] == SymbolKind.]b4_symbol(1,
kind)[.getCode ())
{
yyn = yytable_[yyn];
if (0 < yyn)
@@ -926,7 +926,7 @@ b4_dollar_popdef[]dnl
int yychecklim = YYLAST_ - yyn + 1;
int yyxend = yychecklim < NTOKENS ? yychecklim : NTOKENS;
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck_[yyx + yyn] == yyx && yyx !=
SymbolKind.]b4_symbol_prefix[YYERROR.getCode ()
+ if (yycheck_[yyx + yyn] == yyx && yyx != SymbolKind.]b4_symbol(1,
kind)[.getCode ()
&& !yyTableValueIsError (yytable_[yyx + yyn]))
{
if (yyarg == null)
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 20f84c7d..1ac8e9bc 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -1154,7 +1154,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
{
yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
- if (yysym != ]b4_symbol_prefix[YYERROR && yysym !=
]b4_symbol_prefix[YYUNDEF)
+ if (yysym != ]b4_symbol(1, kind)[ && yysym != ]b4_symbol_prefix[YYUNDEF)
switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes,
&yyps->yyes_capacity, yyps->yyssp, yysym]],
[[yyctx->yyesa, yyctx->yyes,
yyctx->yyes_capacity, yyctx->yyssp, yysym]])[))
{
@@ -1183,7 +1183,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol_prefix[YYERROR
+ if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (!yyarg)
@@ -2009,8 +2009,8 @@ yyerrlab1:
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
- yyn += ]b4_symbol_prefix[YYERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] ==
]b4_symbol_prefix[YYERROR)
+ yyn += ]b4_symbol(1, kind)[;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol(1,
kind)[)
{
yyn = yytable[yyn];
if (0 < yyn)
diff --git a/doc/bison.texi b/doc/bison.texi
index b8fe11bb..7fae3b36 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -7471,7 +7471,7 @@ enum yysymbol_kind_t
@{
YYSYMBOL_YYEMPTY = -2, /* No symbol. */
YYSYMBOL_YYEOF = 0, /* "end of file" */
- YYSYMBOL_YYERROR = 1, /* error */
+ YYSYMBOL_YYERRCODE = 1, /* error */
YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
YYSYMBOL_PLUS = 3, /* "+" */
YYSYMBOL_MINUS = 4, /* "-" */
@@ -7497,7 +7497,7 @@ The location of the syntax error (that of the unexpected
token).
@deftypefun int yypcontext_expected_tokens (@code{const yypcontext_t *}ctx,
@code{yysymbol_kind_t} @var{argv}@code{[]}, @code{int} @var{argc})
Fill @var{argv} with the expected tokens, which never includes
-@code{YYSYMBOL_YYEMPTY}, @code{YYSYMBOL_YYERROR}, or
+@code{YYSYMBOL_YYEMPTY}, @code{YYSYMBOL_YYERRCODE}, or
@code{YYSYMBOL_YYUNDEF}.
Never put more than @var{argc} elements into @var{argv}, and on success
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 3f5c7966..4c5ca366 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -106,7 +106,7 @@ enum yysymbol_kind_t
{
YYSYMBOL_YYEMPTY = -2,
YYSYMBOL_YYEOF = 0, /* "end of file" */
- YYSYMBOL_YYERROR = 1, /* error */
+ YYSYMBOL_YYERRCODE = 1, /* error */
YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
YYSYMBOL_STRING = 3, /* "string" */
YYSYMBOL_TSTRING = 4, /* "translatable string" */
@@ -1612,7 +1612,7 @@ yypcontext_expected_tokens (const yypcontext_t *yyctx,
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
{
yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
- if (yysym != YYSYMBOL_YYERROR && yysym != YYSYMBOL_YYUNDEF)
+ if (yysym != YYSYMBOL_YYERRCODE && yysym != YYSYMBOL_YYUNDEF)
switch (yy_lac (yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity,
yyctx->yyssp, yysym))
{
case YYENOMEM:
@@ -2695,8 +2695,8 @@ yyerrlab1:
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
- yyn += YYSYMBOL_YYERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYERROR)
+ yyn += YYSYMBOL_YYERRCODE;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYERRCODE)
{
yyn = yytable[yyn];
if (0 < yyn)
diff --git a/tests/headers.at b/tests/headers.at
index ebe02ee8..fa13819e 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -323,7 +323,7 @@ AT_PERL_CHECK([[-n -0777 -e '
|YYChar
|YYNTOKENS # This is actual scoped in a C++ class.
|YYPUSH_MORE(?:_DEFINED)?
- |S_(YY(ACCEPT|EMPTY|EOF|ERROR|UNDEF)) # These guys are scoped.
+ |S_(YY(ACCEPT|EMPTY|EOF|ERRCODE|UNDEF)) # These guys are scoped.
|YYUSE
|YY_ATTRIBUTE(?:_PURE|_UNUSED)
|YY(?:_REINTERPRET)?_CAST
diff --git a/tests/input.at b/tests/input.at
index f1cab823..27902d06 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -345,7 +345,7 @@ int main (void)
{
assert (YYERRCODE == 123);
assert (YYTRANSLATE (YYEOF) == YYSYMBOL_YYEOF);
- assert (YYTRANSLATE (YYERRCODE) == YYSYMBOL_YYERROR);
+ assert (YYTRANSLATE (YYERRCODE) == YYSYMBOL_YYERRCODE);
assert (YYTRANSLATE (YYUNDEF) == YYSYMBOL_YYUNDEF);
return 0;
}
--
2.26.2
- [PATCH 00/16] Returning the error token from the scanner does not trigger an error message, Akim Demaille, 2020/04/26
- [PATCH 07/16] c++: fix a few style issues, Akim Demaille, 2020/04/26
- [PATCH 03/16] style: glr.c: fix indentation issue, Akim Demaille, 2020/04/26
- [PATCH 04/16] style: prefer b4_has_translations_if, Akim Demaille, 2020/04/26
- [PATCH 02/16] style: fix a few remaining 'type' instead of 'kind', Akim Demaille, 2020/04/26
- [PATCH 01/16] skeletons: make the warning about implementation details clearer, Akim Demaille, 2020/04/26
- [PATCH 06/16] all: prefer YYERRCODE to YYERROR,
Akim Demaille <=
- [PATCH 08/16] c++: always define symbol_name, Akim Demaille, 2020/04/26
- [PATCH 09/16] c++: make valid to print the empty symbol, Akim Demaille, 2020/04/26
- [PATCH 11/16] examples: bistromathic: comment changes, Akim Demaille, 2020/04/26
- [PATCH 10/16] doc: hacking tricks, Akim Demaille, 2020/04/26
- [PATCH 05/16] style: glr.c: clarify, Akim Demaille, 2020/04/26
- [PATCH 13/16] examples: bistromathic: demonstrate error recovery, Akim Demaille, 2020/04/26
- [PATCH 12/16] examples: bistromathic: when quitting, close the current line, Akim Demaille, 2020/04/26
- [PATCH 15/16] all: don't emit an error message when the scanner returns YYERRCODE, Akim Demaille, 2020/04/26
- [PATCH 16/16] todo: update, Akim Demaille, 2020/04/26
- [PATCH 14/16] c: don't emit an error message when the scanner returns YYERRCODE, Akim Demaille, 2020/04/26