[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fixes to allow glr.c to be used for C++ as well.
From: |
Paul Hilfinger |
Subject: |
Re: [PATCH] Fixes to allow glr.c to be used for C++ as well. |
Date: |
Wed, 14 Jan 2004 19:58:14 -0800 |
Here's a corrected, and tested version of the fix for blowing up on
YYEMPTY:
2004-01-14 Paul Hilfinger <address@hidden>
* data/glr.c (yytokenName): Bullet-proof against YYEMPTY token.
(yyreportSyntaxError): Handle case where lookahead token is
YYEMPTY.
Index: bison-1_5.79/data/glr.c
--- bison-1_5.79/data/glr.c Tue, 13 Jan 2004 16:49:19 -0800 hilfingr
(glrbison/e/14_glr-parser 1.27.1.33.1.5 644)
+++ tmp.9(w)/data/glr.c Wed, 14 Jan 2004 19:24:32 -0800 hilfingr
(glrbison/e/14_glr-parser 1.27.1.33.1.7 644)
@@ -636,6 +636,9 @@ yyFail (yyGLRStack* yystack]b4_pure_form
static inline const char*
yytokenName (yySymbol yytoken)
{
+ if (yytoken == YYEMPTY)
+ return "";
+
return yytname[yytoken];
}
#endif
@@ -1653,7 +1656,8 @@ yyreportSyntaxError (yyGLRStack* yystack
if (yymsg != 0)
{
char* yyp = yymsg;
- sprintf (yyp, "syntax error, unexpected %s",
+ sprintf (yyp, "syntax error%s%s",
+ (*yytokenp == YYEMPTY ? "" : ", unexpected "),
yytokenName (*yytokenp));
yyp += strlen (yyp);
if (yycount < 5)