-/*-------------------------------------------------------------.
-| Return the default rule of S if it has one, NULL otherwise. |
-`-------------------------------------------------------------*/
-
-static rule *
-state_default_rule (state *s)
-{
- reductions *reds = s->reductions;
- rule *default_rule = NULL;
- int cmax = 0;
- int i;
-
- /* No need for a look-ahead. */
- if (s->consistent)
- return reds->rules[0];
-
- /* 1. Each reduction is possibly masked by the look-ahead tokens on which
- we shift (S/R conflicts)... */
- bitset_zero (shift_set);
- {
- transitions *trans = s->transitions;
- FOR_EACH_SHIFT (trans, i)
- {
- /* If this state has a shift for the error token, don't use a
- default rule. */
- if (TRANSITION_IS_ERROR (trans, i))
- return NULL;
- bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
- }
- }
-
- /* 2. Each reduction is possibly masked by the look-ahead tokens on which
- we raise an error (due to %nonassoc). */
- {
- errs *errp = s->errs;
- for (i = 0; i < errp->num; i++)
- if (errp->symbols[i])
- bitset_set (shift_set, errp->symbols[i]->number);
- }
-
- for (i = 0; i < reds->num; ++i)
- {
- int count = 0;
-
- /* How many non-masked look-ahead tokens are there for this
- reduction? */
- bitset_andn (look_ahead_set, reds->look_ahead_tokens[i], shift_set);
- count = bitset_count (look_ahead_set);
-
- if (count > cmax)
- {
- cmax = count;
- default_rule = reds->rules[i];
- }
-
- /* 3. And finally, each reduction is possibly masked by previous
- reductions (in R/R conflicts, we keep the first reductions).
- */
- bitset_or (shift_set, shift_set, reds->look_ahead_tokens[i]);
- }
-
- return default_rule;
-}
-
-
-/*--------------------------------------------------------------------------.
-| Report a reduction of RULE on LOOK_AHEAD_TOKEN (which can be `default'). |
-| If not ENABLED, the rule is masked by a shift or a reduce (S/R and |
-| R/R conflicts). |
-`--------------------------------------------------------------------------*/