Commit 7793038f authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Cleanup.

parent 4f22ba0e
...@@ -615,38 +615,54 @@ let out = ...@@ -615,38 +615,54 @@ let out =
(* If requested, dump a verbose description of the automaton. *) (* If requested, dump a verbose description of the automaton. *)
let dump_node out node = let dump_node out node =
let open Printf in
Printf.fprintf out "State %d:\n%s" (* Print the state number. *)
(number node)
fprintf out "State %d:\n"
(number node);
(* Print the items. *)
fprintf out "%s"
(Lr0.print "" (state node)); (Lr0.print "" (state node));
(* Print the transitions. *)
SymbolMap.iter (fun symbol node -> SymbolMap.iter (fun symbol node ->
Printf.fprintf out "-- On %s shift to state %d\n" fprintf out "-- On %s shift to state %d\n"
(Symbol.print symbol) (number node) (Symbol.print symbol) (number node)
) (transitions node); ) (transitions node);
(* TEMPORARY In the following, one might wish to group all symbols that (* Print the reductions. *)
(* One might wish to group all symbols that
lead to reducing a common production. *) lead to reducing a common production. *)
TerminalMap.iter (fun tok prods -> TerminalMap.iter (fun tok prods ->
List.iter (fun prod -> List.iter (fun prod ->
Printf.fprintf out "-- On %s " (Terminal.print tok); fprintf out "-- On %s " (Terminal.print tok);
match Production.classify prod with match Production.classify prod with
| Some nt -> | Some nt ->
Printf.fprintf out "accept %s\n" (Nonterminal.print false nt) fprintf out "accept %s\n" (Nonterminal.print false nt)
| None -> | None ->
Printf.fprintf out "reduce production %s\n" (Production.print prod) fprintf out "reduce production %s\n" (Production.print prod)
) prods ) prods
) (reductions node); ) (reductions node);
(* Print the conflicts. *)
if not (TerminalSet.is_empty (conflict_tokens node)) then if not (TerminalSet.is_empty (conflict_tokens node)) then
Printf.fprintf out "** Conflict on %s\n" fprintf out "** Conflict on %s\n"
(TerminalSet.print (conflict_tokens node)); (TerminalSet.print (conflict_tokens node));
Printf.fprintf out "\n%!" (* Skip a line. *)
fprintf out "\n"
let dump out = let dump out =
iter (dump_node out) iter (dump_node out);
flush out
let () = let () =
Time.tick "Construction of the LR(1) automaton"; Time.tick "Construction of the LR(1) automaton";
......
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