mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 10:13:03 +00:00
* data/glr.c (yynewGLRStackItem, YY_RESERVE_GLRSTACK): New.
(yyaddDeferredAction, yyglrShift, yyglrShiftDefer): Use them. (yyexpandGLRStack, YYRELOC): Define only when YYSTACKEXPANDABLE.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2005-11-10 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* data/glr.c (yynewGLRStackItem, YY_RESERVE_GLRSTACK): New.
|
||||||
|
(yyaddDeferredAction, yyglrShift, yyglrShiftDefer): Use them.
|
||||||
|
(yyexpandGLRStack, YYRELOC): Define only when YYSTACKEXPANDABLE.
|
||||||
|
|
||||||
2005-11-09 Albert Chin-A-Young <china@thewrittenword.com>
|
2005-11-09 Albert Chin-A-Young <china@thewrittenword.com>
|
||||||
|
|
||||||
* m4/cxx.m4, examples/Makefile.am: Don't build
|
* m4/cxx.m4, examples/Makefile.am: Don't build
|
||||||
|
|||||||
104
data/glr.c
104
data/glr.c
@@ -591,6 +591,21 @@ int yydebug;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if YYSTACKEXPANDABLE
|
||||||
|
# define YY_RESERVE_GLRSTACK(Yystack) \
|
||||||
|
do { \
|
||||||
|
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
||||||
|
yyexpandGLRStack (Yystack); \
|
||||||
|
} while (/*CONSTCOND*/ 0)
|
||||||
|
#else
|
||||||
|
# define YY_RESERVE_GLRSTACK(Yystack) \
|
||||||
|
do { \
|
||||||
|
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
||||||
|
yyMemoryExhausted (Yystack); \
|
||||||
|
} while (/*CONSTCOND*/ 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
||||||
|
|
||||||
# ifndef yystpcpy
|
# ifndef yystpcpy
|
||||||
@@ -1020,21 +1035,32 @@ yyisErrorAction (int yyaction)
|
|||||||
|
|
||||||
/* GLRStates */
|
/* GLRStates */
|
||||||
|
|
||||||
|
/** Return a fresh GLRStackItem. Callers should call
|
||||||
|
* YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
|
||||||
|
* headroom. */
|
||||||
|
|
||||||
|
static inline yyGLRStackItem*
|
||||||
|
yynewGLRStackItem (yyGLRStack* yystack, yybool yyisState)
|
||||||
|
{
|
||||||
|
yyGLRStackItem* yynewItem = yystack->yynextFree;
|
||||||
|
yystack->yyspaceLeft -= 1;
|
||||||
|
yystack->yynextFree += 1;
|
||||||
|
yynewItem->yystate.yyisState = yyisState;
|
||||||
|
return yynewItem;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
|
yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
|
||||||
yyGLRState* rhs, yyRuleNum yyrule)
|
yyGLRState* rhs, yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
yySemanticOption* yynewItem;
|
yySemanticOption* yynewOption =
|
||||||
yynewItem = &yystack->yynextFree->yyoption;
|
&yynewGLRStackItem (yystack, yyfalse)->yyoption;
|
||||||
yystack->yyspaceLeft -= 1;
|
yynewOption->yystate = rhs;
|
||||||
yystack->yynextFree += 1;
|
yynewOption->yyrule = yyrule;
|
||||||
yynewItem->yyisState = yyfalse;
|
yynewOption->yynext = yystate->yysemantics.yyfirstVal;
|
||||||
yynewItem->yystate = rhs;
|
yystate->yysemantics.yyfirstVal = yynewOption;
|
||||||
yynewItem->yyrule = yyrule;
|
|
||||||
yynewItem->yynext = yystate->yysemantics.yyfirstVal;
|
YY_RESERVE_GLRSTACK (yystack);
|
||||||
yystate->yysemantics.yyfirstVal = yynewItem;
|
|
||||||
if (yystack->yyspaceLeft < YYHEADROOM)
|
|
||||||
yyexpandGLRStack (yystack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GLRStacks */
|
/* GLRStacks */
|
||||||
@@ -1075,7 +1101,9 @@ yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
|
|||||||
return yyinitStateSet (&yystack->yytops);
|
return yyinitStateSet (&yystack->yytops);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
|
||||||
|
#if YYSTACKEXPANDABLE
|
||||||
|
# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
||||||
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
|
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
|
||||||
|
|
||||||
/** If STACK is expandable, extend it. WARNING: Pointers into the
|
/** If STACK is expandable, extend it. WARNING: Pointers into the
|
||||||
@@ -1086,7 +1114,6 @@ yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
|
|||||||
static void
|
static void
|
||||||
yyexpandGLRStack (yyGLRStack* yystack)
|
yyexpandGLRStack (yyGLRStack* yystack)
|
||||||
{
|
{
|
||||||
#if YYSTACKEXPANDABLE
|
|
||||||
yyGLRStackItem* yynewItems;
|
yyGLRStackItem* yynewItems;
|
||||||
yyGLRStackItem* yyp0, *yyp1;
|
yyGLRStackItem* yyp0, *yyp1;
|
||||||
size_t yysize, yynewSize;
|
size_t yysize, yynewSize;
|
||||||
@@ -1139,11 +1166,8 @@ yyexpandGLRStack (yyGLRStack* yystack)
|
|||||||
yystack->yyitems = yynewItems;
|
yystack->yyitems = yynewItems;
|
||||||
yystack->yynextFree = yynewItems + yysize;
|
yystack->yynextFree = yynewItems + yysize;
|
||||||
yystack->yyspaceLeft = yynewSize - yysize;
|
yystack->yyspaceLeft = yynewSize - yysize;
|
||||||
|
|
||||||
#else
|
|
||||||
yyMemoryExhausted (yystack);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
yyfreeGLRStack (yyGLRStack* yystack)
|
yyfreeGLRStack (yyGLRStack* yystack)
|
||||||
@@ -1221,21 +1245,17 @@ yyglrShift (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
|
|||||||
size_t yyposn,
|
size_t yyposn,
|
||||||
YYSTYPE yysval, YYLTYPE* yylocp)
|
YYSTYPE yysval, YYLTYPE* yylocp)
|
||||||
{
|
{
|
||||||
yyGLRStackItem* yynewItem;
|
yyGLRState* yynewState = &yynewGLRStackItem (yystack, yytrue)->yystate;
|
||||||
|
|
||||||
yynewItem = yystack->yynextFree;
|
yynewState->yylrState = yylrState;
|
||||||
yystack->yynextFree += 1;
|
yynewState->yyposn = yyposn;
|
||||||
yystack->yyspaceLeft -= 1;
|
yynewState->yyresolved = yytrue;
|
||||||
yynewItem->yystate.yyisState = yytrue;
|
yynewState->yypred = yystack->yytops.yystates[yyk];
|
||||||
yynewItem->yystate.yylrState = yylrState;
|
yynewState->yysemantics.yysval = yysval;
|
||||||
yynewItem->yystate.yyposn = yyposn;
|
yynewState->yyloc = *yylocp;
|
||||||
yynewItem->yystate.yyresolved = yytrue;
|
yystack->yytops.yystates[yyk] = yynewState;
|
||||||
yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
|
|
||||||
yystack->yytops.yystates[yyk] = &yynewItem->yystate;
|
YY_RESERVE_GLRSTACK (yystack);
|
||||||
yynewItem->yystate.yysemantics.yysval = yysval;
|
|
||||||
yynewItem->yystate.yyloc = *yylocp;
|
|
||||||
if (yystack->yyspaceLeft < YYHEADROOM)
|
|
||||||
yyexpandGLRStack (yystack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shift stack #K of YYSTACK, to a new state corresponding to LR
|
/** Shift stack #K of YYSTACK, to a new state corresponding to LR
|
||||||
@@ -1245,19 +1265,17 @@ static inline void
|
|||||||
yyglrShiftDefer (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
|
yyglrShiftDefer (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
|
||||||
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
|
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
yyGLRStackItem* yynewItem;
|
yyGLRState* yynewState = &yynewGLRStackItem (yystack, yytrue)->yystate;
|
||||||
|
|
||||||
yynewItem = yystack->yynextFree;
|
yynewState->yylrState = yylrState;
|
||||||
yynewItem->yystate.yyisState = yytrue;
|
yynewState->yyposn = yyposn;
|
||||||
yynewItem->yystate.yylrState = yylrState;
|
yynewState->yyresolved = yyfalse;
|
||||||
yynewItem->yystate.yyposn = yyposn;
|
yynewState->yypred = yystack->yytops.yystates[yyk];
|
||||||
yynewItem->yystate.yyresolved = yyfalse;
|
yynewState->yysemantics.yyfirstVal = NULL;
|
||||||
yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
|
yystack->yytops.yystates[yyk] = yynewState;
|
||||||
yynewItem->yystate.yysemantics.yyfirstVal = NULL;
|
|
||||||
yystack->yytops.yystates[yyk] = &yynewItem->yystate;
|
/* Invokes YY_RESERVE_GLRSTACK. */
|
||||||
yystack->yynextFree += 1;
|
yyaddDeferredAction (yystack, yynewState, rhs, yyrule);
|
||||||
yystack->yyspaceLeft -= 1;
|
|
||||||
yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pop the symbols consumed by reduction #RULE from the top of stack
|
/** Pop the symbols consumed by reduction #RULE from the top of stack
|
||||||
|
|||||||
Reference in New Issue
Block a user