+2001-12-05 Akim Demaille <akim@epita.fr>
+
+ * src/state.h (SHIFT_DISABLE, SHIFT_IS_DISABLED): New.
+ * src/conflicts.c: Use it.
+ Restore a few missing `if (!SHIFT_IS_DISABLED)' which were
+ incorrectly ``simplified''.
+
+
2001-12-05 Akim Demaille <akim@epita.fr>
* src/conflicts.c (flush_shift, resolve_sr_conflict): De-obfuscate
if (shiftp)
for (i = 0; i < shiftp->nshifts; i++)
- if (shiftp->shifts[i] && SHIFT_SYMBOL (shiftp, i) == token)
- shiftp->shifts[i] = 0;
+ if (!SHIFT_IS_DISABLED (shiftp, i) && SHIFT_SYMBOL (shiftp, i) == token)
+ SHIFT_DISABLE (shiftp, i);
}
shiftp = state_table[state].shift_table;
if (shiftp)
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
- SETBIT (lookaheadset, SHIFT_SYMBOL (shiftp, i));
+ if (!SHIFT_IS_DISABLED (shiftp, i))
+ SETBIT (lookaheadset, SHIFT_SYMBOL (shiftp, i));
/* Loop over all rules which require lookahead in this state. First
check for shift-reduce conflict, and try to resolve using
}
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
- SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
+ if (!SHIFT_IS_DISABLED (shiftp, i))
+ SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
for (i = state_table[state].lookaheads;
i < state_table[state + 1].lookaheads;
shiftp = state_table[state].shift_table;
if (shiftp)
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
- {
- /* if this state has a shift for the error token, don't use a
- default rule. */
- if (SHIFT_IS_ERROR (shiftp, i))
- nodefault = 1;
- SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
- }
+ if (!SHIFT_IS_DISABLED (shiftp, i))
+ {
+ /* if this state has a shift for the error token, don't use a
+ default rule. */
+ if (SHIFT_IS_ERROR (shiftp, i))
+ nodefault = 1;
+ SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
+ }
errp = err_table[state];
if (errp)
if (shiftp)
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
- SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
+ if (!SHIFT_IS_DISABLED (shiftp, i))
+ SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
for (i = 0; i < ntokens; i++)
{
#define SHIFT_IS_ERROR(Shifts, Shift) \
(SHIFT_SYMBOL (Shifts, Shift) == error_token_number)
+/* When resolving a SR conflicts, if the reduction wins, the shift is
+ disabled. */
+
+#define SHIFT_DISABLE(Shifts, Shift) \
+ (Shifts->shifts[Shift] = 0)
+
+#define SHIFT_IS_DISABLED(Shifts, Shift) \
+ (Shifts->shifts[Shift] == 0)
+
/*-------.
| Errs. |