(yytokenName): Bullet-proof against YYEMPTY token.

(yyreportSyntaxError): Handle case where lookahead token is
YYEMPTY.
This commit is contained in:
Paul Eggert
2004-02-02 22:35:53 +00:00
parent be16239bf7
commit d0d5aa6425

View File

@@ -1,7 +1,7 @@
m4_divert(-1) -*- C -*-
# GLR skeleton for Bison
# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -636,6 +636,9 @@ yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yyformat, ...)
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)