-/*----------------------------------------------------------.
-| Return the default rule of this STATE if it has one, NULL |
-| otherwise. |
-`----------------------------------------------------------*/
-
-static rule_t *
-state_default_rule (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);
- {
- transitions_t *transitions = state->shifts;
- for (i = 0; i < transitions->num && TRANSITION_IS_SHIFT (transitions, i); i++)
- if (!TRANSITION_IS_DISABLED (transitions, i))
- {
- /* If this state has a shift for the error token, don't use a
- default rule. */
- if (TRANSITION_IS_ERROR (transitions, i))
- return NULL;
- bitset_set (shiftset, TRANSITION_SYMBOL (transitions, 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->num; i++)
- if (errp->symbols[i])
- bitset_set (shiftset, errp->symbols[i]);
- }
-
- for (i = 0; i < state->nlookaheads; ++i)
- {
- int count = 0;
-
- /* How many non-masked lookaheads are there for this reduction?
- */
- bitset_andn (lookaheadset, state->lookaheads[i], shiftset);
- count = bitset_count (lookaheadset);
-
- if (count > cmax)
- {
- cmax = count;
- default_rule = state->lookaheads_rule[i];
- }
-
- /* 3. And finally, each reduction is possibly masked by previous
- reductions (in R/R conflicts, we keep the first reductions).
- */
- bitset_or (shiftset, shiftset, state->lookaheads[i]);
- }
-
- return default_rule;
-}
-
-
-/*--------------------------------------------------------------------.
-| Report a reduction of RULE on LOOKAHEADS (which can be `default'). |
-| If not ENABLED, the rule is masked by a shift or a reduce (S/R and |
-| R/R conflicts). |
-`--------------------------------------------------------------------*/