summaryrefslogtreecommitdiff
path: root/src/conflicts.c
diff options
context:
space:
mode:
authorPaul Hilfinger <Hilfinger@CS.Berkeley.EDU>2004-03-26 22:41:16 +0000
committerPaul Hilfinger <Hilfinger@CS.Berkeley.EDU>2004-03-26 22:41:16 +0000
commitd63282419d27320c40be57d46418a0b44691626c (patch)
tree297b056008f97300f98a48d6a030aa9d11787b21 /src/conflicts.c
parent1452af69b4f4d2aeabf50918e9b6039cc809b988 (diff)
downloadbison-d63282419d27320c40be57d46418a0b44691626c.tar.gz
* src/parse-gram.y: Define PERCENT_EXPECT_RR.
(declaration): Replace expected_conflicts with expected_sr_conflicts. Add %expect-rr rule. * src/scan-gram.l: Recognize %expect-rr. * src/conflicts.h (expected_sr_conflicts): Rename from expected_conflicts. (expected_rr_conflicts): Declare. * src/conflicts.c (expected_sr_conflicts): Rename from expected_conflicts. (expected_rr_conflicts): Define. (conflicts_print): Check r/r conflicts against expected_rr_conflicts for GLR parsers. Use expected_sr_conflicts in place of expected_conflicts. Warn if expected_rr_conflicts used in non-GLR parser. * doc/bison.texinfo: Add documentation for %expect-rr.
Diffstat (limited to 'src/conflicts.c')
-rw-r--r--src/conflicts.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/conflicts.c b/src/conflicts.c
index 44546e1c..7ad2ad12 100644
--- a/src/conflicts.c
+++ b/src/conflicts.c
@@ -36,7 +36,8 @@
#include "symtab.h"
/* -1 stands for not specified. */
-int expected_conflicts = -1;
+int expected_sr_conflicts = -1;
+int expected_rr_conflicts = -1;
static char *conflicts = NULL;
struct obstack solved_conflicts_obstack;
@@ -464,6 +465,7 @@ conflicts_print (void)
not set, and then we want 0 SR, or else it is specified, in which
case we want equality. */
bool src_ok = false;
+ bool rrc_ok = false;
int src_total = 0;
int rrc_total = 0;
@@ -480,11 +482,20 @@ conflicts_print (void)
}
}
- src_ok = src_total == (expected_conflicts == -1 ? 0 : expected_conflicts);
+ if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
+ {
+ warn (_("%expect-rr applies only to GLR parsers"));
+ expected_rr_conflicts = -1;
+ }
+
+ src_ok =
+ src_total == (expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts);
+ rrc_ok =
+ rrc_total == (expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts);
- /* If there are no RR conflicts, and as many SR conflicts as
+ /* If there are as many RR conflicts and SR conflicts as
expected, then there is nothing to report. */
- if (!rrc_total && src_ok)
+ if (rrc_ok && src_ok)
return;
/* Report the total number of conflicts on STDERR. */
@@ -492,15 +503,18 @@ conflicts_print (void)
fprintf (stderr, "%s: ", current_file);
conflict_report (stderr, src_total, rrc_total);
- if (expected_conflicts != -1)
+ if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
{
+ int sr = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts;
+ int rr = expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts;
if (! src_ok)
warn (ngettext ("expected %d shift/reduce conflict",
"expected %d shift/reduce conflicts",
- expected_conflicts),
- expected_conflicts);
- if (rrc_total)
- warn (_("expected 0 reduce/reduce conflicts"));
+ sr), sr);
+ if (! rrc_ok)
+ warn (ngettext ("expected %d reduce/reduce conflict",
+ "expected %d reduce/reduce conflicts",
+ rr), rr);
}
}