Commit 163855af authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Improve end-of-stream conflict reports in the .automaton file.

The end-of-stream conflicts are now printed at each state,
instead of at the end of the file.

They are now printed before conflict resolution is performed
(thus better conforming to what the manual says) whereas they
used to be printed afterwards.
parent 287949db
......@@ -652,6 +652,27 @@ let dump_node out node =
fprintf out "** Conflict on %s\n"
(TerminalSet.print (conflict_tokens node));
(* Print the end-of-stream conflicts. *)
has_eos_conflict.(raw node) |> Option.iter begin fun (prods, toks) ->
(* If this function is invoked before conflict resolution has been
performed, then the list [prods] could have several elements.
We pick one. *)
assert (prods <> []);
let prod = List.hd prods in
fprintf out "** End-of-stream conflict on %s\n"
(TerminalSet.print toks);
fprintf out
"** There is a tension between\n\
** (1) %s\n\
** without even requesting a lookahead token, and\n\
** (2) testing whether the lookahead token is a member of the above set.\n"
(Production.describe prod)
end;
(* Skip a line. *)
fprintf out "\n"
......@@ -940,39 +961,12 @@ let default_conflict_resolution () =
if Lr0.has_eos_conflict transitions reductions then begin
(* Suppress the reduce action at [#]. *)
let prods, reductions =
let _, reductions =
TerminalMap.lookup_and_remove Terminal.sharp reductions in
set_reductions node reductions;
(* We can assume that there is only one reduction on [#]. *)
let prod = Misc.single prods in
(* Count this end-of-stream conflict. *)
incr eos_conflicts;
(* Signal this end-of-stream conflict in the .automaton file. *)
if Settings.dump then begin
(* Compute the tokens involved in the transitions and remaining
reductions. *)
let toks =
TerminalSet.union
(Lr0.transition_tokens transitions)
(Lr0.reduction_tokens reductions)
in
(* Emit a message. *)
Printf.fprintf (Lazy.force out)
"State %d has an end-of-stream conflict. There is a tension between\n\
(1) %s\n\
without even requesting a lookahead token, and\n\
(2) checking whether the lookahead token is %s%s,\n\
which would require some other action.\n\n"
(number node)
(Production.describe prod)
(if TerminalSet.cardinal toks > 1 then "one of " else "")
(TerminalSet.print toks)
end
incr eos_conflicts
end
end;
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,6 +6,11 @@ main' -> . main [ # ]
-- On C reduce production liste(A) ->
-- On B reduce production liste(A) ->
-- On # reduce production liste(A) ->
** End-of-stream conflict on C B A
** There is a tension between
** (1) reducing production liste(A) ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 1:
liste(A) -> A . liste(A) [ C B # ]
......@@ -14,12 +19,22 @@ liste(A) -> A . liste(A) [ C B # ]
-- On C reduce production liste(A) ->
-- On B reduce production liste(A) ->
-- On # reduce production liste(A) ->
** End-of-stream conflict on C B A
** There is a tension between
** (1) reducing production liste(A) ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 2:
liste(A) -> A liste(A) . [ C B # ]
-- On C reduce production liste(A) -> A liste(A)
-- On B reduce production liste(A) -> A liste(A)
-- On # reduce production liste(A) -> A liste(A)
** End-of-stream conflict on C B
** There is a tension between
** (1) reducing production liste(A) -> A liste(A)
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 3:
main' -> main . [ # ]
......@@ -31,6 +46,11 @@ main -> liste(A) . liste(B) liste(C) [ # ]
-- On liste(B) shift to state 7
-- On C reduce production liste(B) ->
-- On # reduce production liste(B) ->
** End-of-stream conflict on C B
** There is a tension between
** (1) reducing production liste(B) ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 5:
liste(B) -> B . liste(B) [ C # ]
......@@ -38,23 +58,43 @@ liste(B) -> B . liste(B) [ C # ]
-- On liste(B) shift to state 6
-- On C reduce production liste(B) ->
-- On # reduce production liste(B) ->
** End-of-stream conflict on C B
** There is a tension between
** (1) reducing production liste(B) ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 6:
liste(B) -> B liste(B) . [ C # ]
-- On C reduce production liste(B) -> B liste(B)
-- On # reduce production liste(B) -> B liste(B)
** End-of-stream conflict on C
** There is a tension between
** (1) reducing production liste(B) -> B liste(B)
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 7:
main -> liste(A) liste(B) . liste(C) [ # ]
-- On C shift to state 8
-- On liste(C) shift to state 10
-- On # reduce production liste(C) ->
** End-of-stream conflict on C
** There is a tension between
** (1) reducing production liste(C) ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 8:
liste(C) -> C . liste(C) [ # ]
-- On C shift to state 8
-- On liste(C) shift to state 9
-- On # reduce production liste(C) ->
** End-of-stream conflict on C
** There is a tension between
** (1) reducing production liste(C) ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 9:
liste(C) -> C liste(C) . [ # ]
......@@ -64,51 +104,3 @@ State 10:
main -> liste(A) liste(B) liste(C) . [ # ]
-- On # reduce production main -> liste(A) liste(B) liste(C)
State 0 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(A) ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of C B A,
which would require some other action.
State 1 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(A) ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of C B A,
which would require some other action.
State 2 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(A) -> A liste(A)
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of C B,
which would require some other action.
State 4 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(B) ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of C B,
which would require some other action.
State 5 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(B) ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of C B,
which would require some other action.
State 6 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(B) -> B liste(B)
without even requesting a lookahead token, and
(2) checking whether the lookahead token is C,
which would require some other action.
State 7 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(C) ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is C,
which would require some other action.
State 8 has an end-of-stream conflict. There is a tension between
(1) reducing production liste(C) ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is C,
which would require some other action.
......@@ -120,14 +120,13 @@ inst -> expr DOT . [ DOT ]
-- On DOT reduce production inst -> expr DOT
-- On # reduce production debut -> expr DOT
** Conflict on DOT
** End-of-stream conflict on DOT
** There is a tension between
** (1) reducing production debut -> expr DOT
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 15:
debut' -> debut . [ # ]
-- On # accept debut
State 14 has an end-of-stream conflict. There is a tension between
(1) reducing production debut -> expr DOT
without even requesting a lookahead token, and
(2) checking whether the lookahead token is DOT,
which would require some other action.
This diff is collapsed.
This diff is collapsed.
......@@ -83,6 +83,11 @@ expr -> INT . [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF D
-- On COMP reduce production expr -> INT
-- On AND reduce production expr -> INT
-- On # reduce production expr -> INT
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> INT
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 7:
expr -> IDENT . [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -100,6 +105,11 @@ expr -> IDENT . [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF
-- On COMP reduce production expr -> IDENT
-- On AND reduce production expr -> IDENT
-- On # reduce production expr -> IDENT
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> IDENT
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 8:
expr -> PARGAUCHE expr . PARDROITE [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -144,6 +154,11 @@ expr -> expr . EXP INT [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQ
-- On COMP reduce production expr -> expr PLUS expr
-- On AND reduce production expr -> expr PLUS expr
-- On # reduce production expr -> expr PLUS expr
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> expr PLUS expr
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 11:
expr -> expr MULT . expr [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -174,6 +189,11 @@ expr -> expr . EXP INT [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQ
-- On COMP reduce production expr -> expr MULT expr
-- On AND reduce production expr -> expr MULT expr
-- On # reduce production expr -> expr MULT expr
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> expr MULT expr
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 13:
expr -> expr EXP . INT [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -195,6 +215,11 @@ expr -> expr EXP INT . [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQ
-- On COMP reduce production expr -> expr EXP INT
-- On AND reduce production expr -> expr EXP INT
-- On # reduce production expr -> expr EXP INT
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> expr EXP INT
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 15:
expr -> expr DIV . expr [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -225,6 +250,11 @@ expr -> expr . EXP INT [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQ
-- On COMP reduce production expr -> expr DIV expr
-- On AND reduce production expr -> expr DIV expr
-- On # reduce production expr -> expr DIV expr
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> expr DIV expr
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 17:
expr -> PARGAUCHE expr PARDROITE . [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -242,6 +272,11 @@ expr -> PARGAUCHE expr PARDROITE . [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IM
-- On COMP reduce production expr -> PARGAUCHE expr PARDROITE
-- On AND reduce production expr -> PARGAUCHE expr PARDROITE
-- On # reduce production expr -> PARGAUCHE expr PARDROITE
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> PARGAUCHE expr PARDROITE
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 18:
expr -> expr MINUS . expr [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -272,6 +307,11 @@ expr -> expr . EXP INT [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQ
-- On COMP reduce production expr -> expr MINUS expr
-- On AND reduce production expr -> expr MINUS expr
-- On # reduce production expr -> expr MINUS expr
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> expr MINUS expr
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 20:
expr -> expr . PLUS expr [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND # ]
......@@ -294,6 +334,11 @@ expr -> expr . EXP INT [ VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQ
-- On COMP reduce production expr -> MINUS expr
-- On AND reduce production expr -> MINUS expr
-- On # reduce production expr -> MINUS expr
** End-of-stream conflict on VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND
** There is a tension between
** (1) reducing production expr -> MINUS expr
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 21:
formula -> FORALL . id_list COMMA formula [ PARDROITE OR IMPLIES EQUIV EOF AND ]
......@@ -734,64 +779,9 @@ expr -> expr . EXP INT [ PLUS MULT MINUS EXP DIV # ]
-- On EXP shift to state 13
-- On DIV shift to state 15
-- On # accept expr
State 6 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> INT
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 7 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> IDENT
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 10 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> expr PLUS expr
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 12 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> expr MULT expr
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 14 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> expr EXP INT
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 16 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> expr DIV expr
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 17 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> PARGAUCHE expr PARDROITE
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 19 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> expr MINUS expr
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 20 has an end-of-stream conflict. There is a tension between
(1) reducing production expr -> MINUS expr
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VERTICALBAR PLUS PARDROITE OR MULT MINUS IMPLIES EXP EQUIV EOF DIV COMP AND,
which would require some other action.
State 57 has an end-of-stream conflict. There is a tension between
(1) accepting expr
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of PLUS MULT MINUS EXP DIV,
which would require some other action.
** End-of-stream conflict on PLUS MULT MINUS EXP DIV
** There is a tension between
** (1) accepting expr
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
This diff is collapsed.
This diff is collapsed.
......@@ -21,6 +21,11 @@ main' -> . main [ # ]
-- On Body shift to state 86
-- On BinPredPref shift to state 62
-- On # reduce production main ->
** End-of-stream conflict on VAR TRUE STR SING ROOT NS LPAR LEAF LAB FC FALSE EX2 EX1 CHILD ALL2 ALL1
** There is a tension between
** (1) reducing production main ->
** without even requesting a lookahead token, and
** (2) testing whether the lookahead token is a member of the above set.
State 1:
Body -> VAR . VariablesDec Formula POINTVIRGULE [ EOF ]
......@@ -790,9 +795,3 @@ State 87:
main -> Body EOF . [ # ]
-- On # reduce production main -> Body EOF
State 0 has an end-of-stream conflict. There is a tension between
(1) reducing production main ->
without even requesting a lookahead token, and
(2) checking whether the lookahead token is one of VAR TRUE STR SING ROOT NS LPAR LEAF LAB FC FALSE EX2 EX1 CHILD ALL2 ALL1,
which would require some other action.
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