mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
* src/lalr.c (initialize_lookaheads): New. Extracted from...
* src/LR0.c (set_state_table): here. * src/lalr.c (lalr): Call it.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2001-12-10 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/lalr.c (initialize_lookaheads): New. Extracted from...
|
||||||
|
* src/LR0.c (set_state_table): here.
|
||||||
|
* src/lalr.c (lalr): Call it.
|
||||||
|
|
||||||
2001-12-10 Akim Demaille <akim@epita.fr>
|
2001-12-10 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/state.h (shifts): Remove the `number' member: shifts are
|
* src/state.h (shifts): Remove the `number' member: shifts are
|
||||||
|
|||||||
33
src/LR0.c
33
src/LR0.c
@@ -560,39 +560,6 @@ set_state_table (void)
|
|||||||
if (!state_table[i]->shifts)
|
if (!state_table[i]->shifts)
|
||||||
state_table[i]->shifts = shifts_new (0);
|
state_table[i]->shifts = shifts_new (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initializing the lookaheads members. Please note that it must be
|
|
||||||
performed after having set some of the other members which are
|
|
||||||
used below. Change with extreme caution. */
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int count = 0;
|
|
||||||
for (i = 0; i < nstates; i++)
|
|
||||||
{
|
|
||||||
int k;
|
|
||||||
reductions *rp = state_table[i]->reductions;
|
|
||||||
shifts *sp = state_table[i]->shifts;
|
|
||||||
|
|
||||||
state_table[i]->lookaheads = count;
|
|
||||||
|
|
||||||
if (rp
|
|
||||||
&& (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
|
|
||||||
count += rp->nreds;
|
|
||||||
else
|
|
||||||
state_table[i]->consistent = 1;
|
|
||||||
|
|
||||||
for (k = 0; k < sp->nshifts; k++)
|
|
||||||
if (SHIFT_IS_ERROR (sp, k))
|
|
||||||
{
|
|
||||||
state_table[i]->consistent = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Seems to be needed by conflicts.c. */
|
|
||||||
state_table[nstates] = STATE_ALLOC (0);
|
|
||||||
state_table[nstates]->lookaheads = count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
|
|||||||
37
src/lalr.c
37
src/lalr.c
@@ -534,11 +534,48 @@ compute_lookaheads (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------.
|
||||||
|
| Initializing the lookaheads members. |
|
||||||
|
`--------------------------------------*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialize_lookaheads (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int count = 0;
|
||||||
|
for (i = 0; i < nstates; i++)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
reductions *rp = state_table[i]->reductions;
|
||||||
|
shifts *sp = state_table[i]->shifts;
|
||||||
|
|
||||||
|
state_table[i]->lookaheads = count;
|
||||||
|
|
||||||
|
if (rp
|
||||||
|
&& (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
|
||||||
|
count += rp->nreds;
|
||||||
|
else
|
||||||
|
state_table[i]->consistent = 1;
|
||||||
|
|
||||||
|
for (k = 0; k < sp->nshifts; k++)
|
||||||
|
if (SHIFT_IS_ERROR (sp, k))
|
||||||
|
{
|
||||||
|
state_table[i]->consistent = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Seems to be needed by conflicts.c. */
|
||||||
|
state_table[nstates] = STATE_ALLOC (0);
|
||||||
|
state_table[nstates]->lookaheads = count;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
lalr (void)
|
lalr (void)
|
||||||
{
|
{
|
||||||
tokensetsize = WORDSIZE (ntokens);
|
tokensetsize = WORDSIZE (ntokens);
|
||||||
|
|
||||||
|
initialize_lookaheads ();
|
||||||
initialize_LA ();
|
initialize_LA ();
|
||||||
set_goto_map ();
|
set_goto_map ();
|
||||||
initialize_F ();
|
initialize_F ();
|
||||||
|
|||||||
Reference in New Issue
Block a user