36 |
int nstates; |
int nstates; |
37 |
int final_state; |
int final_state; |
38 |
static state_t *first_state = NULL; |
static state_t *first_state = NULL; |
|
static shifts *first_shift = NULL; |
|
39 |
|
|
40 |
static state_t *this_state = NULL; |
static state_t *this_state = NULL; |
41 |
static state_t *last_state = NULL; |
static state_t *last_state = NULL; |
|
static shifts *last_shift = NULL; |
|
42 |
|
|
43 |
static int nshifts; |
static int nshifts; |
44 |
static short *shift_symbol = NULL; |
static short *shift_symbol = NULL; |
320 |
p->number = this_state->number; |
p->number = this_state->number; |
321 |
shortcpy (p->shifts, shiftset, nshifts); |
shortcpy (p->shifts, shiftset, nshifts); |
322 |
this_state->shifts = p; |
this_state->shifts = p; |
|
|
|
|
if (last_shift) |
|
|
last_shift->next = p; |
|
|
else |
|
|
first_shift = p; |
|
|
last_shift = p; |
|
323 |
} |
} |
324 |
|
|
325 |
|
|
356 |
statep->shifts = sp; |
statep->shifts = sp; |
357 |
sp->number = nstates++; |
sp->number = nstates++; |
358 |
sp->shifts[0] = nstates; |
sp->shifts[0] = nstates; |
|
|
|
|
last_shift->next = sp; |
|
|
last_shift = sp; |
|
359 |
} |
} |
360 |
|
|
361 |
|
|
385 |
statep->shifts = sp; |
statep->shifts = sp; |
386 |
sp->number = nstates++; |
sp->number = nstates++; |
387 |
sp->shifts[0] = nstates; |
sp->shifts[0] = nstates; |
|
|
|
|
last_shift->next = sp; |
|
|
last_shift = sp; |
|
388 |
} |
} |
389 |
|
|
390 |
|
|
432 |
first_state->shifts = sp; |
first_state->shifts = sp; |
433 |
sp->shifts[0] = nstates; |
sp->shifts[0] = nstates; |
434 |
|
|
|
/* Initialize the chain of shifts with sp. */ |
|
|
first_shift = sp; |
|
|
last_shift = sp; |
|
|
|
|
435 |
/* Create the next-to-final state, with shift to |
/* Create the next-to-final state, with shift to |
436 |
what will be the final state. */ |
what will be the final state. */ |
437 |
insert_start_shifting_state (); |
insert_start_shifting_state (); |
455 |
the final state. */ |
the final state. */ |
456 |
int i; |
int i; |
457 |
|
|
458 |
/* Find the shift that leads to this STATEP. */ |
/* Find the shift of the inital state that leads to STATEP. */ |
459 |
shifts *sp = first_state->shifts; |
shifts *sp = statep->shifts; |
|
shifts *sp1 = NULL; |
|
|
shifts *sp2 = NULL; |
|
|
while (sp->number < statep->number) |
|
|
{ |
|
|
sp1 = sp; |
|
|
sp = sp->next; |
|
|
} |
|
460 |
|
|
461 |
sp2 = shifts_new (sp->nshifts + 1); |
shifts *sp1 = shifts_new (sp->nshifts + 1); |
462 |
sp2->number = statep->number; |
sp1->number = statep->number; |
463 |
statep->shifts = sp2; |
statep->shifts = sp1; |
464 |
sp2->shifts[0] = nstates; |
sp1->shifts[0] = nstates; |
465 |
for (i = sp->nshifts; i > 0; i--) |
for (i = sp->nshifts; i > 0; i--) |
466 |
sp2->shifts[i] = sp->shifts[i - 1]; |
sp1->shifts[i] = sp->shifts[i - 1]; |
467 |
|
|
|
/* 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; |
|
468 |
XFREE (sp); |
XFREE (sp); |
469 |
|
|
470 |
insert_eof_shifting_state (); |
insert_eof_shifting_state (); |
474 |
/* There is no state for `start: start . ...'. */ |
/* There is no state for `start: start . ...'. */ |
475 |
int i, k; |
int i, k; |
476 |
shifts *sp = first_state->shifts; |
shifts *sp = first_state->shifts; |
477 |
shifts *sp2 = NULL; |
shifts *sp1 = NULL; |
478 |
|
|
479 |
/* There is no next-to-final state as yet. */ |
/* Add one more shift to the initial state, going to the |
480 |
/* Add one more shift in first_shift, |
next-to-final state (yet to be made). */ |
481 |
going to the next-to-final state (yet to be made). */ |
sp1 = shifts_new (sp->nshifts + 1); |
482 |
sp2 = shifts_new (sp->nshifts + 1); |
first_state->shifts = sp1; |
|
first_state->shifts = sp2; |
|
483 |
/* Stick this shift into the vector at the proper place. */ |
/* Stick this shift into the vector at the proper place. */ |
484 |
statep = first_state->next; |
statep = first_state->next; |
485 |
for (k = 0, i = 0; i < sp->nshifts; k++, i++) |
for (k = 0, i = 0; i < sp->nshifts; k++, i++) |
486 |
{ |
{ |
487 |
if (statep->accessing_symbol > start_symbol && i == k) |
if (statep->accessing_symbol > start_symbol && i == k) |
488 |
sp2->shifts[k++] = nstates; |
sp1->shifts[k++] = nstates; |
489 |
sp2->shifts[k] = sp->shifts[i]; |
sp1->shifts[k] = sp->shifts[i]; |
490 |
statep = statep->next; |
statep = statep->next; |
491 |
} |
} |
492 |
if (i == k) |
if (i == k) |
493 |
sp2->shifts[k++] = nstates; |
sp1->shifts[k++] = nstates; |
|
|
|
|
/* Patch sp2 into the chain of shifts |
|
|
in place of sp, at the beginning. */ |
|
|
sp2->next = sp->next; |
|
|
first_shift = sp2; |
|
|
if (last_shift == sp) |
|
|
last_shift = sp2; |
|
494 |
|
|
495 |
XFREE (sp); |
XFREE (sp); |
496 |
|
|