From c555896775f9398684aeb2c7bf8bd6e7af946d77 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 19 Nov 2001 09:13:26 +0000 Subject: [PATCH] * src/bison.simple (yyparse): When reporting verbosely an error, no longer issue additional quotes around token names. * tests/calc.at: Adjust. --- ChangeLog | 6 ++++++ NEWS | 5 +++++ src/bison.simple | 17 ++++++++--------- tests/calc.at | 10 +++++----- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f97247b..4c85dce7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-19 Akim Demaille + + * 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 * src/symtab.h, src/symtab.c: `line' is a new member of `bucket'. diff --git a/NEWS b/NEWS index 668e2449..bc333b13 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,11 @@ Bison News Changes in version 1.30d: +* Parse errors + Verbose parse error messages from the parsers are better looking. + Before: parse error: unexpected `'/'', expecting `"number"' or `'-'' or `'('' + Now: parse error: unexpected '/', expecting "number" or '-' or '(' + Changes in version 1.30c: * Fixed a few warnings. diff --git a/src/bison.simple b/src/bison.simple index bca1254a..98fa0c4b 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -671,30 +671,29 @@ yyerrlab: int x, count; count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); + /* Start X at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (x = yyn < 0 ? -yyn : 0; x < (int) (sizeof (yytname) / sizeof (char *)); x++) if (yycheck[x + yyn] == x) size += strlen (yytname[x]) + 15, count++; - size += strlen ("parse error, unexpected `") + 1; + size += strlen ("parse error, unexpected ") + 1; size += strlen (yytname[YYTRANSLATE (yychar)]); msg = (char *) malloc (size); if (msg != 0) { - strcpy (msg, "parse error, unexpected `"); + strcpy (msg, "parse error, unexpected "); strcat (msg, yytname[YYTRANSLATE (yychar)]); - strcat (msg, "'"); if (count < 5) { count = 0; - for (x = (yyn < 0 ? -yyn : 0); + for (x = yyn < 0 ? -yyn : 0; x < (int) (sizeof (yytname) / sizeof (char *)); x++) if (yycheck[x + yyn] == x) { - strcat (msg, count == 0 ? ", expecting `" : " or `"); + strcat (msg, count == 0 ? ", expecting " : " or "); strcat (msg, yytname[x]); - strcat (msg, "'"); count++; } } @@ -702,7 +701,7 @@ yyerrlab: free (msg); } else - yyerror ("parse error; also virtual memory exceeded"); + yyerror ("parse error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ diff --git a/tests/calc.at b/tests/calc.at index 9bf1af9c..04d7e366 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -366,22 +366,22 @@ _AT_CHECK_CALC([$1], # Some parse errors. _AT_CHECK_CALC_ERROR([$1], [+1], [8], [1.0:1.1], - [unexpected `'+'']) + [unexpected '+']) _AT_CHECK_CALC_ERROR([$1], [1//2], [17], [1.2:1.3], - [unexpected `'/'', expecting `NUM' or `'-'' or `'('']) + [unexpected '/', expecting NUM or '-' or '(']) _AT_CHECK_CALC_ERROR([$1], [error], [8], [1.0:1.1], - [unexpected `$undefined.']) + [unexpected $undefined.]) _AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [23], [1.6:1.7], - [unexpected `'='']) + [unexpected '=']) _AT_CHECK_CALC_ERROR([$1], [ +1], [16], [2.0:2.1], - [unexpected `'+'']) + [unexpected '+']) AT_CLEANUP ])# AT_CHECK_CALC -- 2.50.0