From: Paul Eggert Date: Mon, 12 Aug 2002 14:02:32 +0000 (+0000) Subject: Include string.h, for strlen. X-Git-Tag: BISON-1_49b~47 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/cf126971ad414473f977aedc360ad6a72f84c4a8 Include string.h, for strlen. (yyreportParseError): Use size_t for yysize. (yy_yypstack): No longer nested inside yypstates, as nested functions are not portable. Do not assume size_t is the same width as int. (yypstates): Do not assume that ptrdiff_t is the same width as int, and similarly for yyposn and YYINDEX. --- diff --git a/data/glr.c b/data/glr.c index c2fab0b8..6824d2bf 100644 --- a/data/glr.c +++ b/data/glr.c @@ -108,11 +108,12 @@ b4_copyright([Skeleton parser for GLR parsing with Bison], [2002]) /* This is the parser code for GLR (Generalized LR) parser. */ /* FIXME: minimize these */ -#include +#include #include -#include #include -#include +#include +#include +#include /* Identify Bison output. */ #define YYBISON 1 @@ -1497,7 +1498,8 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) { #if YYERROR_VERBOSE yySymbol* const yytokenp = yystack->yytokenp; - int yyn, yyx, yycount, yysize; + int yyn, yyx, yycount; + size_t yysize; const char* yyprefix; char* yyp; char* yymsg; @@ -1761,20 +1763,19 @@ static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED; static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED; static void -yypstates (yyGLRState* yyst) +yy_yypstack (yyGLRState* yys) { - static void - yy_yypstack (yyGLRState* yys) + if (yys->yypred) { - if (yys->yypred == NULL) - fprintf (stderr, "%d@%d", yys->yylrState, yys->yyposn); - else - { - yy_yypstack (yys->yypred); - fprintf (stderr, " -> %d@%d", yys->yylrState, yys->yyposn); - } + yy_yypstack (yys->yypred); + fprintf (stderr, " -> "); } + fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long) yys->yyposn); +} +static void +yypstates (yyGLRState* yyst) +{ if (yyst == NULL) fprintf (stderr, ""); else @@ -1799,28 +1800,30 @@ yypdumpstack (yyGLRStack* yystack) size_t yyi; for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1) { - fprintf (stderr, "%3d. ", yyp - yystack->yyitems); + fprintf (stderr, "%3lu. ", (unsigned long) (yyp - yystack->yyitems)); if (*(bool*) yyp) { - fprintf (stderr, "Res: %d, LR State: %d, posn: %d, pred: %d", + fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld", yyp->yystate.yyresolved, yyp->yystate.yylrState, - yyp->yystate.yyposn, - YYINDEX(yyp->yystate.yypred)); + (unsigned long) yyp->yystate.yyposn, + (long) YYINDEX (yyp->yystate.yypred)); if (! yyp->yystate.yyresolved) - fprintf (stderr, ", firstVal: %d", - YYINDEX (yyp->yystate.yysemantics.yyfirstVal)); + fprintf (stderr, ", firstVal: %ld", + (long) YYINDEX (yyp->yystate.yysemantics.yyfirstVal)); } else { - fprintf (stderr, "Option. rule: %d, state: %d, next: %d", - yyp->yyoption.yyrule, YYINDEX (yyp->yyoption.yystate), - YYINDEX (yyp->yyoption.yynext)); + fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld", + yyp->yyoption.yyrule, + (long) YYINDEX (yyp->yyoption.yystate), + (long) YYINDEX (yyp->yyoption.yynext)); } fprintf (stderr, "\n"); } fprintf (stderr, "Tops:"); for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) - fprintf (stderr, "%d: %d; ", yyi, YYINDEX (yystack->yytops.yystates[yyi])); + fprintf (stderr, "%lu: %ld; ", (unsigned long) yyi, + (long) YYINDEX (yystack->yytops.yystates[yyi])); fprintf (stderr, "\n"); }