mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
On syntax errors, report the token on which we choked.
* bison.s1 (yyparse): In the label yyerrlab, when YYERROR_VERBOSE, add yychar in msg.
This commit is contained in:
@@ -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>
|
2000-03-17 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* reader.c (copy_at): New function.
|
* reader.c (copy_at): New function.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
aclocal && \
|
aclocal -I m4 && \
|
||||||
gettextize && \
|
gettextize && \
|
||||||
autoconf && \
|
autoconf && \
|
||||||
autoheader && \
|
autoheader && \
|
||||||
|
|||||||
20
src/bison.s1
20
src/bison.s1
@@ -635,10 +635,14 @@ yyerrlab: /* here on detecting error */
|
|||||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
x < (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++;
|
||||||
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++)
|
x < (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, "'");
|
strcat (msg, "'");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyerror(msg);
|
yyerror (msg);
|
||||||
free(msg);
|
free (msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yyerror ("parse error; also virtual memory exceeded");
|
yyerror ("parse error; also virtual memory exceeded");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
yyerror("parse error");
|
yyerror ("parse error");
|
||||||
}
|
}
|
||||||
|
|
||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
|
|||||||
@@ -635,10 +635,14 @@ yyerrlab: /* here on detecting error */
|
|||||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
x < (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++;
|
||||||
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++)
|
x < (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, "'");
|
strcat (msg, "'");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyerror(msg);
|
yyerror (msg);
|
||||||
free(msg);
|
free (msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yyerror ("parse error; also virtual memory exceeded");
|
yyerror ("parse error; also virtual memory exceeded");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
yyerror("parse error");
|
yyerror ("parse error");
|
||||||
}
|
}
|
||||||
|
|
||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
|
|||||||
Reference in New Issue
Block a user