| 274 | |
| 275 | |
| 276 | core *new_state(int symbol) |
| 277 | { |
| 278 | register int n; |
| 279 | register core *p; |
| 280 | register Yshort *isp1; |
| 281 | register Yshort *isp2; |
| 282 | register Yshort *iend; |
| 283 | |
| 284 | #ifdef TRACE |
| 285 | fprintf(stderr, "Entering new_state(%d)\n", symbol); |
| 286 | #endif |
| 287 | |
| 288 | if (nstates >= MAXSHORT) |
| 289 | fatal("too many states"); |
| 290 | |
| 291 | isp1 = kernel_base[symbol]; |
| 292 | iend = kernel_end[symbol]; |
| 293 | n = iend - isp1; |
| 294 | |
| 295 | p = (core *) allocate((unsigned) (sizeof(core) + (n - 1) * sizeof(Yshort))); |
| 296 | p->accessing_symbol = symbol; |
| 297 | p->number = nstates; |
| 298 | p->nitems = n; |
| 299 | |
| 300 | isp2 = p->items; |
| 301 | while (isp1 < iend) |
| 302 | *isp2++ = *isp1++; |
| 303 | |
| 304 | last_state->next = p; |
| 305 | last_state = p; |
| 306 | |
| 307 | nstates++; |
| 308 | |
| 309 | return (p); |
| 310 | } |
| 311 | |
| 312 | |
| 313 | /* show_cores is used for debugging */ |