[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unsatisfied %expectations
From: |
Akim Demaille |
Subject: |
Unsatisfied %expectations |
Date: |
Fri, 18 Nov 2005 12:46:13 +0100 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
I was just horrified to discover that unmet %expect are not errors. I
had an ambiguity that sneaked in and remain hidden in the lengthy
compilation. I propose the following patch, which is admittedly not
backward compatible, but otherwise the feature is quite meaningless...
An alternative would be introducing -Werror, but (i) that's more work
:( and (ii) it still should be an error, not a warning!
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/conflicts.c (conflicts_print): Unsatisfied %expectation are
errors.
Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.130
diff -u -u -r1.130 NEWS
--- NEWS 21 Oct 2005 11:36:22 -0000 1.130
+++ NEWS 18 Nov 2005 11:43:16 -0000
@@ -3,6 +3,10 @@
Changes in version 2.1a:
+* %expect, %expect-rr
+ Incorrect numbers of expected conflicts are now actual errors,
+ instead of warnings.
+
* GLR, YACC parsers.
The %parse-params are available in the %destructor's (and the
experimental %printer's) as per the documentation.
Index: doc/bison.texinfo
===================================================================
RCS file: /cvsroot/bison/bison/doc/bison.texinfo,v
retrieving revision 1.166
diff -u -u -r1.166 bison.texinfo
--- doc/bison.texinfo 12 Nov 2005 14:13:03 -0000 1.166
+++ doc/bison.texinfo 18 Nov 2005 11:43:17 -0000
@@ -3915,17 +3915,16 @@
Here @var{n} is a decimal integer. The declaration says there should be
no warning if there are @var{n} shift/reduce conflicts and no
-reduce/reduce conflicts. The usual warning is
-given if there are either more or fewer conflicts, or if there are any
-reduce/reduce conflicts.
-
-For normal @acronym{LALR}(1) parsers, reduce/reduce conflicts are more serious,
-and should be eliminated entirely. Bison will always report
-reduce/reduce conflicts for these parsers. With @acronym{GLR} parsers,
however,
-both shift/reduce and reduce/reduce are routine (otherwise, there
-would be no need to use @acronym{GLR} parsing). Therefore, it is also possible
-to specify an expected number of reduce/reduce conflicts in @acronym{GLR}
-parsers, using the declaration:
+reduce/reduce conflicts. An error is issued if there are either more or
+fewer conflicts, or if there are any reduce/reduce conflicts.
+
+For normal @acronym{LALR}(1) parsers, reduce/reduce conflicts are more
+serious, and should be eliminated entirely. Bison will always report
+reduce/reduce conflicts for these parsers. With @acronym{GLR} parsers,
+however, both shift/reduce and reduce/reduce are routine (otherwise,
+there would be no need to use @acronym{GLR} parsing). Therefore, it is
+also possible to specify an expected number of reduce/reduce conflicts
+in @acronym{GLR} parsers, using the declaration:
@example
%expect-rr @var{n}
@@ -3950,8 +3949,8 @@
@end itemize
Now Bison will stop annoying you if you do not change the number of
-conflicts, but it will warn you again if changes in the grammar result
-in more or fewer conflicts.
+conflicts, unless changes in the grammar result in more or fewer
+conflicts.
@node Start Decl
@subsection The Start-Symbol
Index: src/conflicts.c
===================================================================
RCS file: /cvsroot/bison/bison/src/conflicts.c,v
retrieving revision 1.111
diff -u -u -r1.111 conflicts.c
--- src/conflicts.c 14 May 2005 06:49:47 -0000 1.111
+++ src/conflicts.c 18 Nov 2005 11:43:17 -0000
@@ -1,6 +1,6 @@
/* Find and resolve or report look-ahead conflicts for bison,
- Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004
+ Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -508,13 +508,13 @@
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",
- sr), sr);
+ complain (ngettext ("expected %d shift/reduce conflict",
+ "expected %d shift/reduce conflicts",
+ sr), sr);
if (! rrc_ok)
- warn (ngettext ("expected %d reduce/reduce conflict",
- "expected %d reduce/reduce conflicts",
- rr), rr);
+ complain (ngettext ("expected %d reduce/reduce conflict",
+ "expected %d reduce/reduce conflicts",
+ rr), rr);
}
}
- Unsatisfied %expectations,
Akim Demaille <=