mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 09:43:03 +00:00
* data/glr.c (yyGLRStateSet): Rename yylookaheadStatuses to
yylookaheadNeeds. All uses updated. (yysplitStack): Rename local yynewLookaheadStatuses to yynewLookaheadNeeds. * data/glr-regression.at (Incorrect lookahead during nondeterministic GLR): In comments, change `lookahead status' to `lookahead need'.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2006-01-12 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
|
* data/glr.c (yyGLRStateSet): Rename yylookaheadStatuses to
|
||||||
|
yylookaheadNeeds. All uses updated.
|
||||||
|
(yysplitStack): Rename local yynewLookaheadStatuses to
|
||||||
|
yynewLookaheadNeeds.
|
||||||
|
* data/glr-regression.at (Incorrect lookahead during nondeterministic
|
||||||
|
GLR): In comments, change `lookahead status' to `lookahead need'.
|
||||||
|
|
||||||
2006-01-11 Paul Hilfinger <hilfingr@tully.CS.Berkeley.EDU>
|
2006-01-11 Paul Hilfinger <hilfingr@tully.CS.Berkeley.EDU>
|
||||||
|
|
||||||
* data/glr.c (yysplitStack): A little stylistic rewrite.
|
* data/glr.c (yysplitStack): A little stylistic rewrite.
|
||||||
|
|||||||
42
data/glr.c
42
data/glr.c
@@ -761,11 +761,11 @@ struct yyGLRState {
|
|||||||
|
|
||||||
struct yyGLRStateSet {
|
struct yyGLRStateSet {
|
||||||
yyGLRState** yystates;
|
yyGLRState** yystates;
|
||||||
/** During nondeterministic operation, yylookaheadStatuses tracks which
|
/** During nondeterministic operation, yylookaheadNeeds tracks which
|
||||||
* stacks have actually needed the current lookahead. During deterministic
|
* stacks have actually needed the current lookahead. During deterministic
|
||||||
* operation, yylookaheadStatuses[0] is not maintained since it would merely
|
* operation, yylookaheadNeeds[0] is not maintained since it would merely
|
||||||
* duplicate yychar != YYEMPTY. */
|
* duplicate yychar != YYEMPTY. */
|
||||||
yybool* yylookaheadStatuses;
|
yybool* yylookaheadNeeds;
|
||||||
size_t yysize, yycapacity;
|
size_t yysize, yycapacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1113,7 +1113,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
|||||||
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
|
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
|
||||||
yynewOption->yystate = rhs;
|
yynewOption->yystate = rhs;
|
||||||
yynewOption->yyrule = yyrule;
|
yynewOption->yyrule = yyrule;
|
||||||
if (yystackp->yytops.yylookaheadStatuses[yyk])
|
if (yystackp->yytops.yylookaheadNeeds[yyk])
|
||||||
{
|
{
|
||||||
yynewOption->yyrawchar = yychar;
|
yynewOption->yyrawchar = yychar;
|
||||||
yynewOption->yyval = yylval;
|
yynewOption->yyval = yylval;
|
||||||
@@ -1139,9 +1139,9 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
|||||||
if (! yyset->yystates)
|
if (! yyset->yystates)
|
||||||
return yyfalse;
|
return yyfalse;
|
||||||
yyset->yystates[0] = NULL;
|
yyset->yystates[0] = NULL;
|
||||||
yyset->yylookaheadStatuses =
|
yyset->yylookaheadNeeds =
|
||||||
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadStatuses[0]);
|
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
|
||||||
if (! yyset->yylookaheadStatuses)
|
if (! yyset->yylookaheadNeeds)
|
||||||
{
|
{
|
||||||
YYFREE (yyset->yystates);
|
YYFREE (yyset->yystates);
|
||||||
return yyfalse;
|
return yyfalse;
|
||||||
@@ -1152,7 +1152,7 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
|||||||
static void yyfreeStateSet (yyGLRStateSet* yyset)
|
static void yyfreeStateSet (yyGLRStateSet* yyset)
|
||||||
{
|
{
|
||||||
YYFREE (yyset->yystates);
|
YYFREE (yyset->yystates);
|
||||||
YYFREE (yyset->yylookaheadStatuses);
|
YYFREE (yyset->yylookaheadNeeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize STACK to a single empty stack, with total maximum
|
/** Initialize STACK to a single empty stack, with total maximum
|
||||||
@@ -1300,12 +1300,12 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
|||||||
{
|
{
|
||||||
yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi];
|
yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi];
|
||||||
/* In the current implementation, it's unnecessary to copy
|
/* In the current implementation, it's unnecessary to copy
|
||||||
yystackp->yytops.yylookaheadStatuses[yyi] since, after
|
yystackp->yytops.yylookaheadNeeds[yyi] since, after
|
||||||
yyremoveDeletes returns, the parser immediately either enters
|
yyremoveDeletes returns, the parser immediately either enters
|
||||||
deterministic operation or shifts a token. However, it doesn't
|
deterministic operation or shifts a token. However, it doesn't
|
||||||
hurt, and the code might evolve to need it. */
|
hurt, and the code might evolve to need it. */
|
||||||
yystackp->yytops.yylookaheadStatuses[yyj] =
|
yystackp->yytops.yylookaheadNeeds[yyj] =
|
||||||
yystackp->yytops.yylookaheadStatuses[yyi];
|
yystackp->yytops.yylookaheadNeeds[yyi];
|
||||||
if (yyj != yyi)
|
if (yyj != yyi)
|
||||||
{
|
{
|
||||||
YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
|
YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
|
||||||
@@ -1533,7 +1533,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
|||||||
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
|
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
|
||||||
{
|
{
|
||||||
yyGLRState** yynewStates;
|
yyGLRState** yynewStates;
|
||||||
yybool* yynewLookaheadStatuses;
|
yybool* yynewLookaheadNeeds;
|
||||||
|
|
||||||
yynewStates = NULL;
|
yynewStates = NULL;
|
||||||
|
|
||||||
@@ -1550,18 +1550,18 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
|||||||
yyMemoryExhausted (yystackp);
|
yyMemoryExhausted (yystackp);
|
||||||
yystackp->yytops.yystates = yynewStates;
|
yystackp->yytops.yystates = yynewStates;
|
||||||
|
|
||||||
yynewLookaheadStatuses =
|
yynewLookaheadNeeds =
|
||||||
(yybool*) YYREALLOC (yystackp->yytops.yylookaheadStatuses,
|
(yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
|
||||||
(yystackp->yytops.yycapacity
|
(yystackp->yytops.yycapacity
|
||||||
* sizeof yynewLookaheadStatuses[0]));
|
* sizeof yynewLookaheadNeeds[0]));
|
||||||
if (yynewLookaheadStatuses == NULL)
|
if (yynewLookaheadNeeds == NULL)
|
||||||
yyMemoryExhausted (yystackp);
|
yyMemoryExhausted (yystackp);
|
||||||
yystackp->yytops.yylookaheadStatuses = yynewLookaheadStatuses;
|
yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
|
||||||
}
|
}
|
||||||
yystackp->yytops.yystates[yystackp->yytops.yysize]
|
yystackp->yytops.yystates[yystackp->yytops.yysize]
|
||||||
= yystackp->yytops.yystates[yyk];
|
= yystackp->yytops.yystates[yyk];
|
||||||
yystackp->yytops.yylookaheadStatuses[yystackp->yytops.yysize]
|
yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
|
||||||
= yystackp->yytops.yylookaheadStatuses[yyk];
|
= yystackp->yytops.yylookaheadNeeds[yyk];
|
||||||
yystackp->yytops.yysize += 1;
|
yystackp->yytops.yysize += 1;
|
||||||
return yystackp->yytops.yysize-1;
|
return yystackp->yytops.yysize-1;
|
||||||
}
|
}
|
||||||
@@ -1953,7 +1953,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yystackp->yytops.yylookaheadStatuses[yyk] = yytrue;
|
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
||||||
if (*yytokenp == YYEMPTY)
|
if (*yytokenp == YYEMPTY)
|
||||||
{
|
{
|
||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((stderr, "Reading a token: "));
|
||||||
@@ -2318,7 +2318,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
|||||||
size_t yyn = yystack.yytops.yysize;
|
size_t yyn = yystack.yytops.yysize;
|
||||||
|
|
||||||
for (yys = 0; yys < yyn; yys += 1)
|
for (yys = 0; yys < yyn; yys += 1)
|
||||||
yystackp->yytops.yylookaheadStatuses[yys] = yychar != YYEMPTY;
|
yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
|
||||||
|
|
||||||
/* yyprocessOneStack returns one of three things:
|
/* yyprocessOneStack returns one of three things:
|
||||||
|
|
||||||
|
|||||||
@@ -1151,17 +1151,17 @@ AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
|||||||
AT_DATA_GRAMMAR([glr-regr14.y],
|
AT_DATA_GRAMMAR([glr-regr14.y],
|
||||||
[[
|
[[
|
||||||
/* Tests:
|
/* Tests:
|
||||||
- Conflicting actions (split-off parse, which copies lookahead status,
|
- Conflicting actions (split-off parse, which copies lookahead need,
|
||||||
which is necessarily yytrue) and nonconflicting actions (non-split-off
|
which is necessarily yytrue) and nonconflicting actions (non-split-off
|
||||||
parse) for nondefaulted state: yychar != YYEMPTY.
|
parse) for nondefaulted state: yychar != YYEMPTY.
|
||||||
- Merged deferred actions (lookahead status and RHS from different stack
|
- Merged deferred actions (lookahead need and RHS from different stack
|
||||||
than the target state) and nonmerged deferred actions (same stack).
|
than the target state) and nonmerged deferred actions (same stack).
|
||||||
- Defaulted state after lookahead: yychar != YYEMPTY.
|
- Defaulted state after lookahead: yychar != YYEMPTY.
|
||||||
- Defaulted state after shift: yychar == YYEMPTY.
|
- Defaulted state after shift: yychar == YYEMPTY.
|
||||||
- yychar != YYEMPTY but lookahead status is yyfalse (a previous stack has
|
- yychar != YYEMPTY but lookahead need is yyfalse (a previous stack has
|
||||||
seen the lookahead but current stack has not).
|
seen the lookahead but current stack has not).
|
||||||
- Exceeding stack capacity (stack explosion), and thus reallocating
|
- Exceeding stack capacity (stack explosion), and thus reallocating
|
||||||
lookahead status array.
|
lookahead need array.
|
||||||
Note that it does not seem possible to see the initial yychar value during
|
Note that it does not seem possible to see the initial yychar value during
|
||||||
nondeterministic operation since:
|
nondeterministic operation since:
|
||||||
- In order to preserve the initial yychar, only defaulted states may be
|
- In order to preserve the initial yychar, only defaulted states may be
|
||||||
@@ -1193,8 +1193,7 @@ start:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* When merging the 2 deferred actions, the lookahead statuses are
|
/* When merging the 2 deferred actions, the lookahead needs are different. */
|
||||||
different. */
|
|
||||||
merge:
|
merge:
|
||||||
nonconflict1 'a' 'b' nonconflict2 %dprec 1 {
|
nonconflict1 'a' 'b' nonconflict2 %dprec 1 {
|
||||||
USE ($2); USE ($3);
|
USE ($2); USE ($3);
|
||||||
@@ -1232,7 +1231,7 @@ defstate_look:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* yychar != YYEMPTY but lookahead status is yyfalse. */
|
/* yychar != YYEMPTY but lookahead need is yyfalse. */
|
||||||
defstate_shift:
|
defstate_shift:
|
||||||
{
|
{
|
||||||
print_look_ahead ("defstate_shift <- empty string");
|
print_look_ahead ("defstate_shift <- empty string");
|
||||||
|
|||||||
Reference in New Issue
Block a user