38 |
state_t *state_table = NULL; |
state_t *state_table = NULL; |
39 |
|
|
40 |
int tokensetsize; |
int tokensetsize; |
|
short *lookaheads; |
|
41 |
short *LAruleno; |
short *LAruleno; |
42 |
unsigned *LA; |
unsigned *LA; |
43 |
|
|
144 |
static void |
static void |
145 |
set_state_table (void) |
set_state_table (void) |
146 |
{ |
{ |
147 |
state_table = XCALLOC (state_t, nstates); |
/* NSTATES + 1 because lookahead for the pseudo state number NSTATES |
148 |
|
might be used (see conflicts.c). It is too opaque for me to |
149 |
|
provide a probably less hacky implementation. --akim */ |
150 |
|
state_table = XCALLOC (state_t, nstates + 1); |
151 |
|
|
152 |
{ |
{ |
153 |
core *sp; |
core *sp; |
204 |
{ |
{ |
205 |
int i; |
int i; |
206 |
int j; |
int j; |
207 |
int count; |
int count = 0; |
208 |
reductions *rp; |
reductions *rp; |
209 |
shifts *sp; |
shifts *sp; |
210 |
short *np; |
short *np; |
211 |
|
|
|
lookaheads = XCALLOC (short, nstates + 1); |
|
|
|
|
|
count = 0; |
|
212 |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
213 |
{ |
{ |
214 |
int k; |
int k; |
215 |
|
|
216 |
lookaheads[i] = count; |
state_table[i].lookaheads = count; |
217 |
|
|
218 |
rp = state_table[i].reduction_table; |
rp = state_table[i].reduction_table; |
219 |
sp = state_table[i].shift_table; |
sp = state_table[i].shift_table; |
234 |
} |
} |
235 |
} |
} |
236 |
|
|
237 |
lookaheads[nstates] = count; |
state_table[nstates].lookaheads = count; |
238 |
|
|
239 |
if (count == 0) |
if (count == 0) |
240 |
{ |
{ |
449 |
int found; |
int found; |
450 |
shorts *sp; |
shorts *sp; |
451 |
|
|
452 |
i = lookaheads[stateno]; |
i = state_table[stateno].lookaheads; |
453 |
k = lookaheads[stateno + 1]; |
k = state_table[stateno + 1].lookaheads; |
454 |
found = 0; |
found = 0; |
455 |
while (!found && i < k) |
while (!found && i < k) |
456 |
{ |
{ |
652 |
shorts *sptmp; /* JF */ |
shorts *sptmp; /* JF */ |
653 |
|
|
654 |
rowp = LA; |
rowp = LA; |
655 |
n = lookaheads[nstates]; |
for (i = 0; i < state_table[nstates].lookaheads; i++) |
|
for (i = 0; i < n; i++) |
|
656 |
{ |
{ |
657 |
fp3 = rowp + tokensetsize; |
fp3 = rowp + tokensetsize; |
658 |
for (sp = lookback[i]; sp; sp = sp->next) |
for (sp = lookback[i]; sp; sp = sp->next) |
666 |
rowp = fp3; |
rowp = fp3; |
667 |
} |
} |
668 |
|
|
669 |
for (i = 0; i < n; i++) |
for (i = 0; i < state_table[nstates].lookaheads; i++) |
670 |
{ |
{ |
671 |
/* JF removed ref to freed storage */ |
/* JF removed ref to freed storage */ |
672 |
for (sp = lookback[i]; sp; sp = sptmp) |
for (sp = lookback[i]; sp; sp = sptmp) |