mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
yacc.c: yypstate_expected_tokens
In push parsers, when asking for the list of expected tokens at some point, it makes no sense to build a yyparse_context_t: the yypstate alone suffices (the only difference being the lookahead). Instead of forcing the user to build a useless shell around yypstate, let's offer yypstate_expected_tokens. See https://lists.gnu.org/r/bison-patches/2020-03/msg00025.html. * data/skeletons/yacc.c (yypstate): Declare earlier, so that we can use it for... (yypstate_expected_tokens): this new function, when in push parsers. Adjust dependencies. * examples/c/bistromathic/parse.y: Simplify: use yypstate_expected_tokens. Style fixes. Reduce scopes (reported by Joel E. Denny).
This commit is contained in:
16
NEWS
16
NEWS
@@ -75,6 +75,16 @@ GNU Bison NEWS
|
||||
the translated symbol (i.e., it returns '_("variable")' rather that
|
||||
'"variable"').
|
||||
|
||||
*** List of expected tokens (yacc.c)
|
||||
|
||||
At any point during parsing (including even before submitting the first
|
||||
token), push parsers may now invoke yypstate_expected_tokens to get the
|
||||
list of possible tokens. This feature can be used to propose
|
||||
autocompletion (see below the "bistromathic" example).
|
||||
|
||||
It makes little sense to use this feature without enabling LAC (lookahead
|
||||
correction).
|
||||
|
||||
*** Modernize display of explanatory statements in diagnostics
|
||||
|
||||
Since Bison 2.7, output was indented four spaces for explanatory
|
||||
@@ -106,9 +116,9 @@ GNU Bison NEWS
|
||||
|
||||
A new C example, bistromathic, is a fully featured interactive calculator
|
||||
using many Bison features: pure interface, push parser, autocompletion
|
||||
based on the current parser state (using yyexpected_tokens), location
|
||||
tracking, internationalized custom error messages, lookahead-correction,
|
||||
rich debug traces, etc.
|
||||
based on the current parser state (using yypstate_expected_tokens),
|
||||
location tracking, internationalized custom error messages, lookahead
|
||||
correction, rich debug traces, etc.
|
||||
|
||||
* Noteworthy changes in release 3.5.3 (2020-03-08) [stable]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user