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:
Joel E. Denny
2010-11-07 16:10:09 -05:00
parent 095a1d11ca
commit 3b8378825e
3 changed files with 41 additions and 3 deletions

View File

@@ -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],