mono/mono · warning
%s: %d rules never reduced
Error message
%s: %d rules never reduced
What it means
Emitted by unused_rules() in mcs/jay/mkpar.c:251 (plural branch) when two or more grammar rules are never selected as a reduction in any parser state. Same mechanism as the singular form: post-table-build scan of `rules_used` counts rules with no reduction action. It is a warning; the parser still generates but carries dead productions.
Source
Thrown at mcs/jay/mkpar.c:251
for (i = 0; i < nstates; ++i)
{
for (p = parser[i]; p; p = p->next)
{
if (p->action_code == REDUCE && p->suppressed == 0)
rules_used[p->number] = 1;
}
}
nunused = 0;
for (i = 3; i < nrules; ++i)
if (!rules_used[i]) ++nunused;
if (nunused)
{
if (nunused == 1)
fprintf(stderr, "%s: 1 rule never reduced\n", myname);
else
fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused);
}
}
static void
remove_conflicts (void)
{
register int i;
register int symbol;
register action *p, *pref;
SRtotal = 0;
RRtotal = 0;
SRconflicts = NEW2(nstates, short);
RRconflicts = NEW2(nstates, short);
for (i = 0; i < nstates; i++)
{
SRcount = 0;
RRcount = 0;View on GitHub (pinned to 0f53e9e151)
Solutions
- Remove each unreachable rule, or wire its LHS nonterminal into a reachable production.
- Audit the nonterminal graph from the start symbol and prune dead branches.
- Re-run jay to confirm the count drops to zero.
Example fix
// before start : a ; a : 'x' ; b : 'y' ; c : 'z' ; /* b and c unreachable -> 2 rules never reduced */ // after start : a ; a : 'x' ;
Defensive patterns
Strategy: validation
Validate before calling
# Treat any 'rules never reduced' line as a build failure.
jay -v -c -o Parser.cs grammar.jay 2>jay.log
grep -qE '[0-9]+ rules never reduced' jay.log && { echo 'multiple unreachable rules'; cat jay.log; exit 1; } || true Prevention
- Prune dead nonterminals after feature removal.
- Walk the nonterminal graph from %start and drop unreached branches.
- Fail CI on any 'rules never reduced' diagnostic.
When it happens
Trigger: Multiple productions (or whole nonterminals) unreachable from the start symbol.
Common situations: Large grammar after deleting a feature but leaving its rules; importing a grammar subset whose entry points are unused; superseded alternatives accumulating.
Related errors
- %s: 1 rule never reduced
- %s: e - line %d of "%s", unexpected end-of-file
- %s: e - line %d of "%s", syntax error
- %s: e - line %d of "%s", unmatched /*
- %s: e - line %d of "%s", unterminated string
AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13).
Data as JSON: /api/errors/95619ca237d9d80d.
Report an issue: GitHub.