* src/state.h, src/state.c (reductions_new): New.

* src/LR0.c (set_state_table): Let all the states have a
`reductions', even if reduced to 0.
(save_reductions): Adjust.
* src/lalr.c (initialize_LA, initialize_lookaheads): Adjust.
* src/print.c (print_reductions, print_actions): Adjust.
* src/output.c (action_row): Adjust.
This commit is contained in:
Akim Demaille
2001-12-27 18:11:06 +00:00
parent 2cec70b9f1
commit 80dac38c5e
7 changed files with 49 additions and 26 deletions

View File

@@ -137,7 +137,6 @@ initialize_LA (void)
int i;
int j;
short *np;
reductions *rp;
/* Avoid having to special case 0. */
if (!nLA)
@@ -150,9 +149,8 @@ initialize_LA (void)
np = LAruleno;
for (i = 0; i < nstates; i++)
if (!state_table[i]->consistent)
if ((rp = state_table[i]->reductions))
for (j = 0; j < rp->nreds; j++)
*np++ = rp->rules[j];
for (j = 0; j < state_table[i]->reductions->nreds; j++)
*np++ = state_table[i]->reductions->rules[j];
}
@@ -525,8 +523,12 @@ initialize_lookaheads (void)
reductions *rp = state_table[i]->reductions;
shifts *sp = state_table[i]->shifts;
if (rp
&& (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
/* We need a lookahead either to distinguish different
reductions (i.e., there are two or more), or to distinguish a
reduction from a shift. Otherwise, it is straightforward,
and the state is `consistent'. */
if (rp->nreds > 1
|| (rp->nreds == 1 && sp->nshifts && SHIFT_IS_SHIFT (sp, 0)))
nlookaheads += rp->nreds;
else
state_table[i]->consistent = 1;