196 |
{ |
{ |
197 |
int n; |
int n; |
198 |
core *p; |
core *p; |
|
short *isp1; |
|
|
short *isp2; |
|
|
short *iend; |
|
199 |
|
|
200 |
#if TRACE |
#if TRACE |
201 |
fprintf (stderr, "Entering new_state, symbol = %d, state = %d\n", |
fprintf (stderr, "Entering new_state, symbol = %d, state = %d\n", |
205 |
if (nstates >= MAXSHORT) |
if (nstates >= MAXSHORT) |
206 |
fatal (_("too many states (max %d)"), MAXSHORT); |
fatal (_("too many states (max %d)"), MAXSHORT); |
207 |
|
|
208 |
isp1 = kernel_base[symbol]; |
n = kernel_end[symbol] - kernel_base[symbol]; |
|
iend = kernel_end[symbol]; |
|
|
n = iend - isp1; |
|
209 |
|
|
210 |
p = CORE_ALLOC (n); |
p = CORE_ALLOC (n); |
211 |
p->accessing_symbol = symbol; |
p->accessing_symbol = symbol; |
212 |
p->number = nstates; |
p->number = nstates; |
213 |
p->nitems = n; |
p->nitems = n; |
214 |
|
|
215 |
isp2 = p->items; |
shortcpy (p->items, kernel_base[symbol], n); |
|
while (isp1 < iend) |
|
|
*isp2++ = *isp1++; |
|
216 |
|
|
217 |
last_state->next = p; |
last_state->next = p; |
218 |
last_state = p; |
last_state = p; |
353 |
save_shifts (void) |
save_shifts (void) |
354 |
{ |
{ |
355 |
shifts *p; |
shifts *p; |
|
short *sp1; |
|
|
short *sp2; |
|
|
short *send; |
|
356 |
|
|
357 |
p = SHIFTS_ALLOC (nshifts); |
p = SHIFTS_ALLOC (nshifts); |
358 |
|
|
359 |
p->number = this_state->number; |
p->number = this_state->number; |
360 |
p->nshifts = nshifts; |
p->nshifts = nshifts; |
361 |
|
|
362 |
sp1 = shiftset; |
shortcpy (p->shifts, shiftset, nshifts); |
|
sp2 = p->shifts; |
|
|
send = shiftset + nshifts; |
|
|
|
|
|
while (sp1 < send) |
|
|
*sp2++ = *sp1++; |
|
363 |
|
|
364 |
if (last_shift) |
if (last_shift) |
365 |
{ |
{ |
588 |
save_reductions (void) |
save_reductions (void) |
589 |
{ |
{ |
590 |
short *isp; |
short *isp; |
|
short *rp1; |
|
|
short *rp2; |
|
591 |
int item; |
int item; |
592 |
int count; |
int count; |
593 |
reductions *p; |
reductions *p; |
613 |
p->number = this_state->number; |
p->number = this_state->number; |
614 |
p->nreds = count; |
p->nreds = count; |
615 |
|
|
616 |
rp1 = redset; |
shortcpy (p->rules, redset, count); |
|
rp2 = p->rules; |
|
|
rend = rp1 + count; |
|
|
|
|
|
for (/* nothing */; rp1 < rend; ++rp1, ++rp2) |
|
|
*rp2 = *rp1; |
|
617 |
|
|
618 |
if (last_reduction) |
if (last_reduction) |
619 |
{ |
{ |