- int cmax = 0;
- int default_LA = -1;
- int default_rule = 0;
-
- if (!nodefault)
- for (i = 0; i < state->nlookaheads; ++i)
- {
- int count = 0;
- int j, k;
-
- for (k = 0; k < tokensetsize; ++k)
- lookaheadset[k] = LA (state->lookaheadsp + i)[k] & ~shiftset[k];
-
- for (j = 0; j < ntokens; j++)
- if (BITISSET (lookaheadset, j))
- count++;
-
- if (count > cmax)
- {
- cmax = count;
- default_LA = state->lookaheadsp + i;
- default_rule = LAruleno[state->lookaheadsp + i];
- }
-
- for (k = 0; k < tokensetsize; ++k)
- shiftset[k] |= lookaheadset[k];
- }
-
- for (i = 0; i < tokensetsize; i++)
- shiftset[i] = 0;
-
- for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
- if (!SHIFT_IS_DISABLED (shiftp, i))
- SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
-
- for (i = 0; i < ntokens; i++)
- {
- int j;
- int defaulted = 0;
- int count = BITISSET (shiftset, i);
-
- for (j = 0; j < state->nlookaheads; ++j)
- {
- if (BITISSET (LA (state->lookaheadsp + j), i))
- {
- if (count == 0)
- {
- if (state->lookaheadsp + j != default_LA)
- fprintf (out,
- _(" %-4s\treduce using rule %d (%s)\n"),
- escape (symbols[i]->tag),
- LAruleno[state->lookaheadsp + j] - 1,
- escape2 (symbols[rule_table[LAruleno[state->lookaheadsp + j]].lhs]->tag));
- else
- defaulted = 1;
-
- count++;
- }
- else
- {
- if (defaulted)
- fprintf (out,
- _(" %-4s\treduce using rule %d (%s)\n"),
- escape (symbols[i]->tag),
- LAruleno[default_LA] - 1,
- escape2 (symbols[rule_table[LAruleno[default_LA]].lhs]->tag));
- defaulted = 0;
- fprintf (out,
- _(" %-4s\t[reduce using rule %d (%s)]\n"),
- escape (symbols[i]->tag),
- LAruleno[state->lookaheadsp + j] - 1,
- escape2 (symbols[rule_table[LAruleno[state->lookaheadsp + j]].lhs]->tag));
- }
- }
- }
- }
-
- if (default_LA >= 0)
- fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
- default_rule - 1,
- escape (symbols[rule_table[default_rule].lhs]->tag));
+ char *default_reductions =
+ muscle_percent_define_get ("lr.default-reductions");
+ print_reduction (out, width, _("$default"), default_reduction, true);
+ aver (0 == strcmp (default_reductions, "most")
+ || (0 == strcmp (default_reductions, "consistent")
+ && default_reduction_only)
+ || (reds->num == 1 && reds->rules[0]->number == 0));
+ free (default_reductions);