- int cmax = 0;
- int default_LA = -1;
- rule_t *default_rule = NULL;
-
- if (!nodefault)
- for (i = 0; i < state->nlookaheads; ++i)
- {
- int count = 0;
-
- bitset_andn (lookaheadset, state->lookaheads[i], shiftset);
- count = bitset_count (lookaheadset);
-
- if (count > cmax)
- {
- cmax = count;
- default_LA = i;
- default_rule = state->lookaheads_rule[i];
- }
-
- bitset_or (shiftset, shiftset, lookaheadset);
- }
-
- bitset_zero (shiftset);
-
- for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
- if (!SHIFT_IS_DISABLED (shiftp, i))
- bitset_set (shiftset, SHIFT_SYMBOL (shiftp, i));
-
- for (i = 0; i < ntokens; i++)
- {
- int j;
- int defaulted = 0;
- int count = bitset_test (shiftset, i);
-
- for (j = 0; j < state->nlookaheads; ++j)
- if (bitset_test (state->lookaheads[j], i))
- {
- if (count == 0)
- {
- if (j != default_LA)
- fprintf (out,
- _(" %-4s\treduce using rule %d (%s)\n"),
- symbol_tag_get (symbols[i]),
- state->lookaheads_rule[j]->number - 1,
- symbol_tag_get_n (state->lookaheads_rule[j]->lhs, 1));
- else
- defaulted = 1;
-
- count++;
- }
- else
- {
- if (defaulted)
- fprintf (out,
- _(" %-4s\treduce using rule %d (%s)\n"),
- symbol_tag_get (symbols[i]),
- state->lookaheads_rule[default_LA]->number - 1,
- symbol_tag_get_n (state->lookaheads_rule[default_LA]->lhs, 1));
- defaulted = 0;
- fprintf (out,
- _(" %-4s\t[reduce using rule %d (%s)]\n"),
- symbol_tag_get (symbols[i]),
- state->lookaheads_rule[j]->number - 1,
- symbol_tag_get_n (state->lookaheads_rule[j]->lhs, 1));
- }
- }
- }
-
- if (default_LA >= 0)
- fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
- default_rule->number - 1,
- symbol_tag_get (default_rule->lhs));
+ char *default_reductions =
+ muscle_percent_define_get ("lr.default-reductions");
+ print_reduction (out, width, _("$default"), default_reduction, true);
+ aver (STREQ (default_reductions, "most")
+ || (STREQ (default_reductions, "consistent")
+ && default_reduction_only)
+ || (reds->num == 1 && reds->rules[0]->number == 0));
+ free (default_reductions);