During deterministic GLR operation, user actions should be able to

influence the parse by changing yychar.  To make this easier to fix and
to make glr.c easier to evolve in general, don't maintain yytoken in
parallel with yychar; just compute yytoken when needed.
* tests/glr-regression.at (Incorrect lookahead during deterministic
GLR): Check that setting yychar in a user action has the intended
effect.
* data/glr.c (yyGLRStack): Remove yytokenp member.
(yyclearin): Don't set *yytokenp.
(yyprocessOneStack, yyreportSyntaxError, yyrecoverSyntaxError): Examine
yychar rather than *yytokenp to determine the current lookahead.
Compute yytoken locally when needed.
(yyparse): Likewise.  Remove the local yytoken that yytokenp used to
point to.

* doc/bison.texinfo (Bison Options): Remove stray sentence fragment
after `--report' documentation.
This commit is contained in:
Joel E. Denny
2006-01-30 11:15:15 +00:00
parent e2a8c0f591
commit 3f0014152b
6 changed files with 63 additions and 39 deletions

View File

@@ -1016,7 +1016,8 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Incorrect lookahead during deterministic GLR. See ##
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00017.html>. ##
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00017.html> and ##
## <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00060.html>. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Incorrect lookahead during deterministic GLR])
@@ -1027,7 +1028,8 @@ AT_DATA_GRAMMAR([glr-regr13.y],
- Defaulted state with initial yychar: yychar == YYEMPTY.
- Nondefaulted state: yychar != YYEMPTY.
- Defaulted state after lookahead: yychar != YYEMPTY.
- Defaulted state after shift: yychar == YYEMPTY. */
- Defaulted state after shift: yychar == YYEMPTY.
- User action changing the lookahead. */
%{
#include <stdio.h>
@@ -1045,7 +1047,7 @@ AT_DATA_GRAMMAR([glr-regr13.y],
%%
start:
defstate_init defstate_shift 'b' {
defstate_init defstate_shift 'b' change_lookahead 'a' {
USE ($3);
print_look_ahead ("start <- defstate_init defstate_shift 'b'");
}
@@ -1075,6 +1077,11 @@ nondefstate:
print_look_ahead ("nondefstate <- 'b'");
}
;
change_lookahead:
{
yychar = 'a';
}
;
%%