56 |
static void |
static void |
57 |
flush_shift (int state, int token) |
flush_shift (int state, int token) |
58 |
{ |
{ |
59 |
shifts *shiftp = state_table[state].shifts; |
shifts *shiftp = state_table[state]->shifts; |
60 |
int i; |
int i; |
61 |
|
|
62 |
for (i = 0; i < shiftp->nshifts; i++) |
for (i = 0; i < shiftp->nshifts; i++) |
147 |
/* Some tokens have been explicitly made errors. Allocate a |
/* Some tokens have been explicitly made errors. Allocate a |
148 |
permanent errs structure for this state, to record them. */ |
permanent errs structure for this state, to record them. */ |
149 |
i = (char *) errtokens - (char *) errp; |
i = (char *) errtokens - (char *) errp; |
150 |
state_table[state].errs = ERRS_ALLOC (i + 1); |
state_table[state]->errs = ERRS_ALLOC (i + 1); |
151 |
memcpy (state_table[state].errs, errp, i); |
memcpy (state_table[state]->errs, errp, i); |
152 |
free (errp); |
free (errp); |
153 |
} |
} |
154 |
|
|
159 |
int i, j; |
int i, j; |
160 |
shifts *shiftp; |
shifts *shiftp; |
161 |
|
|
162 |
if (state_table[state].consistent) |
if (state_table[state]->consistent) |
163 |
return; |
return; |
164 |
|
|
165 |
for (i = 0; i < tokensetsize; i++) |
for (i = 0; i < tokensetsize; i++) |
166 |
lookaheadset[i] = 0; |
lookaheadset[i] = 0; |
167 |
|
|
168 |
shiftp = state_table[state].shifts; |
shiftp = state_table[state]->shifts; |
169 |
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++) |
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++) |
170 |
if (!SHIFT_IS_DISABLED (shiftp, i)) |
if (!SHIFT_IS_DISABLED (shiftp, i)) |
171 |
SETBIT (lookaheadset, SHIFT_SYMBOL (shiftp, i)); |
SETBIT (lookaheadset, SHIFT_SYMBOL (shiftp, i)); |
173 |
/* Loop over all rules which require lookahead in this state. First |
/* Loop over all rules which require lookahead in this state. First |
174 |
check for shift-reduce conflict, and try to resolve using |
check for shift-reduce conflict, and try to resolve using |
175 |
precedence */ |
precedence */ |
176 |
for (i = state_table[state].lookaheads; |
for (i = state_table[state]->lookaheads; |
177 |
i < state_table[state + 1].lookaheads; |
i < state_table[state + 1]->lookaheads; |
178 |
++i) |
++i) |
179 |
if (rule_table[LAruleno[i]].prec) |
if (rule_table[LAruleno[i]].prec) |
180 |
for (j = 0; j < tokensetsize; ++j) |
for (j = 0; j < tokensetsize; ++j) |
187 |
|
|
188 |
/* Loop over all rules which require lookahead in this state. Check |
/* Loop over all rules which require lookahead in this state. Check |
189 |
for conflicts not resolved above. */ |
for conflicts not resolved above. */ |
190 |
for (i = state_table[state].lookaheads; |
for (i = state_table[state]->lookaheads; |
191 |
i < state_table[state + 1].lookaheads; |
i < state_table[state + 1]->lookaheads; |
192 |
++i) |
++i) |
193 |
{ |
{ |
194 |
for (j = 0; j < tokensetsize; ++j) |
for (j = 0; j < tokensetsize; ++j) |
223 |
{ |
{ |
224 |
int i, k; |
int i, k; |
225 |
int src_count = 0; |
int src_count = 0; |
226 |
shifts *shiftp = state_table[state].shifts; |
shifts *shiftp = state_table[state]->shifts; |
227 |
|
|
228 |
if (!shiftp) |
if (!shiftp) |
229 |
return 0; |
return 0; |
238 |
if (!SHIFT_IS_DISABLED (shiftp, i)) |
if (!SHIFT_IS_DISABLED (shiftp, i)) |
239 |
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i)); |
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i)); |
240 |
|
|
241 |
for (i = state_table[state].lookaheads; |
for (i = state_table[state]->lookaheads; |
242 |
i < state_table[state + 1].lookaheads; |
i < state_table[state + 1]->lookaheads; |
243 |
++i) |
++i) |
244 |
for (k = 0; k < tokensetsize; ++k) |
for (k = 0; k < tokensetsize; ++k) |
245 |
lookaheadset[k] |= LA (i)[k]; |
lookaheadset[k] |= LA (i)[k]; |
265 |
int i; |
int i; |
266 |
int rrc_count = 0; |
int rrc_count = 0; |
267 |
|
|
268 |
int m = state_table[state].lookaheads; |
int m = state_table[state]->lookaheads; |
269 |
int n = state_table[state + 1].lookaheads; |
int n = state_table[state + 1]->lookaheads; |
270 |
|
|
271 |
if (n - m < 2) |
if (n - m < 2) |
272 |
return 0; |
return 0; |
424 |
for (i = 0; i < tokensetsize; i++) |
for (i = 0; i < tokensetsize; i++) |
425 |
shiftset[i] = 0; |
shiftset[i] = 0; |
426 |
|
|
427 |
shiftp = state_table[state].shifts; |
shiftp = state_table[state]->shifts; |
428 |
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++) |
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++) |
429 |
if (!SHIFT_IS_DISABLED (shiftp, i)) |
if (!SHIFT_IS_DISABLED (shiftp, i)) |
430 |
{ |
{ |
435 |
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i)); |
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i)); |
436 |
} |
} |
437 |
|
|
438 |
errp = state_table[state].errs; |
errp = state_table[state]->errs; |
439 |
if (errp) |
if (errp) |
440 |
for (i = 0; i < errp->nerrs; i++) |
for (i = 0; i < errp->nerrs; i++) |
441 |
if (errp->errs[i]) |
if (errp->errs[i]) |
442 |
SETBIT (shiftset, errp->errs[i]); |
SETBIT (shiftset, errp->errs[i]); |
443 |
|
|
444 |
m = state_table[state].lookaheads; |
m = state_table[state]->lookaheads; |
445 |
n = state_table[state + 1].lookaheads; |
n = state_table[state + 1]->lookaheads; |
446 |
|
|
447 |
if (n - m == 1 && !nodefault) |
if (n - m == 1 && !nodefault) |
448 |
{ |
{ |