mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
warnings: use the regular interface for s/r and r/r conflicts
The current routines used to display s/r and r/r conflicts are both
inconvenient from the programmer point of view (they do not use the
warning infrastructure) and for the user (the messages are rather
terse, not necessarily pleasant to read, and because they don't use
the same routines, they look different).
It was due to the belief (dating back to the initial checked-in
version of Bison) that, at some point, POSIX Yacc mandated the format
for these messages. Today, the Open Group's manual page for Yacc,
<http://pubs.opengroup.org/onlinepubs/009695399/utilities/yacc.html>,
explicitly states that the format of these messages is unspecified.
See commit be7280480c and
<http://lists.gnu.org/archive/html/bison-patches/2002-12/msg00027.html>.
For a discussion on the chosen warning format, see
http://lists.gnu.org/archive/html/bison-patches/2012-09/msg00039.html
In an effort to factor the handling of errors and warnings, use the
Bison warning routines to report these messages.
* src/conflicts.c (conflicts_print): Rewrite with clearer sections
about S/R and then R/R conflicts.
(conflict_report): Remove, inlined in its sole
caller...
(conflicts_output): here.
* tests/conflicts.at, tests/existing.at, tests/glr-regression.at,
* tests/reduce.at, tests/regression.at: Adjust the expected results.
* NEWS: Update.
This commit is contained in:
47
NEWS
47
NEWS
@@ -67,6 +67,53 @@ GNU Bison NEWS
|
||||
%printer {} token1 <type1> <type3>
|
||||
%destructor {} token2 <type2> <type4>
|
||||
|
||||
*** Conflicts
|
||||
|
||||
The warnings and error messages about shift/reduce and reduce/reduce
|
||||
conflicts have been normalized. For instance on the following foo.y file:
|
||||
|
||||
%glr-parser
|
||||
%%
|
||||
exp: exp '+' exp | '0' | '0';
|
||||
|
||||
compare the previous version of bison:
|
||||
|
||||
$ bison foo.y
|
||||
foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
|
||||
$ bison -Werror foo.y
|
||||
bison: warnings being treated as errors
|
||||
foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
|
||||
|
||||
with the new behavior:
|
||||
|
||||
$ bison foo.y
|
||||
foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
||||
foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
|
||||
$ bison -Werror foo.y
|
||||
bison: warnings being treated as errors
|
||||
foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
|
||||
foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
|
||||
|
||||
When %expect or %expect-rr is used, such as with bar.y:
|
||||
|
||||
%expect 0
|
||||
%glr-parser
|
||||
%%
|
||||
exp: exp '+' exp | '0' | '0';
|
||||
|
||||
Former behavior:
|
||||
|
||||
$ bison bar.y
|
||||
bar.y: conflicts: 1 shift/reduce, 2 reduce/reduce
|
||||
bar.y: expected 0 shift/reduce conflicts
|
||||
bar.y: expected 0 reduce/reduce conflicts
|
||||
|
||||
New one:
|
||||
|
||||
$ bison bar.y
|
||||
bar.y: shift/reduce conflicts: 1 found, 0 expected
|
||||
bar.y: reduce/reduce conflicts: 2 found, 0 expected
|
||||
|
||||
** Additional yylex/yyparse arguments
|
||||
|
||||
The new directive %param declares additional arguments to both yylex and
|
||||
|
||||
Reference in New Issue
Block a user