156 |
{ |
{ |
157 |
shifts *sp; |
shifts *sp; |
158 |
for (sp = first_shift; sp; sp = sp->next) |
for (sp = first_shift; sp; sp = sp->next) |
159 |
state_table[sp->number].shift_table = sp; |
state_table[sp->number].shifts = sp; |
160 |
} |
} |
161 |
|
|
162 |
{ |
{ |
163 |
reductions *rp; |
reductions *rp; |
164 |
for (rp = first_reduction; rp; rp = rp->next) |
for (rp = first_reduction; rp; rp = rp->next) |
165 |
state_table[rp->number].reduction_table = rp; |
state_table[rp->number].reductions = rp; |
166 |
} |
} |
167 |
|
|
168 |
/* Pessimization, but simplification of the code: make sense all the |
/* Pessimization, but simplification of the code: make sense all the |
169 |
states have a shift_table, even if reduced to 0 shifts. */ |
states have a shifts, even if reduced to 0 shifts. */ |
170 |
{ |
{ |
171 |
int i; |
int i; |
172 |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
173 |
if (!state_table[i].shift_table) |
if (!state_table[i].shifts) |
174 |
state_table[i].shift_table = shifts_new (0); |
state_table[i].shifts = shifts_new (0); |
175 |
} |
} |
176 |
|
|
177 |
/* Initializing the lookaheads members. Please note that it must be |
/* Initializing the lookaheads members. Please note that it must be |
183 |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
184 |
{ |
{ |
185 |
int k; |
int k; |
186 |
reductions *rp = state_table[i].reduction_table; |
reductions *rp = state_table[i].reductions; |
187 |
shifts *sp = state_table[i].shift_table; |
shifts *sp = state_table[i].shifts; |
188 |
|
|
189 |
state_table[i].lookaheads = count; |
state_table[i].lookaheads = count; |
190 |
|
|
225 |
np = LAruleno; |
np = LAruleno; |
226 |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
227 |
if (!state_table[i].consistent) |
if (!state_table[i].consistent) |
228 |
if ((rp = state_table[i].reduction_table)) |
if ((rp = state_table[i].reductions)) |
229 |
for (j = 0; j < rp->nreds; j++) |
for (j = 0; j < rp->nreds; j++) |
230 |
*np++ = rp->rules[j]; |
*np++ = rp->rules[j]; |
231 |
} |
} |
340 |
for (i = 0; i < ngotos; i++) |
for (i = 0; i < ngotos; i++) |
341 |
{ |
{ |
342 |
int stateno = to_state[i]; |
int stateno = to_state[i]; |
343 |
shifts *sp = state_table[stateno].shift_table; |
shifts *sp = state_table[stateno].shifts; |
344 |
|
|
345 |
int j; |
int j; |
346 |
for (j = 0; j < sp->nshifts && SHIFT_IS_SHIFT (sp, j); j++) |
for (j = 0; j < sp->nshifts && SHIFT_IS_SHIFT (sp, j); j++) |
347 |
{ |
{ |
348 |
int symbol = state_table[sp->shifts[j]].accessing_symbol; |
int symbol = state_table[sp->shifts[j]].accessing_symbol; |
349 |
SETBIT (F + i * tokensetsize, symbol); |
SETBIT (F (i), symbol); |
350 |
} |
} |
351 |
|
|
352 |
for (; j < sp->nshifts; j++) |
for (; j < sp->nshifts; j++) |
515 |
|
|
516 |
for (rp = ritem + rule_table[*rulep].rhs; *rp > 0; rp++) |
for (rp = ritem + rule_table[*rulep].rhs; *rp > 0; rp++) |
517 |
{ |
{ |
518 |
shifts *sp = state_table[stateno].shift_table; |
shifts *sp = state_table[stateno].shifts; |
519 |
int j; |
int j; |
520 |
for (j = 0; j < sp->nshifts; j++) |
for (j = 0; j < sp->nshifts; j++) |
521 |
{ |
{ |