mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 05:13:04 +00:00
cex: reformat the s/r and r/r reports
In Bison we refer to "shift/reduce" conflicts, not "shift-reduce" (in
Bison 3.6.3 186 occurrences vs 15). Enforce consistency on this.
Instead of "spending" a second line for each conflict to report the
lookaheads, put that on the same line as the type of conflict. Also,
prefer "token" to "symbol". Maybe we should even prefer "lookahead".
While at it, enable internationalization, with plurals where
appropriate.
As a consequence, instead of
Shift-Reduce Conflict:
6: 3 b: . %empty
6: 6 d: c . A
On Symbol: A
display
Shift/reduce conflict on token A:
6: 3 b: . %empty
6: 6 d: c . A
* NEWS, doc/bison.texi, src/conflicts.c: Spell it "shift/reduce", not
"shift-reduce".
* src/counterexample.c (counterexample_report_shift_reduce)
(counterexample_report_reduce_reduce): Reformat and internationalize
output.
* tests/counterexample.at: Adjust expectations.
This commit is contained in:
@@ -220,7 +220,7 @@ log_resolution (rule *r, symbol_number token,
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Turn off the shift recorded for the specified token in the |
|
||||
| specified state. Used when we resolve a shift-reduce conflict in |
|
||||
| specified state. Used when we resolve a shift/reduce conflict in |
|
||||
| favor of the reduction or as an error (%nonassoc). |
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
@@ -239,7 +239,7 @@ flush_shift (state *s, int token)
|
||||
|
||||
/*--------------------------------------------------------------------.
|
||||
| Turn off the reduce recorded for the specified token in the |
|
||||
| specified lookahead set. Used when we resolve a shift-reduce |
|
||||
| specified lookahead set. Used when we resolve a shift/reduce |
|
||||
| conflict in favor of the shift or as an error (%nonassoc). |
|
||||
`--------------------------------------------------------------------*/
|
||||
|
||||
@@ -251,7 +251,7 @@ flush_reduce (bitset lookahead_tokens, int token)
|
||||
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Attempt to resolve shift-reduce conflict for one rule by means of |
|
||||
| Attempt to resolve shift/reduce conflict for one rule by means of |
|
||||
| precedence declarations. It has already been checked that the |
|
||||
| rule has a precedence. A conflict is resolved by modifying the |
|
||||
| shift or reduce tables so that there is no longer a conflict. |
|
||||
@@ -276,7 +276,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
|
||||
&& bitset_test (lookahead_set, i)
|
||||
&& symbols[i]->content->prec)
|
||||
{
|
||||
/* Shift-reduce conflict occurs for token number i
|
||||
/* Shift/reduce conflict occurs for token number i
|
||||
and it has a precedence.
|
||||
The precedence of shifting is that of token i. */
|
||||
if (symbols[i]->content->prec < redprec)
|
||||
@@ -358,7 +358,7 @@ set_conflicts (state *s, symbol **errors)
|
||||
}
|
||||
|
||||
/* Loop over all rules which require lookahead in this state. First
|
||||
check for shift-reduce conflict, and try to resolve using
|
||||
check for shift/reduce conflict, and try to resolve using
|
||||
precedence. */
|
||||
for (int i = 0; i < reds->num; ++i)
|
||||
if (reds->rules[i]->prec
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "counterexample.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include <gl_linked_list.h>
|
||||
#include <gl_rbtreehash_list.h>
|
||||
#include <hash.h>
|
||||
@@ -1214,10 +1216,9 @@ counterexample_report_shift_reduce (state_item_number itm1, state_item_number it
|
||||
symbol_number next_sym)
|
||||
{
|
||||
FILE *out = stderr;
|
||||
fputs ("Shift-Reduce Conflict:\n", out);
|
||||
fprintf (out, _("Shift/reduce conflict on token %s:\n"), symbols[next_sym]->tag);
|
||||
print_state_item (&state_items[itm1], out);
|
||||
print_state_item (&state_items[itm2], out);
|
||||
fprintf (out, "On Symbol: %s\n", symbols[next_sym]->tag);
|
||||
counterexample_report (itm1, itm2, next_sym, true);
|
||||
}
|
||||
|
||||
@@ -1226,18 +1227,21 @@ counterexample_report_reduce_reduce (state_item_number itm1, state_item_number i
|
||||
bitset conflict_syms)
|
||||
{
|
||||
FILE *out = stderr;
|
||||
fputs ("Reduce-Reduce Conflict:\n", out);
|
||||
{
|
||||
fputs (ngettext ("Reduce/reduce conflict on token",
|
||||
"Reduce/reduce conflict on tokens",
|
||||
bitset_count (conflict_syms)), out);
|
||||
bitset_iterator biter;
|
||||
state_item_number sym;
|
||||
const char *sep = " ";
|
||||
BITSET_FOR_EACH (biter, conflict_syms, sym, 0)
|
||||
{
|
||||
fprintf (out, "%s%s", sep, symbols[sym]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
fputs (_(":\n"), out);
|
||||
}
|
||||
print_state_item (&state_items[itm1], out);
|
||||
print_state_item (&state_items[itm2], out);
|
||||
fputs ("On Symbols: ", out);
|
||||
bitset_iterator biter;
|
||||
state_item_number sym;
|
||||
const char *sep = "";
|
||||
BITSET_FOR_EACH (biter, conflict_syms, sym, 0)
|
||||
{
|
||||
fprintf (out, "%s%s", sep, symbols[sym]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
fputs ("\n", out);
|
||||
counterexample_report (itm1, itm2, bitset_first (conflict_syms), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user