Commit 181905f6 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

New option --dump-resolved.

parent 7b134165
......@@ -551,6 +551,15 @@ let () =
Lr1.extra_reductions();
Time.tick "Adding extra reductions"
(* ------------------------------------------------------------------------ *)
(* The automaton is now frozen and will no longer be modified.
It is time to dump a new description of it, if requested by
the user. *)
let () =
if Settings.dump_resolved then
Lr1.dump (Settings.base ^ ".automaton.resolved")
(* ------------------------------------------------------------------------ *)
(* If any warnings about the grammar have been emitted up to this point,
and if [--strict] is enabled, now is the time to stop, before going
......
......@@ -477,6 +477,9 @@ let transitions : node SymbolMap.t array =
(* The array [conflict_tokens] is now frozen. *)
let () =
Time.tick "Construction of the LR(1) automaton"
(* -------------------------------------------------------------------------- *)
(* Accessors. *)
......@@ -670,17 +673,15 @@ let dump_node out node =
fprintf out "\n"
let dump out =
iter (dump_node out)
let dump filename =
let out = open_out filename in
iter (dump_node out);
close_out out;
Time.tick "Dumping the LR(1) automaton"
let () =
Time.tick "Construction of the LR(1) automaton";
if Settings.dump then begin
let out = open_out (Settings.base ^ ".automaton") in
dump out;
close_out out;
Time.tick "Dumping the LR(1) automaton"
end
if Settings.dump then
dump (Settings.base ^ ".automaton")
(* -------------------------------------------------------------------------- *)
......
......@@ -178,6 +178,15 @@ val default_conflict_resolution: unit -> unit
val extra_reductions: unit -> unit
(* ------------------------------------------------------------------------- *)
(* Dumping the automaton. *)
(* This function dumps a description of the automaton to the file whose
name is passed as an argument. It can be called before or after conflict
resolution has taken place. *)
val dump: string -> unit
(* ------------------------------------------------------------------------- *)
(* Information about which productions are reduced and where. *)
......
......@@ -68,6 +68,9 @@ let base =
let dump =
ref false
let dump_resolved =
ref false
let graph =
ref false
......@@ -301,6 +304,7 @@ let options = Arg.align [
"--coq-no-complete", Arg.Set coq_no_complete, " Do not generate a proof of completeness";
"--depend", Arg.Unit enable_depend, " Invoke ocamldep and display dependencies";
"--dump", Arg.Set dump, " Write an .automaton file";
"--dump-resolved", Arg.Set dump_resolved, " Write an .automaton.resolved file";
"--echo-errors", Arg.String set_echo_errors, "<filename> Echo the sentences in a .messages file";
"--error-recovery", Arg.Set recovery, " (no longer supported)";
"--explain", Arg.Set explain, " Explain conflicts in <basename>.conflicts";
......@@ -451,6 +455,9 @@ let explain =
let dump =
!dump
let dump_resolved =
!dump_resolved
let graph =
!graph
......
......@@ -43,10 +43,14 @@ val construction_mode: construction_mode
val explain: bool
(* Whether the automaton should be dumped. *)
(* Whether the automaton should be dumped before conflict resolution. *)
val dump: bool
(* Whether the automaton should be dumped after conflict resolution. *)
val dump_resolved: bool
(* Whether the grammar's dependence graph should be dumped. *)
val graph: bool
......
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