* data/glr.c, data/lalr1.cc, data/yacc.c: When YYABORT was

invoked, yydestruct the lookahead.
* tests/calc.at (Calculator $1): Update the expected lengths of
traces: there is an added line for the discarded lookahead.
* doc/bison.texinfo (Destructor Decl): Some rewording.
Define "discarded" symbols.
This commit is contained in:
Akim Demaille
2004-09-06 07:48:20 +00:00
parent 0fe1f06d36
commit e757bb10bc
6 changed files with 64 additions and 27 deletions

View File

@@ -1916,7 +1916,13 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
yyposn = yystack.yytops.yystates[0]->yyposn;
}
yyDone:
;
/* On YYABORT, free the lookahead. */
if (yystack.yyerrflag == 1 && yytoken != YYEMPTY)
{
YY_SYMBOL_PRINT ("Error: discarding lookahead",
yytoken, yylvalp, yyllocp);
yydestruct (yytoken, yylvalp]b4_location_if([, yyllocp])[);
}
yyfreeGLRStack (&yystack);
return yystack.yyerrflag;

View File

@@ -714,6 +714,10 @@ yyacceptlab:
/* Abort. */
yyabortlab:
/* Free the lookahead. */
YY_SYMBOL_PRINT ("Error: discarding lookahead", ilooka_, &value, &location);
destruct_ (ilooka_, &value, &location);
looka_ = empty_;
return 1;
}

View File

@@ -1209,6 +1209,9 @@ yyacceptlab:
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
YY_SYMBOL_PRINT ("Error: discarding lookahead", yytoken, &yylval, &yylloc);
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;