+
+/*----------------------------------------------------------.
+| Return the default rule of this STATE if it has one, NULL |
+| otherwise. |
+`----------------------------------------------------------*/
+
+static rule_t *
+state_default_rule_compute (state_t *state)
+{
+ reductions_t *redp = state->reductions;
+ rule_t *default_rule = NULL;
+ int cmax = 0;
+ int i;
+
+ /* No need for a lookahead. */
+ if (state->consistent)
+ return &rules[redp->rules[0]];
+
+ /* 1. Each reduction is possibly masked by the lookaheads on which
+ we shift (S/R conflicts)... */
+ bitset_zero (shiftset);
+ {
+ shifts_t *shiftp = state->shifts;
+ for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); 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))
+ return NULL;
+ bitset_set (shiftset, SHIFT_SYMBOL (shiftp, i));
+ }
+ }
+
+ /* 2. Each reduction is possibly masked by the lookaheads on which
+ we raise an error (due to %nonassoc). */
+ {
+ errs_t *errp = state->errs;
+ for (i = 0; i < errp->nerrs; i++)
+ if (errp->errs[i])
+ bitset_set (shiftset, errp->errs[i]);
+ }
+
+ for (i = 0; i < state->nlookaheads; ++i)