Mail Archives: djgpp/1997/08/08/19:38:11
I have noticed that if a bison file is compiled as C++ for use with
classes, say, it generates a pair of warnings about comparisons between
signed and unsigned. These can be a nuisance, and if you use -werror, worse.
Consequently I have come up with a simple patch that changes two lines of
BISON.SIM without altering the functionality, but that gets rid of the
warnings in C++.
The two lines are clearly marked by comments.
And just out of curiosity, what is BISON.HAI? It comes with BISON.SIM, but
it's only BISON.SIM that I've ever seen get incorporated into parsers by
Bison.
.
.
.
#ifdef YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
for (x = (yyn < 0 ? -yyn : 0);
x < ((int)sizeof(yytname) / (int)sizeof(char *)); x++) /* (int) added by PGD to fix warnings when using C++ */
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
if (msg != 0)
{
strcpy(msg, "parse error");
if (count < 5)
{
count = 0;
for (x = (yyn < 0 ? -yyn : 0);
x < ((int)sizeof(yytname) / (int)sizeof(char *)); x++) /* (int) added by PGD to fix warnings when using C++ */
if (yycheck[x + yyn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
strcat(msg, yytname[x]);
strcat(msg, "'");
count++;
}
}
yyerror(msg);
free(msg);
}
else
yyerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
yyerror("parse error");
}
.
.
.
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -