mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
(YYERROR): Now just 'goto yyerrorlab', since the
macro's size was becoming unwieldy. (yyerrlab): Do not discard an empty lookahead symbol, as this might destroy garbage. (yyerrorlab): New label, with the old contents of YYERROR, plus the following change: pop the stack of rhs corresponding to the production that invoked YYERROR. That is how Yacc behaves, and POSIX requires this behavior. (yyerrlab1): Use YYPOPSTACK instead of its definiens.
This commit is contained in:
77
data/yacc.c
77
data/yacc.c
@@ -466,14 +466,7 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
|||||||
|
|
||||||
#define YYACCEPT goto yyacceptlab
|
#define YYACCEPT goto yyacceptlab
|
||||||
#define YYABORT goto yyabortlab
|
#define YYABORT goto yyabortlab
|
||||||
#define YYERROR ]b4_location_if([do \
|
#define YYERROR goto yyerrorlab
|
||||||
{ \
|
|
||||||
yylerrsp = yylsp; \
|
|
||||||
*++yylerrsp = yyloc; \
|
|
||||||
goto yyerrlab1; \
|
|
||||||
} \
|
|
||||||
while (0)],
|
|
||||||
[goto yyerrlab1])[
|
|
||||||
|
|
||||||
|
|
||||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||||
@@ -1101,25 +1094,27 @@ yyerrlab:
|
|||||||
/* If just tried and failed to reuse lookahead token after an
|
/* If just tried and failed to reuse lookahead token after an
|
||||||
error, discard it. */
|
error, discard it. */
|
||||||
|
|
||||||
/* Return failure if at end of input. */
|
if (yychar <= YYEOF)
|
||||||
if (yychar == YYEOF)
|
|
||||||
{
|
{
|
||||||
/* Pop the error token. */
|
/* If at end of input, pop the error token,
|
||||||
YYPOPSTACK;
|
then the rest of the stack, then return failure. */
|
||||||
/* Pop the rest of the stack. */
|
if (yychar == YYEOF)
|
||||||
while (yyss < yyssp)
|
for (;;)
|
||||||
{
|
{
|
||||||
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
YYPOPSTACK;
|
||||||
yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
if (yyssp == yyss)
|
||||||
YYPOPSTACK;
|
YYABORT;
|
||||||
}
|
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
||||||
YYABORT;
|
yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
|
{
|
||||||
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
|
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
|
||||||
yychar = YYEMPTY;
|
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||||
]b4_location_if([ *++yylerrsp = yylloc;])[
|
yychar = YYEMPTY;
|
||||||
|
]b4_location_if([ *++yylerrsp = yylloc;])[
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* Else will try to reuse lookahead token after shifting the error
|
||||||
@@ -1127,9 +1122,30 @@ yyerrlab:
|
|||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------.
|
/*---------------------------------------------------.
|
||||||
| yyerrlab1 -- error raised explicitly by an action. |
|
| yyerrorlab -- error raised explicitly by YYERROR. |
|
||||||
`----------------------------------------------------*/
|
`---------------------------------------------------*/
|
||||||
|
yyerrorlab:
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
/* Pacify GCC when the user code never invokes YYERROR and the label
|
||||||
|
yyerrorlab therefore never appears in user code. */
|
||||||
|
if (0)
|
||||||
|
goto yyerrorlab;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
yyvsp -= yylen;
|
||||||
|
yyssp -= yylen;
|
||||||
|
yystate = *yyssp;
|
||||||
|
]b4_location_if([yylerrsp = yylsp;
|
||||||
|
*++yylerrsp = yyloc;
|
||||||
|
yylsp -= yylen;
|
||||||
|
])[goto yyerrlab1;
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------.
|
||||||
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
||||||
|
`-------------------------------------------------------------*/
|
||||||
yyerrlab1:
|
yyerrlab1:
|
||||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
@@ -1153,9 +1169,8 @@ yyerrlab1:
|
|||||||
|
|
||||||
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
||||||
yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
||||||
yyvsp--;
|
YYPOPSTACK;
|
||||||
yystate = *--yyssp;
|
yystate = *yyssp;
|
||||||
]b4_location_if([ yylsp--;])[
|
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user