]> git.saurik.com Git - bison.git/commitdiff
On syntax errors, report the token on which we choked.
authorAkim Demaille <akim@epita.fr>
Fri, 17 Mar 2000 13:17:09 +0000 (13:17 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 17 Mar 2000 13:17:09 +0000 (13:17 +0000)
* bison.s1 (yyparse): In the label yyerrlab, when YYERROR_VERBOSE,
add yychar in msg.

ChangeLog
pre-config
src/bison.s1
src/bison.simple

index a1274aab527f20c4a510173fbb9d8a7ed3e48735..b0e45468671716923b0c2838dfbe3584adbac230 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-03-17  Akim Demaille  <akim@epita.fr>
+
+       On syntax errors, report the token on which we choked.
+
+       * bison.s1 (yyparse): In the label yyerrlab, when YYERROR_VERBOSE,
+       add yychar in msg.
+
 2000-03-17  Akim Demaille  <akim@epita.fr>
 
        * reader.c (copy_at): New function.
 2000-03-17  Akim Demaille  <akim@epita.fr>
 
        * reader.c (copy_at): New function.
index 8ce69f656b5936e44cdb46a196f2c55ec3dcef06..dce7fc8e5d5a2676f07e893d088391a47609b791 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 
 #! /bin/sh
 
-aclocal && \
+aclocal -I m4 && \
 gettextize && \
 autoconf && \
 autoheader && \
 gettextize && \
 autoconf && \
 autoheader && \
index e71ac990e41483c8bace5a17fda794507c9b6bbe..474e324f14fe442b3a4d29b24bb4649294cb595c 100644 (file)
@@ -635,10 +635,14 @@ yyerrlab:   /* here on detecting error */
               x < (sizeof(yytname) / sizeof(char *)); x++)
            if (yycheck[x + yyn] == x)
              size += strlen(yytname[x]) + 15, count++;
               x < (sizeof(yytname) / sizeof(char *)); x++)
            if (yycheck[x + yyn] == x)
              size += strlen(yytname[x]) + 15, count++;
-         msg = (char *) malloc(size + 15);
+         size += strlen ("parse error, unexpected `") + 1;
+         size += strlen (yytname[YYTRANSLATE (yychar)]);
+         msg = (char *) malloc (size);
          if (msg != 0)
            {
          if (msg != 0)
            {
-             strcpy(msg, "parse error");
+             strcpy (msg, "parse error, unexpected `");
+             strcat (msg, yytname[YYTRANSLATE (yychar)]);
+             strcat (msg, "'");
 
              if (count < 5)
                {
 
              if (count < 5)
                {
@@ -647,21 +651,21 @@ yyerrlab:   /* here on detecting error */
                       x < (sizeof(yytname) / sizeof(char *)); x++)
                    if (yycheck[x + yyn] == x)
                      {
                       x < (sizeof(yytname) / sizeof(char *)); x++)
                    if (yycheck[x + yyn] == x)
                      {
-                       strcat(msg, count == 0 ? ", expecting `" : " or `");
-                       strcat(msg, yytname[x]);
-                       strcat(msg, "'");
+                       strcat (msg, count == 0 ? ", expecting `" : " or `");
+                       strcat (msg, yytname[x]);
+                       strcat (msg, "'");
                        count++;
                      }
                }
                        count++;
                      }
                }
-             yyerror(msg);
-             free(msg);
+             yyerror (msg);
+             free (msg);
            }
          else
            yyerror ("parse error; also virtual memory exceeded");
        }
       else
 #endif /* YYERROR_VERBOSE */
            }
          else
            yyerror ("parse error; also virtual memory exceeded");
        }
       else
 #endif /* YYERROR_VERBOSE */
-       yyerror("parse error");
+       yyerror ("parse error");
     }
 
   goto yyerrlab1;
     }
 
   goto yyerrlab1;
index e71ac990e41483c8bace5a17fda794507c9b6bbe..474e324f14fe442b3a4d29b24bb4649294cb595c 100644 (file)
@@ -635,10 +635,14 @@ yyerrlab:   /* here on detecting error */
               x < (sizeof(yytname) / sizeof(char *)); x++)
            if (yycheck[x + yyn] == x)
              size += strlen(yytname[x]) + 15, count++;
               x < (sizeof(yytname) / sizeof(char *)); x++)
            if (yycheck[x + yyn] == x)
              size += strlen(yytname[x]) + 15, count++;
-         msg = (char *) malloc(size + 15);
+         size += strlen ("parse error, unexpected `") + 1;
+         size += strlen (yytname[YYTRANSLATE (yychar)]);
+         msg = (char *) malloc (size);
          if (msg != 0)
            {
          if (msg != 0)
            {
-             strcpy(msg, "parse error");
+             strcpy (msg, "parse error, unexpected `");
+             strcat (msg, yytname[YYTRANSLATE (yychar)]);
+             strcat (msg, "'");
 
              if (count < 5)
                {
 
              if (count < 5)
                {
@@ -647,21 +651,21 @@ yyerrlab:   /* here on detecting error */
                       x < (sizeof(yytname) / sizeof(char *)); x++)
                    if (yycheck[x + yyn] == x)
                      {
                       x < (sizeof(yytname) / sizeof(char *)); x++)
                    if (yycheck[x + yyn] == x)
                      {
-                       strcat(msg, count == 0 ? ", expecting `" : " or `");
-                       strcat(msg, yytname[x]);
-                       strcat(msg, "'");
+                       strcat (msg, count == 0 ? ", expecting `" : " or `");
+                       strcat (msg, yytname[x]);
+                       strcat (msg, "'");
                        count++;
                      }
                }
                        count++;
                      }
                }
-             yyerror(msg);
-             free(msg);
+             yyerror (msg);
+             free (msg);
            }
          else
            yyerror ("parse error; also virtual memory exceeded");
        }
       else
 #endif /* YYERROR_VERBOSE */
            }
          else
            yyerror ("parse error; also virtual memory exceeded");
        }
       else
 #endif /* YYERROR_VERBOSE */
-       yyerror("parse error");
+       yyerror ("parse error");
     }
 
   goto yyerrlab1;
     }
 
   goto yyerrlab1;