mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
* data/yacc.cc, data/glr.cc (yydestruct): Accept an additional
argument, an informative message. Call YY_SYMBOL_PRINT. Adjust all callers: integrate the associated YY_SYMBOL_PRINT. * data/lalr1.cc (destruct_): Likewise. In addition, no longer depend on b4_yysymprint_generate and b4_yydestruct_generate to generate these functions, do it "by hand".
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2004-09-06 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* data/yacc.cc, data/glr.cc (yydestruct): Accept an additional
|
||||||
|
argument, an informative message.
|
||||||
|
Call YY_SYMBOL_PRINT.
|
||||||
|
Adjust all callers: integrate the associated YY_SYMBOL_PRINT.
|
||||||
|
* data/lalr1.cc (destruct_): Likewise.
|
||||||
|
In addition, no longer depend on b4_yysymprint_generate and
|
||||||
|
b4_yydestruct_generate to generate these functions, do it "by
|
||||||
|
hand".
|
||||||
|
|
||||||
2004-09-03 Akim Demaille <akim@epita.fr>
|
2004-09-03 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/glr.c, data/lalr1.cc, data/yacc.c: When YYABORT was
|
* data/glr.c, data/lalr1.cc, data/yacc.c: When YYABORT was
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ m4_define([b4_yydestruct_generate],
|
|||||||
|
|
||||||
]$1([yydestruct],
|
]$1([yydestruct],
|
||||||
[static void],
|
[static void],
|
||||||
|
[[const char *yymsg], [yymsg]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
|
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
|
||||||
[[YYLTYPE *yylocationp], [yylocationp]]]))[
|
[[YYLTYPE *yylocationp], [yylocationp]]]))[
|
||||||
@@ -360,6 +361,10 @@ m4_define([b4_yydestruct_generate],
|
|||||||
(void) yyvaluep;
|
(void) yyvaluep;
|
||||||
]b4_location_if([ (void) yylocationp;
|
]b4_location_if([ (void) yylocationp;
|
||||||
])[
|
])[
|
||||||
|
if (!yymsg)
|
||||||
|
yymsg = "Deleting";
|
||||||
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||||
|
|
||||||
switch (yytype)
|
switch (yytype)
|
||||||
{
|
{
|
||||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
|
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
|
||||||
|
|||||||
25
data/glr.c
25
data/glr.c
@@ -1698,10 +1698,8 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
while (yystack->yytops.yystates[0] != NULL)
|
while (yystack->yytops.yystates[0] != NULL)
|
||||||
{
|
{
|
||||||
yyGLRState *yys = yystack->yytops.yystates[0];
|
yyGLRState *yys = yystack->yytops.yystates[0];
|
||||||
YY_SYMBOL_PRINT ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[yys->yylrState],
|
yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval, &yys->yyloc);
|
|
||||||
yydestruct (yystos[yys->yylrState],
|
|
||||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||||
yystack->yytops.yystates[0] = yys->yypred;
|
yystack->yytops.yystates[0] = yys->yypred;
|
||||||
yystack->yynextFree -= 1;
|
yystack->yynextFree -= 1;
|
||||||
@@ -1710,10 +1708,8 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
yyFail (yystack][]b4_lpure_args[, NULL);
|
yyFail (yystack][]b4_lpure_args[, NULL);
|
||||||
}
|
}
|
||||||
if (*yytokenp != YYEMPTY)
|
if (*yytokenp != YYEMPTY)
|
||||||
{
|
yydestruct ("Error: discarding",
|
||||||
YY_SYMBOL_PRINT ("Error: discarding", *yytokenp, yylvalp, yyllocp);
|
*yytokenp, yylvalp]b4_location_if([, yyllocp])[);
|
||||||
yydestruct (*yytokenp, yylvalp]b4_location_if([, yyllocp])[);
|
|
||||||
}
|
|
||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((stderr, "Reading a token: "));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
*yytokenp = YYTRANSLATE (yychar);
|
*yytokenp = YYTRANSLATE (yychar);
|
||||||
@@ -1760,10 +1756,8 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
YY_SYMBOL_PRINT ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[yys->yylrState],
|
yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval, &yys->yyloc);
|
|
||||||
yydestruct (yystos[yys->yylrState],
|
|
||||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||||
yystack->yytops.yystates[0] = yys->yypred;
|
yystack->yytops.yystates[0] = yys->yypred;
|
||||||
yystack->yynextFree -= 1;
|
yystack->yynextFree -= 1;
|
||||||
@@ -1918,11 +1912,8 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
yyDone:
|
yyDone:
|
||||||
/* On YYABORT, free the lookahead. */
|
/* On YYABORT, free the lookahead. */
|
||||||
if (yystack.yyerrflag == 1 && yytoken != YYEMPTY)
|
if (yystack.yyerrflag == 1 && yytoken != YYEMPTY)
|
||||||
{
|
yydestruct ("Error: discarding lookahead",
|
||||||
YY_SYMBOL_PRINT ("Error: discarding lookahead",
|
yytoken, yylvalp]b4_location_if([, yyllocp])[);
|
||||||
yytoken, yylvalp, yyllocp);
|
|
||||||
yydestruct (yytoken, yylvalp]b4_location_if([, yyllocp])[);
|
|
||||||
}
|
|
||||||
|
|
||||||
yyfreeGLRStack (&yystack);
|
yyfreeGLRStack (&yystack);
|
||||||
return yystack.yyerrflag;
|
return yystack.yyerrflag;
|
||||||
|
|||||||
104
data/lalr1.cc
104
data/lalr1.cc
@@ -115,42 +115,6 @@ m4_define([b4_cc_var_decl],
|
|||||||
[ $1;])
|
[ $1;])
|
||||||
|
|
||||||
|
|
||||||
# b4_yysymprint_generate(FUNCTION-DECLARATOR)
|
|
||||||
# -------------------------------------------
|
|
||||||
# Generate the "symprint_" member function.
|
|
||||||
m4_define([b4_yysymprint_generate],
|
|
||||||
[[/*--------------------------------.
|
|
||||||
| Print this symbol on YYOUTPUT. |
|
|
||||||
`--------------------------------*/
|
|
||||||
|
|
||||||
]void
|
|
||||||
yy::b4_parser_class_name::symprint_ (int yytype, const SemanticType *yyvaluep, const LocationType *yylocationp)[
|
|
||||||
{
|
|
||||||
/* Pacify ``unused variable'' warnings. */
|
|
||||||
(void) yyvaluep;
|
|
||||||
(void) yylocationp;
|
|
||||||
|
|
||||||
cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
|
|
||||||
<< ' ' << name_[yytype] << " (";
|
|
||||||
switch (yytype)
|
|
||||||
{
|
|
||||||
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
|
||||||
[ default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cdebug_ << ')';
|
|
||||||
}
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_cxx_destruct_def(IGNORED-ARGUMENTS)
|
|
||||||
# --------------------------------------
|
|
||||||
# Declare the destruct_ method.
|
|
||||||
m4_define([b4_cxx_destruct_def],
|
|
||||||
[void
|
|
||||||
yy::b4_parser_class_name::destruct_ (int yytype, SemanticType *yyvaluep, LocationType *yylocationp)[]dnl
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
# We do want M4 expansion after # for CPP macros.
|
||||||
m4_changecom()
|
m4_changecom()
|
||||||
@@ -316,8 +280,9 @@ namespace yy
|
|||||||
|
|
||||||
/* Even more tables. */
|
/* Even more tables. */
|
||||||
inline TokenNumberType translate_ (int token);
|
inline TokenNumberType translate_ (int token);
|
||||||
inline void destruct_ (int yytype, SemanticType *yyvaluep,
|
inline void destruct_ (const char *yymsg,
|
||||||
LocationType *yylocationp);
|
int yytype,
|
||||||
|
SemanticType *yyvaluep, LocationType *yylocationp);
|
||||||
|
|
||||||
/* Constants. */
|
/* Constants. */
|
||||||
static const int eof_;
|
static const int eof_;
|
||||||
@@ -419,9 +384,49 @@ do { \
|
|||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
|
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
]b4_yysymprint_generate([b4_cxx_symprint_def])[
|
/*--------------------------------.
|
||||||
|
| Print this symbol on YYOUTPUT. |
|
||||||
|
`--------------------------------*/
|
||||||
|
|
||||||
|
void
|
||||||
|
yy::]b4_parser_class_name[::symprint_ (int yytype,
|
||||||
|
const SemanticType *yyvaluep, const LocationType *yylocationp)
|
||||||
|
{
|
||||||
|
/* Pacify ``unused variable'' warnings. */
|
||||||
|
(void) yyvaluep;
|
||||||
|
(void) yylocationp;
|
||||||
|
|
||||||
|
cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
|
||||||
|
<< ' ' << name_[yytype] << " (";
|
||||||
|
switch (yytype)
|
||||||
|
{
|
||||||
|
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
||||||
|
[ default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cdebug_ << ')';
|
||||||
|
}
|
||||||
#endif /* ! YYDEBUG */
|
#endif /* ! YYDEBUG */
|
||||||
]b4_yydestruct_generate([b4_cxx_destruct_def])[
|
|
||||||
|
void
|
||||||
|
yy::]b4_parser_class_name[::destruct_ (const char *yymsg,
|
||||||
|
int yytype, SemanticType *yyvaluep, LocationType *yylocationp)
|
||||||
|
{
|
||||||
|
/* Pacify ``unused variable'' warnings. */
|
||||||
|
(void) yyvaluep;
|
||||||
|
(void) yylocationp;
|
||||||
|
|
||||||
|
if (!yymsg)
|
||||||
|
yymsg = "Deleting";
|
||||||
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||||
|
|
||||||
|
switch (yytype)
|
||||||
|
{
|
||||||
|
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
yy::]b4_parser_class_name[::parse ()
|
yy::]b4_parser_class_name[::parse ()
|
||||||
@@ -614,19 +619,15 @@ yyerrlab:
|
|||||||
location_stack_.pop ();
|
location_stack_.pop ();
|
||||||
if (state_stack_.height () == 1)
|
if (state_stack_.height () == 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
YY_SYMBOL_PRINT ("Error: popping",
|
destruct_ ("Error: popping",
|
||||||
stos_[state_stack_[0]],
|
stos_[state_stack_[0]],
|
||||||
&semantic_stack_[0],
|
|
||||||
&location_stack_[0]);
|
|
||||||
destruct_ (stos_[state_stack_[0]],
|
|
||||||
&semantic_stack_[0],
|
&semantic_stack_[0],
|
||||||
&location_stack_[0]);
|
&location_stack_[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YY_SYMBOL_PRINT ("Error: discarding", ilooka_, &value, &location);
|
destruct_ ("Error: discarding", ilooka_, &value, &location);
|
||||||
destruct_ (ilooka_, &value, &location);
|
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -679,10 +680,8 @@ yyerrlab1:
|
|||||||
if (state_stack_.height () == 1)
|
if (state_stack_.height () == 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
YY_SYMBOL_PRINT ("Error: popping",
|
destruct_ ("Error: popping",
|
||||||
stos_[state_],
|
stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
||||||
&semantic_stack_[0], &location_stack_[0]);
|
|
||||||
destruct_ (stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
|
||||||
error_start_ = location_stack_[0].begin;
|
error_start_ = location_stack_[0].begin;
|
||||||
|
|
||||||
state_stack_.pop ();
|
state_stack_.pop ();
|
||||||
@@ -715,8 +714,7 @@ yyacceptlab:
|
|||||||
/* Abort. */
|
/* Abort. */
|
||||||
yyabortlab:
|
yyabortlab:
|
||||||
/* Free the lookahead. */
|
/* Free the lookahead. */
|
||||||
YY_SYMBOL_PRINT ("Error: discarding lookahead", ilooka_, &value, &location);
|
destruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
|
||||||
destruct_ (ilooka_, &value, &location);
|
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
15
data/yacc.c
15
data/yacc.c
@@ -1114,15 +1114,13 @@ yyerrlab:
|
|||||||
YYPOPSTACK;
|
YYPOPSTACK;
|
||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
YY_SYMBOL_PRINT ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[*yyssp], yyvsp, yylsp);
|
yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
||||||
yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YY_SYMBOL_PRINT ("Error: discarding", yytoken, &yylval, &yylloc);
|
yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||||
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
|
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
]b4_location_if([ *++yylerrsp = yylloc;])[
|
]b4_location_if([ *++yylerrsp = yylloc;])[
|
||||||
}
|
}
|
||||||
@@ -1178,8 +1176,7 @@ yyerrlab1:
|
|||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
YY_SYMBOL_PRINT ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
||||||
yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
|
||||||
YYPOPSTACK;
|
YYPOPSTACK;
|
||||||
yystate = *yyssp;
|
yystate = *yyssp;
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
@@ -1209,8 +1206,8 @@ yyacceptlab:
|
|||||||
| yyabortlab -- YYABORT comes here. |
|
| yyabortlab -- YYABORT comes here. |
|
||||||
`-----------------------------------*/
|
`-----------------------------------*/
|
||||||
yyabortlab:
|
yyabortlab:
|
||||||
YY_SYMBOL_PRINT ("Error: discarding lookahead", yytoken, &yylval, &yylloc);
|
yydestruct ("Error: discarding lookahead",
|
||||||
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
|
yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
yyresult = 1;
|
yyresult = 1;
|
||||||
goto yyreturn;
|
goto yyreturn;
|
||||||
|
|||||||
Reference in New Issue
Block a user