bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

22-error-message.patch


From: Akim Demaille
Subject: 22-error-message.patch
Date: Mon, 19 Nov 2001 10:03:28 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * src/bison.simple (yyparse): When reporting verbosely an error,
        no longer issue additional quotes around token names.
        * tests/calc.at: Adjust.
        
Index: NEWS
--- NEWS Thu, 15 Nov 2001 08:56:59 +0100 akim
+++ NEWS Sat, 17 Nov 2001 13:08:45 +0100 akim
@@ -3,6 +3,11 @@
 
 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.
Index: src/bison.simple
--- src/bison.simple Thu, 15 Nov 2001 08:56:59 +0100 akim
+++ src/bison.simple Sat, 17 Nov 2001 13:00:32 +0100 akim
@@ -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 */
Index: tests/calc.at
--- tests/calc.at Thu, 15 Nov 2001 08:56:59 +0100 akim
+++ tests/calc.at Sat, 17 Nov 2001 13:02:54 +0100 akim
@@ -366,22 +366,22 @@ m4_define([AT_CHECK_CALC],
 # 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]