* data/glr.c (yyreportSyntaxError): Fix off-by-one error in

checking against YYLAST that caused the parser to miss a potential
alternative in its diagnostic.
Problem reported by Maria Jose Moron Fernandez in
<http://lists.gnu.org/archive/html/bug-bison/2006-05/msg00024.html>.
* data/lalr1.cc (yysyntax_error_): Likewise.
* data/yacc.c (yysyntax_error): Likewise.
* tests/regression.at (_AT_DATA_DANCER_Y): Use static array for
tokens, in case we run into an older C compiler.
(_AT_DATA_EXPECT2_Y, AT_CHECK_EXPECT2): New macros.
Use them to check for the off-by-one error fixed above.
This commit is contained in:
Paul Eggert
2006-05-15 06:13:53 +00:00
parent 276f48df88
commit d664514801
5 changed files with 116 additions and 7 deletions

View File

@@ -2077,7 +2077,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
#if YYERROR_VERBOSE
int yyn;
yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
if (YYPACT_NINF < yyn && yyn < YYLAST)
if (YYPACT_NINF < yyn && yyn <= YYLAST)
{
yySymbol yytoken = YYTRANSLATE (yychar);
size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
@@ -2104,7 +2104,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn;
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 1;