mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
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.
This commit is contained in:
57
data/glr.c
57
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. */
|
/* This is the parser code for GLR (Generalized LR) parser. */
|
||||||
|
|
||||||
/* FIXME: minimize these */
|
/* FIXME: minimize these */
|
||||||
#include <stdlib.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Identify Bison output. */
|
/* Identify Bison output. */
|
||||||
#define YYBISON 1
|
#define YYBISON 1
|
||||||
@@ -1497,7 +1498,8 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
|
|||||||
{
|
{
|
||||||
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
||||||
yySymbol* const yytokenp = yystack->yytokenp;
|
yySymbol* const yytokenp = yystack->yytokenp;
|
||||||
int yyn, yyx, yycount, yysize;
|
int yyn, yyx, yycount;
|
||||||
|
size_t yysize;
|
||||||
const char* yyprefix;
|
const char* yyprefix;
|
||||||
char* yyp;
|
char* yyp;
|
||||||
char* yymsg;
|
char* yymsg;
|
||||||
@@ -1760,21 +1762,20 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED;
|
static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED;
|
||||||
static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED;
|
static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED;
|
||||||
|
|
||||||
|
static void
|
||||||
|
yy_yypstack (yyGLRState* yys)
|
||||||
|
{
|
||||||
|
if (yys->yypred)
|
||||||
|
{
|
||||||
|
yy_yypstack (yys->yypred);
|
||||||
|
fprintf (stderr, " -> ");
|
||||||
|
}
|
||||||
|
fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long) yys->yyposn);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
yypstates (yyGLRState* yyst)
|
yypstates (yyGLRState* yyst)
|
||||||
{
|
{
|
||||||
static void
|
|
||||||
yy_yypstack (yyGLRState* yys)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (yyst == NULL)
|
if (yyst == NULL)
|
||||||
fprintf (stderr, "<null>");
|
fprintf (stderr, "<null>");
|
||||||
else
|
else
|
||||||
@@ -1799,28 +1800,30 @@ yypdumpstack (yyGLRStack* yystack)
|
|||||||
size_t yyi;
|
size_t yyi;
|
||||||
for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
|
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)
|
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.yyresolved, yyp->yystate.yylrState,
|
||||||
yyp->yystate.yyposn,
|
(unsigned long) yyp->yystate.yyposn,
|
||||||
YYINDEX(yyp->yystate.yypred));
|
(long) YYINDEX (yyp->yystate.yypred));
|
||||||
if (! yyp->yystate.yyresolved)
|
if (! yyp->yystate.yyresolved)
|
||||||
fprintf (stderr, ", firstVal: %d",
|
fprintf (stderr, ", firstVal: %ld",
|
||||||
YYINDEX (yyp->yystate.yysemantics.yyfirstVal));
|
(long) YYINDEX (yyp->yystate.yysemantics.yyfirstVal));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Option. rule: %d, state: %d, next: %d",
|
fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld",
|
||||||
yyp->yyoption.yyrule, YYINDEX (yyp->yyoption.yystate),
|
yyp->yyoption.yyrule,
|
||||||
YYINDEX (yyp->yyoption.yynext));
|
(long) YYINDEX (yyp->yyoption.yystate),
|
||||||
|
(long) YYINDEX (yyp->yyoption.yynext));
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
fprintf (stderr, "Tops:");
|
fprintf (stderr, "Tops:");
|
||||||
for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
|
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");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user