- {
- reductions *rp;
- for (rp = first_reduction; rp; rp = rp->next)
- state_table[rp->number].reduction_table = rp;
- }
-}
-
-
-static void
-set_maxrhs (void)
-{
- short *itemp;
- int length;
- int max;
-
- length = 0;
- max = 0;
- for (itemp = ritem; *itemp; itemp++)
- {
- if (*itemp > 0)
- {
- length++;
- }
- else
- {
- if (length > max)
- max = length;
- length = 0;
- }
- }
-
- maxrhs = max;
-}
-
-
-static void
-initialize_LA (void)
-{
- int i;
- int j;
- int count = 0;
- reductions *rp;
- shifts *sp;
- short *np;
-
- for (i = 0; i < nstates; i++)
- {
- int k;
-
- state_table[i].lookaheads = count;
-
- rp = state_table[i].reduction_table;
- sp = state_table[i].shift_table;
- if (rp
- && (rp->nreds > 1
- || (sp && !ISVAR (state_table[sp->shifts[0]].accessing_symbol))))
- count += rp->nreds;
- else
- state_table[i].consistent = 1;
-
- if (sp)
- for (k = 0; k < sp->nshifts; k++)
- if (state_table[sp->shifts[k]].accessing_symbol
- == error_token_number)
- {
- state_table[i].consistent = 0;
- break;
- }
- }
-
- state_table[nstates].lookaheads = count;
-
- if (count == 0)
- {
- LA = XCALLOC (unsigned, 1 * tokensetsize);
- LAruleno = XCALLOC (short, 1);
- lookback = XCALLOC (shorts *, 1);
- }
- else
- {
- LA = XCALLOC (unsigned, count * tokensetsize);
- LAruleno = XCALLOC (short, count);
- lookback = XCALLOC (shorts *, count);
- }
-
- np = LAruleno;
- for (i = 0; i < nstates; i++)
- {
- if (!state_table[i].consistent)
- {
- if ((rp = state_table[i].reduction_table))
- for (j = 0; j < rp->nreds; j++)
- *np++ = rp->rules[j];
- }
- }
-}