Commit 4b6647fd authored by POTTIER Francois's avatar POTTIER Francois

Fix DWordBitSet.add and QWordBitSet.add so as to ensure that TerminalSet.add

always preserves physical equality when the element is already in the set.
This property was exploited by the conflict explanation code. The failure
of this property (since 2020/01/30) would cause all reduce/reduce conflicts
to be mistakenly declared unexplainable.
parent a8de2811
......@@ -63,9 +63,11 @@ let add i s =
singleton i
| D (hi, lo) ->
if i < A.bound then
D (hi, A.add i lo)
let lo' = A.add i lo in
if lo == lo' then s else D (hi, lo')
else
D (A.add (i - A.bound) hi, lo)
let hi' = A.add (i - A.bound) hi in
if hi == hi' then s else D (hi', lo)
let remove i s =
match s with
......
......@@ -79,17 +79,21 @@ let add i s =
| Q (hhi, hlo, lhi, llo) ->
if i < middle then
if i < quarter then
Q (hhi, hlo, lhi, A.add i llo)
let llo' = A.add i llo in
if llo == llo' then s else Q (hhi, hlo, lhi, llo')
else
let i = i - quarter in
Q (hhi, hlo, A.add i lhi, llo)
let lhi' = A.add i lhi in
if lhi == lhi' then s else Q (hhi, hlo, lhi', llo)
else
let i = i - middle in
if i < quarter then
Q (hhi, A.add i hlo, lhi, llo)
let hlo' = A.add i hlo in
if hlo == hlo' then s else Q (hhi, hlo', lhi, llo)
else
let i = i - quarter in
Q (A.add i hhi, hlo, lhi, llo)
let hhi' = A.add i hhi in
if hhi == hhi' then s else Q (hhi', hlo, lhi, llo)
let remove i s =
match s with
......
......@@ -258,7 +258,6 @@ 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.
......
......@@ -1147,7 +1147,6 @@ The construction mode is pager.
Built an LR(1) automaton with 857 states.
Warning: 45 states have shift/reduce conflicts.
Warning: 47 states have reduce/reduce conflicts.
37 conflicts could not be explained.
Warning: 545 shift/reduce conflicts were arbitrarily resolved.
Warning: 515 reduce/reduce conflicts were arbitrarily resolved.
File "christian.mly", line 1072, characters 2-15:
......
......@@ -802,7 +802,6 @@ 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.
......
......@@ -670,7 +670,6 @@ 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:
......
......@@ -274,7 +274,6 @@ 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.
......
......@@ -233,7 +233,6 @@ The construction mode is pager.
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.
......
......@@ -428,7 +428,6 @@ 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.
......
......@@ -306,7 +306,6 @@ The grammar is not SLR(1) -- 1 states have a conflict.
The construction mode is pager.
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.
......
......@@ -64,7 +64,6 @@ 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:
......
......@@ -132,7 +132,6 @@ The grammar is not SLR(1) -- 1 states have a conflict.
The construction mode is pager.
Built an LR(1) automaton with 3 states.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one reduce/reduce conflict was arbitrarily resolved.
File "joe_parser2.mly", line 27, characters 4-14:
Warning: production look_for_trouble -> COOL_TOKEN is never reduced.
......
......@@ -511,7 +511,6 @@ The construction mode is pager.
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.
......
......@@ -636,7 +636,6 @@ The grammar is not SLR(1) -- 9 states have a conflict.
The construction mode is pager.
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.
......
......@@ -596,7 +596,6 @@ 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:
......
......@@ -664,7 +664,6 @@ The construction mode is pager.
Built an LR(1) automaton with 1092 states.
649 shift/reduce conflicts were silently solved.
Warning: one state has reduce/reduce conflicts.
1 conflict could not be explained.
Warning: one reduce/reduce conflict was arbitrarily resolved.
462 out of 1092 states have a default reduction.
333 out of 1092 states are represented.
......
(* menhir 20200211 reports one unexplainable conflict in this grammar. *)
(* Origin: https://github.com/cornell-netlab/petr4/blob/master/lib/parser.mly *)
(* Copyright 2019-present Cornell University
......
......@@ -644,7 +644,6 @@ 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.
......
......@@ -511,7 +511,6 @@ The construction mode is pager.
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.
......
......@@ -318,7 +318,6 @@ 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