Commit 427acb7a authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Log a message to stdout when a conflict cannot be explained.

This allows this situation to be detected by [make test].
About 19 grammars in the test suite are affected,
which is more than I expected.
Some of these are related to issue #21.
Some of these could be conflicts that arise in unreachable nodes (a known issue).
None are artificial conflicts caused by --lalr (I have checked).
parent b00c1d69
......@@ -340,6 +340,24 @@ let explain_reduce_item
let derivation = follow1 tok derivation n configs in
derivation
(* -------------------------------------------------------------------------- *)
(* A counter of how many conflicts could *not* be explained. *)
(* When this counter is nonzero, we display a message on the standard output
channel. This can help us detect regressions via [make test]. *)
let unexplainable =
ref 0
let log_unexplainable () =
if !unexplainable > 0 then
Error.logA 2 (fun f ->
Printf.fprintf f
"%d conflict%s could not be explained.\n"
!unexplainable
(if !unexplainable > 1 then "s" else "")
)
(* -------------------------------------------------------------------------- *)
(* Putting it all together. *)
......@@ -495,6 +513,7 @@ let () =
or because [--lalr] was enabled and we have unexplainable LALR conflicts.
Anyway, send the error message to the .conflicts file and continue. *)
incr unexplainable;
Printf.fprintf out "\n\
** Conflict (unexplainable) in state %d.\n\
** Token%s involved: %s\n\
......@@ -512,6 +531,7 @@ let () =
)
);
log_unexplainable();
Time.tick "Explaining conflicts"
end
......
......@@ -257,6 +257,7 @@ File "K3Parser.mly", line 329, characters 47-53:
Warning: this %prec declaration is never useful.
Warning: 109 states have shift/reduce conflicts.
Warning: 3 states have reduce/reduce conflicts.
3 conflicts could not be explained.
Warning: 576 shift/reduce conflicts were arbitrarily resolved.
Warning: 142 reduce/reduce conflicts were arbitrarily resolved.
Warning: 266 states have an end-of-stream conflict.
......
......@@ -18,6 +18,7 @@ The grammar is not SLR(1) -- 4 states have a conflict.
Built an LR(1) automaton with 14 states.
3 shift/reduce conflicts were silently solved.
Warning: 3 states have shift/reduce conflicts.
1 conflict could not be explained.
Warning: 3 shift/reduce conflicts were arbitrarily resolved.
7 out of 14 states have a default reduction.
4 out of 14 states are represented.
......
......@@ -1146,6 +1146,7 @@ The grammar is not SLR(1) -- 83 states have a conflict.
Built an LR(1) automaton with 858 states.
Warning: 46 states have shift/reduce conflicts.
Warning: 48 states have reduce/reduce conflicts.
37 conflicts could not be explained.
Warning: 554 shift/reduce conflicts were arbitrarily resolved.
Warning: 520 reduce/reduce conflicts were arbitrarily resolved.
File "christian.mly", line 1072, characters 2-15:
......
......@@ -801,6 +801,7 @@ Built an LR(1) automaton with 1178 states.
1299 shift/reduce conflicts were silently solved.
Warning: 15 states have shift/reduce conflicts.
Warning: 2 states have reduce/reduce conflicts.
2 conflicts could not be explained.
Warning: 138 shift/reduce conflicts were arbitrarily resolved.
Warning: 2 reduce/reduce conflicts were arbitrarily resolved.
467 out of 1178 states have a default reduction.
......
......@@ -669,6 +669,7 @@ File "compsyn.mly", line 1348, characters 25-29:
Warning: this %prec declaration is never useful.
Warning: 11 states have shift/reduce conflicts.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: 38 shift/reduce conflicts were arbitrarily resolved.
Warning: one reduce/reduce conflict was arbitrarily resolved.
File "compsyn.mly", line 686, characters 36-36:
......
......@@ -34,6 +34,7 @@ The grammar is not SLR(1) -- 3 states have a conflict.
Built an LR(1) automaton with 21 states.
Warning: one state has shift/reduce conflicts.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one shift/reduce conflict was arbitrarily resolved.
Warning: one reduce/reduce conflict was arbitrarily resolved.
8 out of 21 states have a default reduction.
......
......@@ -273,6 +273,7 @@ Built an LR(1) automaton with 531 states.
54 shift/reduce conflicts were silently solved.
Warning: 29 states have shift/reduce conflicts.
Warning: 2 states have reduce/reduce conflicts.
2 conflicts could not be explained.
Warning: 63 shift/reduce conflicts were arbitrarily resolved.
Warning: 24 reduce/reduce conflicts were arbitrarily resolved.
192 out of 531 states have a default reduction.
......
......@@ -232,6 +232,7 @@ The grammar is not SLR(1) -- 66 states have a conflict.
Built an LR(1) automaton with 373 states.
2497 shift/reduce conflicts were silently solved.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: 74 reduce/reduce conflicts were arbitrarily resolved.
91 out of 373 states have a default reduction.
227 out of 373 states are represented.
......
......@@ -427,6 +427,7 @@ Built an LR(1) automaton with 559 states.
336 shift/reduce conflicts were silently solved.
Warning: one state has shift/reduce conflicts.
Warning: 4 states have reduce/reduce conflicts.
4 conflicts could not be explained.
Warning: one shift/reduce conflict was arbitrarily resolved.
Warning: 4 reduce/reduce conflicts were arbitrarily resolved.
185 out of 559 states have a default reduction.
......
......@@ -305,6 +305,7 @@ Built an LR(0) automaton with 381 states.
The grammar is not SLR(1) -- 1 states have a conflict.
Built an LR(1) automaton with 381 states.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one reduce/reduce conflict was arbitrarily resolved.
191 out of 381 states have a default reduction.
60 out of 381 states are represented.
......
......@@ -29,6 +29,7 @@ Built an LR(0) automaton with 32 states.
The grammar is not SLR(1) -- 1 states have a conflict.
Built an LR(1) automaton with 32 states.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one reduce/reduce conflict was arbitrarily resolved.
10 out of 32 states have a default reduction.
9 out of 32 states are represented.
......
......@@ -17,6 +17,7 @@ Built an LR(0) automaton with 20 states.
The grammar is not SLR(1) -- 1 states have a conflict.
Built an LR(1) automaton with 21 states.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one reduce/reduce conflict was arbitrarily resolved.
7 out of 21 states have a default reduction.
6 out of 21 states are represented.
......
......@@ -63,6 +63,7 @@ Built an LR(1) automaton with 293 states.
581 shift/reduce conflicts were silently solved.
Warning: 62 states have shift/reduce conflicts.
Warning: 6 states have reduce/reduce conflicts.
3 conflicts could not be explained.
Warning: 440 shift/reduce conflicts were arbitrarily resolved.
Warning: 146 reduce/reduce conflicts were arbitrarily resolved.
File "jingoo.1.2.9-jg_parser.mly", line 159, characters 2-12:
......
......@@ -510,6 +510,7 @@ The grammar is not SLR(1) -- 14 states have a conflict.
Built an LR(1) automaton with 733 states.
Warning: 2 states have shift/reduce conflicts.
Warning: 2 states have reduce/reduce conflicts.
2 conflicts could not be explained.
Warning: 2 shift/reduce conflicts were arbitrarily resolved.
Warning: 2 reduce/reduce conflicts were arbitrarily resolved.
288 out of 733 states have a default reduction.
......
......@@ -635,6 +635,7 @@ Built an LR(0) automaton with 828 states.
The grammar is not SLR(1) -- 9 states have a conflict.
Built an LR(1) automaton with 847 states.
Warning: 2 states have reduce/reduce conflicts.
2 conflicts could not be explained.
Warning: 4 reduce/reduce conflicts were arbitrarily resolved.
385 out of 847 states have a default reduction.
249 out of 847 states are represented.
......
......@@ -595,6 +595,7 @@ File "metaocaml.mly", line 1577, characters 25-34:
Warning: this %prec declaration is never useful.
Warning: 12 states have shift/reduce conflicts.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: 142 shift/reduce conflicts were arbitrarily resolved.
Warning: 6 reduce/reduce conflicts were arbitrarily resolved.
File "metaocaml.mly", line 1164, characters 5-27:
......
......@@ -643,6 +643,7 @@ Built an LR(1) automaton with 720 states.
80 shift/reduce conflicts were silently solved.
Warning: 13 states have shift/reduce conflicts.
Warning: 11 states have reduce/reduce conflicts.
11 conflicts could not be explained.
Warning: 65 shift/reduce conflicts were arbitrarily resolved.
Warning: 356 reduce/reduce conflicts were arbitrarily resolved.
305 out of 720 states have a default reduction.
......
......@@ -510,6 +510,7 @@ The grammar is not SLR(1) -- 14 states have a conflict.
Built an LR(1) automaton with 733 states.
Warning: 2 states have shift/reduce conflicts.
Warning: 2 states have reduce/reduce conflicts.
2 conflicts could not be explained.
Warning: 2 shift/reduce conflicts were arbitrarily resolved.
Warning: 2 reduce/reduce conflicts were arbitrarily resolved.
288 out of 733 states have a default reduction.
......
......@@ -317,6 +317,7 @@ File "why-cparser.mly", line 712, characters 30-38:
Warning: this %prec declaration is never useful.
Warning: one state has shift/reduce conflicts.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one shift/reduce conflict was arbitrarily resolved.
Warning: 24 reduce/reduce conflicts were arbitrarily resolved.
188 out of 402 states have a default reduction.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment