* src/bison.simple (yyparse): When reporting verbosely an error,

no longer issue additional quotes around token names.
* tests/calc.at: Adjust.
This commit is contained in:
Akim Demaille
2001-11-19 10:27:52 +00:00
parent e41dc70020
commit f047348491
3 changed files with 19 additions and 14 deletions

View File

@@ -1,3 +1,9 @@
2001-11-19 Akim Demaille <akim@epita.fr>
* src/bison.simple (yyparse): When reporting verbosely an error,
no longer issue additional quotes around token names.
* tests/calc.at: Adjust.
2001-11-19 Akim Demaille <akim@epita.fr> 2001-11-19 Akim Demaille <akim@epita.fr>
* src/symtab.h, src/symtab.c: `line' is a new member of `bucket'. * src/symtab.h, src/symtab.c: `line' is a new member of `bucket'.

View File

@@ -833,30 +833,29 @@ yyerrlab:
int x, count; int x, count;
count = 0; count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */ /* Start X at -YYN if negative to avoid negative indexes in
for (x = (yyn < 0 ? -yyn : 0); YYCHECK. */
for (x = yyn < 0 ? -yyn : 0;
x < (int) (sizeof (yytname) / sizeof (char *)); x++) x < (int) (sizeof (yytname) / sizeof (char *)); x++)
if (yycheck[x + yyn] == x) if (yycheck[x + yyn] == x)
size += strlen (yytname[x]) + 15, count++; size += strlen (yytname[x]) + 15, count++;
size += strlen ("parse error, unexpected `") + 1; size += strlen ("parse error, unexpected ") + 1;
size += strlen (yytname[YYTRANSLATE (yychar)]); size += strlen (yytname[YYTRANSLATE (yychar)]);
msg = (char *) malloc (size); msg = (char *) malloc (size);
if (msg != 0) if (msg != 0)
{ {
strcpy (msg, "parse error, unexpected `"); strcpy (msg, "parse error, unexpected ");
strcat (msg, yytname[YYTRANSLATE (yychar)]); strcat (msg, yytname[YYTRANSLATE (yychar)]);
strcat (msg, "'");
if (count < 5) if (count < 5)
{ {
count = 0; count = 0;
for (x = (yyn < 0 ? -yyn : 0); for (x = yyn < 0 ? -yyn : 0;
x < (int) (sizeof (yytname) / sizeof (char *)); x++) x < (int) (sizeof (yytname) / sizeof (char *)); x++)
if (yycheck[x + yyn] == x) if (yycheck[x + yyn] == x)
{ {
strcat (msg, count == 0 ? ", expecting `" : " or `"); strcat (msg, count == 0 ? ", expecting " : " or ");
strcat (msg, yytname[x]); strcat (msg, yytname[x]);
strcat (msg, "'");
count++; count++;
} }
} }
@@ -864,7 +863,7 @@ yyerrlab:
free (msg); free (msg);
} }
else else
yyerror ("parse error; also virtual memory exceeded"); yyerror ("parse error; also virtual memory exhausted");
} }
else else
#endif /* YYERROR_VERBOSE */ #endif /* YYERROR_VERBOSE */

View File

@@ -366,22 +366,22 @@ _AT_CHECK_CALC([$1],
# Some parse errors. # Some parse errors.
_AT_CHECK_CALC_ERROR([$1], [+1], [8], _AT_CHECK_CALC_ERROR([$1], [+1], [8],
[1.0:1.1], [1.0:1.1],
[unexpected `'+'']) [unexpected '+'])
_AT_CHECK_CALC_ERROR([$1], [1//2], [17], _AT_CHECK_CALC_ERROR([$1], [1//2], [17],
[1.2:1.3], [1.2:1.3],
[unexpected `'/'', expecting `NUM' or `'-'' or `'('']) [unexpected '/', expecting NUM or '-' or '('])
_AT_CHECK_CALC_ERROR([$1], [error], [8], _AT_CHECK_CALC_ERROR([$1], [error], [8],
[1.0:1.1], [1.0:1.1],
[unexpected `$undefined.']) [unexpected $undefined.])
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [23], _AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [23],
[1.6:1.7], [1.6:1.7],
[unexpected `'='']) [unexpected '='])
_AT_CHECK_CALC_ERROR([$1], _AT_CHECK_CALC_ERROR([$1],
[ [
+1], +1],
[16], [16],
[2.0:2.1], [2.0:2.1],
[unexpected `'+'']) [unexpected '+'])
AT_CLEANUP AT_CLEANUP
])# AT_CHECK_CALC ])# AT_CHECK_CALC