From: Akim Demaille Date: Fri, 17 Mar 2000 13:17:09 +0000 (+0000) Subject: On syntax errors, report the token on which we choked. X-Git-Tag: BISON-1_28b~158 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/75bbe78d87984e9c965b418f7a1bf20e0765f07d?ds=sidebyside On syntax errors, report the token on which we choked. * bison.s1 (yyparse): In the label yyerrlab, when YYERROR_VERBOSE, add yychar in msg. --- diff --git a/ChangeLog b/ChangeLog index a1274aab..b0e45468 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-03-17 Akim Demaille + + 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 * reader.c (copy_at): New function. diff --git a/pre-config b/pre-config index 8ce69f65..dce7fc8e 100755 --- a/pre-config +++ b/pre-config @@ -1,6 +1,6 @@ #! /bin/sh -aclocal && \ +aclocal -I m4 && \ gettextize && \ autoconf && \ autoheader && \ diff --git a/src/bison.s1 b/src/bison.s1 index e71ac990..474e324f 100644 --- a/src/bison.s1 +++ b/src/bison.s1 @@ -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++; - msg = (char *) malloc(size + 15); + size += strlen ("parse error, unexpected `") + 1; + size += strlen (yytname[YYTRANSLATE (yychar)]); + msg = (char *) malloc (size); if (msg != 0) { - strcpy(msg, "parse error"); + strcpy (msg, "parse error, unexpected `"); + strcat (msg, yytname[YYTRANSLATE (yychar)]); + strcat (msg, "'"); if (count < 5) { @@ -647,21 +651,21 @@ yyerrlab: /* here on detecting error */ 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++; } } - yyerror(msg); - free(msg); + yyerror (msg); + free (msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); + yyerror ("parse error"); } goto yyerrlab1; diff --git a/src/bison.simple b/src/bison.simple index e71ac990..474e324f 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -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++; - msg = (char *) malloc(size + 15); + size += strlen ("parse error, unexpected `") + 1; + size += strlen (yytname[YYTRANSLATE (yychar)]); + msg = (char *) malloc (size); if (msg != 0) { - strcpy(msg, "parse error"); + strcpy (msg, "parse error, unexpected `"); + strcat (msg, yytname[YYTRANSLATE (yychar)]); + strcat (msg, "'"); if (count < 5) { @@ -647,21 +651,21 @@ yyerrlab: /* here on detecting error */ 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++; } } - yyerror(msg); - free(msg); + yyerror (msg); + free (msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); + yyerror ("parse error"); } goto yyerrlab1;