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

8
NEWS
View File

@@ -4,11 +4,17 @@ GNU Bison NEWS
** Bug fixes
*** Reused Push Parsers
When a push-parser state structure is used for multiple parses, it was
possible for some state to leak from one run into the following one.
*** Fix Table Generation
In some very rare conditions, when there are many useless tokens, it was
possible to generate incorrect parsers.
* Noteworthy changes in release 3.7.5 (2021-01-24) [stable]
** Bug fixes
@@ -290,7 +296,7 @@ GNU Bison NEWS
parse errors, since `yynerrs` was also reset. This can be especially
troublesome when used in autocompletion, since a parser with error
recovery would suggest (irrelevant) expected tokens even if there were
failure.
failures.
Now the parser state can be examined when parsing is finished. The parser
state is reset when starting a new parse.