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:
Akim Demaille
2002-07-30 11:56:44 +00:00
parent 52489d4445
commit 217598dadc
8 changed files with 25 additions and 32 deletions

View File

@@ -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);

View File

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

View File

@@ -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);