mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
yacc.c: prefer YYSYMBOL_YYERROR to YYSYMBOL_error
* data/skeletons/bison.m4 (b4_symbol_sid): Map "error" to YYSYMBOL_YYERROR. * data/skeletons/yacc.c: Adjust.
This commit is contained in:
16
TODO
16
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:
|
YYERRCODE, YYUNDEFTOK, etc.). Possibly we could also define YYEMPTY (twice:
|
||||||
as a token and as a symbol). And YYEOF.
|
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
|
** Consistency
|
||||||
YYUNDEFTOK is an internal symbol number, as YYTERROR.
|
YYUNDEFTOK is an internal symbol number, as YYTERROR.
|
||||||
But YYERRCODE is an external token number.
|
But YYERRCODE is an external token number.
|
||||||
|
|||||||
@@ -413,9 +413,10 @@ m4_define([b4_symbol_sid],
|
|||||||
[m4_case([$1],
|
[m4_case([$1],
|
||||||
[-2], [[YYSYMBOL_YYEMPTY]],
|
[-2], [[YYSYMBOL_YYEMPTY]],
|
||||||
[0], [[YYSYMBOL_YYEOF]],
|
[0], [[YYSYMBOL_YYEOF]],
|
||||||
[m4_bmatch(m4_quote(b4_symbol([$1], [tag])),
|
[m4_case(m4_quote(b4_symbol([$1], [tag])),
|
||||||
[^\$accept$], [[YYSYMBOL_YYACCEPT]],
|
[$accept], [[YYSYMBOL_YYACCEPT]],
|
||||||
[^\$undefined$], [[YYSYMBOL_YYUNDEF]],
|
[error], [[YYSYMBOL_YYERROR]],
|
||||||
|
[$undefined], [[YYSYMBOL_YYUNDEF]],
|
||||||
[m4_quote(b4_symbol_if([$1], [has_id],
|
[m4_quote(b4_symbol_if([$1], [has_id],
|
||||||
[[YYSYMBOL_]]m4_quote(_b4_symbol([$1], [id]))))])])])
|
[[YYSYMBOL_]]m4_quote(_b4_symbol([$1], [id]))))])])])
|
||||||
|
|
||||||
|
|||||||
@@ -1147,7 +1147,7 @@ yyexpected_tokens (const yyparse_context_t *yyctx,
|
|||||||
]b4_lac_if([[
|
]b4_lac_if([[
|
||||||
int yyx;
|
int yyx;
|
||||||
for (yyx = 0; yyx < YYNTOKENS; ++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]],
|
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]])[))
|
[[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 yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||||
int yyx;
|
int yyx;
|
||||||
for (yyx = yyxbegin; yyx < yyxend; ++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]))
|
&& !yytable_value_is_error (yytable[yyx + yyn]))
|
||||||
{
|
{
|
||||||
if (!yyarg)
|
if (!yyarg)
|
||||||
@@ -1998,8 +1998,8 @@ yyerrlab1:
|
|||||||
yyn = yypact[yystate];
|
yyn = yypact[yystate];
|
||||||
if (!yypact_value_is_default (yyn))
|
if (!yypact_value_is_default (yyn))
|
||||||
{
|
{
|
||||||
yyn += YYSYMBOL_error;
|
yyn += YYSYMBOL_YYERROR;
|
||||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_error)
|
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYERROR)
|
||||||
{
|
{
|
||||||
yyn = yytable[yyn];
|
yyn = yytable[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
|
|||||||
Reference in New Issue
Block a user