mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
yysyntax_error: adjust prior fixes for branch-2.5's lalr1.cc.
On master, there is no yychar in lalr1.cc, but there is on branch-2.5, and the prior cherry-pick of "Fix handling of yychar manipulation in user semantic actions" wasn't adjusted for that difference. * data/lalr1.cc (yy::parser::parse): Translate yychar before every use of yytoken, and add comments explaining this approach. * tests/conflicts.at (%error-verbose and consistent errors): Extend to test yychar manipulation with lalr1.cc.
This commit is contained in:
@@ -161,6 +161,7 @@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
|
||||
}]], [[
|
||||
|
||||
%code {]AT_SKEL_CC_IF([[
|
||||
#include <cassert>
|
||||
#include <string>]], [[
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@@ -376,7 +377,7 @@ error-reduce:
|
||||
;
|
||||
|
||||
consistent-reduction: /*empty*/ {
|
||||
assert (yychar == YYEMPTY);
|
||||
assert (yychar == ]AT_SKEL_CC_IF([[yyempty_]], [[YYEMPTY]])[);
|
||||
yylval = 0;
|
||||
yychar = 'b';
|
||||
} ;
|
||||
@@ -400,7 +401,11 @@ AT_CONSISTENT_ERRORS_CHECK([[%glr-parser]],
|
||||
[AT_USER_ACTION_GRAMMAR],
|
||||
[AT_USER_ACTION_INPUT],
|
||||
[['b']], [[none]])
|
||||
# No C++ or Java test because yychar cannot be manipulated by users.
|
||||
AT_CONSISTENT_ERRORS_CHECK([[%language "c++"]],
|
||||
[AT_USER_ACTION_GRAMMAR],
|
||||
[AT_USER_ACTION_INPUT],
|
||||
[['b']], [[none]])
|
||||
# No Java test because yychar cannot be manipulated by users.
|
||||
|
||||
AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]],
|
||||
[AT_USER_ACTION_GRAMMAR],
|
||||
|
||||
Reference in New Issue
Block a user