[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
17-fyi-simplify-augment.patch
From: |
Akim Demaille |
Subject: |
17-fyi-simplify-augment.patch |
Date: |
Mon, 10 Dec 2001 09:36:40 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/LR0.c (augment_automaton): Better variable locality.
Remove an impossible branch: if there is a state corresponding to
the start symbol being shifted, then there is shift for the start
symbol from the initial state.
Index: src/LR0.c
--- src/LR0.c Sat, 08 Dec 2001 21:39:43 +0100 akim
+++ src/LR0.c Sat, 08 Dec 2001 22:02:25 +0100 akim
@@ -457,67 +457,55 @@
else
{
state_t *statep = first_state->next;
- shifts *sp = first_state->shifts;
- shifts *sp1 = NULL;
/* The states reached by shifts from FIRST_STATE are numbered
1..(SP->NSHIFTS). Look for one reached by START_SYMBOL.
This is typical of `start: start ... ;': there is a state
with the item `start: start . ...'. We want to add a `shift
on EOF to eof-shifting state here. */
while (statep->accessing_symbol != start_symbol
- && statep->number < sp->nshifts)
+ && statep->number < first_state->shifts->nshifts)
statep = statep->next;
if (statep->accessing_symbol == start_symbol)
{
- /* We already have a next-to-final state, i.e., for `start:
+ /* We already have STATEP, a next-to-final state for `start:
start . ...'. Make sure it has a shift to what will be
the final state. */
- while (sp && sp->number < statep->number)
+ int i;
+
+ /* Find the shift that leads to this STATEP. */
+ shifts *sp = first_state->shifts;
+ shifts *sp1 = NULL;
+ shifts *sp2 = NULL;
+ while (sp->number < statep->number)
{
sp1 = sp;
sp = sp->next;
}
- if (sp && sp->number == statep->number)
- {
- int i;
- shifts *sp2 = shifts_new (sp->nshifts + 1);
- sp2->number = statep->number;
- statep->shifts = sp2;
- sp2->shifts[0] = nstates;
- for (i = sp->nshifts; i > 0; i--)
- sp2->shifts[i] = sp->shifts[i - 1];
+ sp2 = shifts_new (sp->nshifts + 1);
+ sp2->number = statep->number;
+ statep->shifts = sp2;
+ sp2->shifts[0] = nstates;
+ for (i = sp->nshifts; i > 0; i--)
+ sp2->shifts[i] = sp->shifts[i - 1];
- /* Patch sp2 into the chain of shifts in place of sp,
- following sp1. */
- sp2->next = sp->next;
- sp1->next = sp2;
- if (sp == last_shift)
- last_shift = sp2;
- XFREE (sp);
- }
- else
- {
- shifts *sp2 = shifts_new (1);
- sp2->number = statep->number;
- statep->shifts = sp2;
- sp2->shifts[0] = nstates;
+ /* Patch sp2 into the chain of shifts in place of sp,
+ following sp1. */
+ sp2->next = sp->next;
+ sp1->next = sp2;
+ if (sp == last_shift)
+ last_shift = sp2;
+ XFREE (sp);
- /* Patch sp2 into the chain of shifts between sp1 and sp. */
- sp2->next = sp;
- sp1->next = sp2;
- if (sp == 0)
- last_shift = sp2;
- }
insert_eof_shifting_state ();
}
else
{
/* There is no state for `start: start . ...'. */
int i, k;
- shifts *sp2;
- sp = first_shift;
+ shifts *sp = first_state->shifts;
+ shifts *sp2 = NULL;
/* There is no next-to-final state as yet. */
/* Add one more shift in first_shift,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 17-fyi-simplify-augment.patch,
Akim Demaille <=