yacc: fix push parser

When a pstate is used for multiple successive parses, some state may
leak from one run into the following one.  That was introduced in
330552ea49 "yacc.c: push: don't clear
the parser state when accepting/rejecting".

Reported by Ryan <dev@splintermail.com>
https://lists.gnu.org/r/bug-bison/2021-03/msg00000.html

* data/skeletons/yacc.c (yypush_parse): We reusing a pstate from a
previous run, do behave as if it were the first run.
* tests/push.at (Pstate reuse): Check this.
This commit is contained in:
Akim Demaille
2021-03-07 10:01:53 +01:00
parent a774839ca8
commit cf899f7a7c
3 changed files with 139 additions and 8 deletions

View File

@@ -1573,14 +1573,16 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[
switch (yyps->yynew)
{
case 2:
yypstate_clear (yyps);
goto case_0;
case_0:
case 0:
yyn = yypact[yystate];
goto yyread_pushed_token;
case 2:
yypstate_clear (yyps);
break;
default:
break;
}]])[
YYDPRINTF ((stderr, "Starting parse\n"));