155 |
static void |
static void |
156 |
set_conflicts (state_t *state) |
set_conflicts (state_t *state) |
157 |
{ |
{ |
158 |
int i, j; |
int i; |
159 |
shifts *shiftp; |
shifts *shiftp; |
160 |
|
|
161 |
if (state->consistent) |
if (state->consistent) |
172 |
check for shift-reduce conflict, and try to resolve using |
check for shift-reduce conflict, and try to resolve using |
173 |
precedence */ |
precedence */ |
174 |
for (i = 0; i < state->nlookaheads; ++i) |
for (i = 0; i < state->nlookaheads; ++i) |
175 |
if (rules[LAruleno[state->lookaheadsp + i]].prec) |
if (rules[LAruleno[state->lookaheadsp + i]].prec |
176 |
for (j = 0; j < ntokens; ++j) |
&& !bitset_disjoint_p (LA[state->lookaheadsp + i], lookaheadset)) |
177 |
if (bitset_test (LA[state->lookaheadsp + i], j) |
{ |
178 |
&& bitset_test (lookaheadset, j)) |
resolve_sr_conflict (state, state->lookaheadsp + i); |
179 |
{ |
break; |
180 |
resolve_sr_conflict (state, state->lookaheadsp + i); |
} |
|
break; |
|
|
} |
|
|
|
|
181 |
|
|
182 |
/* Loop over all rules which require lookahead in this state. Check |
/* Loop over all rules which require lookahead in this state. Check |
183 |
for conflicts not resolved above. */ |
for conflicts not resolved above. */ |
184 |
for (i = 0; i < state->nlookaheads; ++i) |
for (i = 0; i < state->nlookaheads; ++i) |
185 |
{ |
{ |
186 |
/* FIXME: Here, I need something like `bitset_disjoint_p'. */ |
if (!bitset_disjoint_p (LA[state->lookaheadsp + i], lookaheadset)) |
187 |
for (j = 0; j < ntokens; ++j) |
conflicts[state->number] = 1; |
|
if (bitset_test (LA[state->lookaheadsp + i], j) |
|
|
&& bitset_test (lookaheadset, j)) |
|
|
conflicts[state->number] = 1; |
|
188 |
|
|
189 |
bitset_or (lookaheadset, lookaheadset, LA[state->lookaheadsp + i]); |
bitset_or (lookaheadset, lookaheadset, LA[state->lookaheadsp + i]); |
190 |
} |
} |
230 |
|
|
231 |
bitset_and (lookaheadset, lookaheadset, shiftset); |
bitset_and (lookaheadset, lookaheadset, shiftset); |
232 |
|
|
233 |
for (i = 0; i < ntokens; i++) |
src_count = bitset_count (lookaheadset); |
|
if (bitset_test (lookaheadset, i)) |
|
|
src_count++; |
|
234 |
|
|
235 |
return src_count; |
return src_count; |
236 |
} |
} |