mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-27 21:23:03 +00:00
* src/LR0.c (augment_automaton): Formatting changes.
Better variable locality.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2001-12-05 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/LR0.c (augment_automaton): Formatting changes.
|
||||
Better variable locality.
|
||||
|
||||
|
||||
2001-12-05 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/lalr.c (matrix_print): New.
|
||||
|
||||
63
src/LR0.c
63
src/LR0.c
@@ -387,44 +387,53 @@ insert_start_shift (void)
|
||||
static void
|
||||
augment_automaton (void)
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
core *statep;
|
||||
shifts *sp;
|
||||
shifts *sp2;
|
||||
shifts *sp1 = NULL;
|
||||
|
||||
sp = first_shift;
|
||||
|
||||
if (sp)
|
||||
if (!sp)
|
||||
{
|
||||
if (sp->number == 0)
|
||||
/* There are no shifts for any state. Make one shift, from the
|
||||
initial state to the next-to-final state. */
|
||||
|
||||
sp = shifts_new (1);
|
||||
sp->shifts[0] = nstates;
|
||||
|
||||
/* Initialize the chain of shifts with sp. */
|
||||
first_shift = sp;
|
||||
last_shift = sp;
|
||||
|
||||
/* Create the next-to-final state, with shift to
|
||||
what will be the final state. */
|
||||
insert_start_shift ();
|
||||
}
|
||||
else if (sp->number == 0)
|
||||
{
|
||||
k = sp->nshifts;
|
||||
statep = first_state->next;
|
||||
|
||||
/* The states reached by shifts from first_state are numbered 1...K.
|
||||
Look for one reached by start_symbol. */
|
||||
/* The states reached by shifts from FIRST_STATE are numbered
|
||||
1..(SP->NSHIFTS). Look for one reached by START_SYMBOL. */
|
||||
while (statep->accessing_symbol < start_symbol
|
||||
&& statep->number < k)
|
||||
&& statep->number < sp->nshifts)
|
||||
statep = statep->next;
|
||||
|
||||
if (statep->accessing_symbol == start_symbol)
|
||||
{
|
||||
/* We already have a next-to-final state.
|
||||
Make sure it has a shift to what will be the final state. */
|
||||
k = statep->number;
|
||||
|
||||
while (sp && sp->number < k)
|
||||
while (sp && sp->number < statep->number)
|
||||
{
|
||||
sp1 = sp;
|
||||
sp = sp->next;
|
||||
}
|
||||
|
||||
if (sp && sp->number == k)
|
||||
if (sp && sp->number == statep->number)
|
||||
{
|
||||
sp2 = shifts_new (sp->nshifts + 1);
|
||||
sp2->number = k;
|
||||
int i;
|
||||
shifts *sp2 = shifts_new (sp->nshifts + 1);
|
||||
sp2->number = statep->number;
|
||||
sp2->shifts[0] = nstates;
|
||||
for (i = sp->nshifts; i > 0; i--)
|
||||
sp2->shifts[i] = sp->shifts[i - 1];
|
||||
@@ -439,8 +448,8 @@ augment_automaton (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
sp2 = shifts_new (1);
|
||||
sp2->number = k;
|
||||
shifts *sp2 = shifts_new (1);
|
||||
sp2->number = statep->number;
|
||||
sp2->shifts[0] = nstates;
|
||||
|
||||
/* Patch sp2 into the chain of shifts between sp1 and sp. */
|
||||
@@ -452,6 +461,9 @@ augment_automaton (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
int i, k;
|
||||
shifts *sp2;
|
||||
|
||||
/* There is no next-to-final state as yet. */
|
||||
/* Add one more shift in first_shift,
|
||||
going to the next-to-final state (yet to be made). */
|
||||
@@ -496,23 +508,6 @@ augment_automaton (void)
|
||||
sp->next = first_shift;
|
||||
first_shift = sp;
|
||||
|
||||
/* Create the next-to-final state, with shift to
|
||||
what will be the final state. */
|
||||
insert_start_shift ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There are no shifts for any state.
|
||||
Make one shift, from the initial state to the next-to-final state. */
|
||||
|
||||
sp = shifts_new (1);
|
||||
sp->shifts[0] = nstates;
|
||||
|
||||
/* Initialize the chain of shifts with sp. */
|
||||
first_shift = sp;
|
||||
last_shift = sp;
|
||||
|
||||
/* Create the next-to-final state, with shift to
|
||||
what will be the final state. */
|
||||
insert_start_shift ();
|
||||
|
||||
Reference in New Issue
Block a user