437 |
static void |
static void |
438 |
augment_automaton (void) |
augment_automaton (void) |
439 |
{ |
{ |
440 |
if (!first_shift->nshifts) |
if (!first_state->shifts->nshifts) |
441 |
{ |
{ |
442 |
/* There are no shifts for any state. Make one shift, from the |
/* The first state has no shifts. Make one shift, from the |
443 |
initial state to the next-to-final state. */ |
initial state to the next-to-final state. */ |
444 |
|
|
445 |
shifts *sp = shifts_new (1); |
shifts *sp = shifts_new (1); |
454 |
what will be the final state. */ |
what will be the final state. */ |
455 |
insert_start_shifting_state (); |
insert_start_shifting_state (); |
456 |
} |
} |
457 |
else if (first_shift->number == 0) |
else |
458 |
{ |
{ |
459 |
state_t *statep = first_state->next; |
state_t *statep = first_state->next; |
460 |
shifts *sp = first_shift; |
shifts *sp = first_shift; |
544 |
insert_start_shifting_state (); |
insert_start_shifting_state (); |
545 |
} |
} |
546 |
} |
} |
|
else |
|
|
{ |
|
|
/* The initial state didn't even have any shifts. |
|
|
Give it one shift, to the next-to-final state. */ |
|
|
shifts *sp = shifts_new (1); |
|
|
first_state->shifts = sp; |
|
|
sp->shifts[0] = nstates; |
|
|
|
|
|
/* Patch sp into the chain of shifts at the beginning. */ |
|
|
sp->next = first_shift; |
|
|
first_shift = sp; |
|
|
|
|
|
/* Create the next-to-final state, with shift to |
|
|
what will be the final state. */ |
|
|
insert_start_shifting_state (); |
|
|
} |
|
547 |
|
|
548 |
insert_eof_shifting_state (); |
insert_eof_shifting_state (); |
549 |
insert_accepting_state (); |
insert_accepting_state (); |