mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Destructor cleanups and regularization among the three skeletons.
* NEWS: Document the behavior changes. * data/glr.c (yyrecoverSyntaxError): Don't bother to pop the stack before failing, as the cleanup code will do it for us now. * data/lalr1.cc (yyerrlab): Likewise. * data/glr.c (yyparse): Pop everything off the stack before freeing it, so that destructors get called properly. * data/lalr1.cc (yyreturn): Likewise. * data/yacc.c (yyreturn): Pop and destroy the start symbol, too. This is more consistent. * doc/bison.texinfo (Destructor Decl): Mention more reasons why destructors might be called. 1.875 -> 2.1. (Destructor Decl, Decl Summary, Table of Symbols): Some English-language cleanups for %destructor. * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Add output line for destructor of start symbol. * tests/calc.at (AT_CHECK_CALC): Add one to line counts, because of that same extra output line.
This commit is contained in:
29
data/glr.c
29
data/glr.c
@@ -1846,21 +1846,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
||||
while (yytrue)
|
||||
{
|
||||
if (*yytokenp == YYEOF)
|
||||
{
|
||||
/* Now pop stack until empty and fail. */
|
||||
while (yystack->yytops.yystates[0] != NULL)
|
||||
{
|
||||
yyGLRState *yys = yystack->yytops.yystates[0];
|
||||
]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
||||
yydestruct ("Error: popping",
|
||||
yystos[yys->yylrState],
|
||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||
yystack->yytops.yystates[0] = yys->yypred;
|
||||
yystack->yynextFree -= 1;
|
||||
yystack->yyspaceLeft += 1;
|
||||
}
|
||||
yyFail (yystack][]b4_lpure_args[, NULL);
|
||||
}
|
||||
yyFail (yystack][]b4_lpure_args[, NULL);
|
||||
if (*yytokenp != YYEMPTY)
|
||||
{]b4_location_if([[
|
||||
/* We throw away the lookahead, but the error range
|
||||
@@ -2122,6 +2108,19 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
||||
yydestruct ("Error: discarding lookahead",
|
||||
yytoken, yylvalp]b4_location_if([, yyllocp])[);
|
||||
|
||||
/* Now pop stack until empty, destroying its entries as we go. */
|
||||
while (yystack.yytops.yystates[0] != NULL)
|
||||
{
|
||||
yyGLRState *yys = yystack.yytops.yystates[0];
|
||||
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
||||
yydestruct ("Error: popping",
|
||||
yystos[yys->yylrState],
|
||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||
yystack.yytops.yystates[0] = yys->yypred;
|
||||
yystack.yynextFree -= 1;
|
||||
yystack.yyspaceLeft += 1;
|
||||
}
|
||||
|
||||
yyfreeGLRStack (&yystack);
|
||||
return yyresult;
|
||||
}
|
||||
|
||||
@@ -729,23 +729,11 @@ yyerrlab:
|
||||
/* If just tried and failed to reuse look-ahead token after an
|
||||
error, discard it. */
|
||||
|
||||
/* Return failure if at end of input. */
|
||||
if (yylooka_ <= yyeof_)
|
||||
{
|
||||
/* If at end of input, pop the error token,
|
||||
then the rest of the stack, then return failure. */
|
||||
/* Return failure if at end of input. */
|
||||
if (yylooka_ == yyeof_)
|
||||
for (;;)
|
||||
{
|
||||
yyerror_range_[0] = yylocation_stack_[0];
|
||||
yypop_ ();
|
||||
if (yystate_stack_.height () == 1)
|
||||
YYABORT;
|
||||
yydestruct_ ("Error: popping",
|
||||
yystos_[yystate_stack_[0]],
|
||||
&yysemantic_stack_[0],
|
||||
&yylocation_stack_[0]);
|
||||
}
|
||||
YYABORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -768,7 +756,7 @@ yyerrorlab:
|
||||
YYERROR and the label yyerrorlab therefore never appears in user
|
||||
code. */
|
||||
if (false)
|
||||
goto yyerrorlab;
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range_[0] = yylocation_stack_[yylen_ - 1];
|
||||
yypop_ (yylen_);
|
||||
@@ -838,6 +826,16 @@ yyabortlab:
|
||||
yyreturn:
|
||||
if (yylooka_ != yyeof_ && yylooka_ != yyempty_)
|
||||
yydestruct_ ("Error: discarding lookahead", yyilooka_, &yylval, &yylloc);
|
||||
|
||||
while (yystate_stack_.height () != 1)
|
||||
{
|
||||
yydestruct_ ("Error: popping",
|
||||
yystos_[yystate_stack_[0]],
|
||||
&yysemantic_stack_[0],
|
||||
&yylocation_stack_[0]);
|
||||
yypop_ ();
|
||||
}
|
||||
|
||||
return yyresult_;
|
||||
}
|
||||
|
||||
|
||||
19
data/yacc.c
19
data/yacc.c
@@ -1220,8 +1220,7 @@ yyerrlab:
|
||||
|
||||
if (yychar <= YYEOF)
|
||||
{
|
||||
/* If at end of input, pop the error token,
|
||||
then the rest of the stack, then return failure. */
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == YYEOF)
|
||||
YYABORT;
|
||||
}
|
||||
@@ -1333,16 +1332,12 @@ yyreturn:
|
||||
if (yychar != YYEOF && yychar != YYEMPTY)
|
||||
yydestruct ("Error: discarding lookahead",
|
||||
yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||
if (yyssp != yyss)
|
||||
for (;;)
|
||||
{
|
||||
]b4_location_if([[ yyerror_range[0] = *yylsp;]])[
|
||||
YYPOPSTACK;
|
||||
if (yyssp == yyss)
|
||||
break;
|
||||
yydestruct ("Error: popping",
|
||||
yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
||||
}
|
||||
while (yyssp != yyss)
|
||||
{
|
||||
yydestruct ("Error: popping",
|
||||
yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
||||
YYPOPSTACK;
|
||||
}
|
||||
#ifndef yyoverflow
|
||||
if (yyss != yyssa)
|
||||
YYSTACK_FREE (yyss);
|
||||
|
||||
Reference in New Issue
Block a user