mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
In verbose parse error message, don't report `error' as an
expected token. * tests/actions.at (Printers and Destructors): Adjust. * tests/calc.at (Calculator $1): Adjust. * data/yacc.c, data/glr.c, data/lalr1.c: When making the verbose error message, do not report the parser accepts the error token in that state.
This commit is contained in:
@@ -1512,7 +1512,7 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
|
||||
yyprefix = ", expecting ";
|
||||
for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size && yycount <= 5;
|
||||
yyx += 1)
|
||||
if (yycheck[yyx + yyn] == yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||
yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),
|
||||
yycount += 1, yyprefix = " or ";
|
||||
yymsg = yyp = (char*) malloc (yysize);
|
||||
|
||||
@@ -500,13 +500,13 @@ yy::b4_name::parse ()
|
||||
{
|
||||
int count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
if (check_[[x + n_]] == x)
|
||||
if (check_[[x + n_]] == x && x != terror_)
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
if (check_[[x + n_]] == x)
|
||||
if (check_[[x + n_]] == x && x != terror_)
|
||||
{
|
||||
message += (!count++) ? ", expecting " : " or ";
|
||||
message += name_[[x]];
|
||||
|
||||
@@ -667,7 +667,7 @@ b4_c_function([yyreport_parse_error],
|
||||
YYCHECK. */
|
||||
for (yyx = yyn < 0 ? -yyn : 0;
|
||||
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
|
||||
if (yycheck[yyx + yyn] == yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
|
||||
yysize += yystrlen ("parse error, unexpected ") + 1;
|
||||
yysize += yystrlen (yytname[yytype]);
|
||||
@@ -683,7 +683,7 @@ b4_c_function([yyreport_parse_error],
|
||||
for (yyx = yyn < 0 ? -yyn : 0;
|
||||
yyx < (int) (sizeof (yytname) / sizeof (char *));
|
||||
yyx++)
|
||||
if (yycheck[yyx + yyn] == yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||
{
|
||||
const char *yyq = ! yycount ? ", expecting " : " or ";
|
||||
yyp = yystpcpy (yyp, yyq);
|
||||
|
||||
Reference in New Issue
Block a user