equal
deleted
inserted
replaced
92 fun run_action_function f = |
92 fun run_action_function f = |
93 f () handle exn => |
93 f () handle exn => |
94 if Exn.is_interrupt exn then Exn.reraise exn |
94 if Exn.is_interrupt exn then Exn.reraise exn |
95 else print_exn exn; |
95 else print_exn exn; |
96 |
96 |
97 fun make_action_path ({index, label, name, ...} : action_context) = |
97 fun make_action_string ({index, label, name, ...} : action_context) = |
98 Path.basic (if label = "" then string_of_int index ^ "." ^ name else label); |
98 if label = "" then string_of_int index ^ "." ^ name else label; |
|
99 |
|
100 val make_action_path = Path.basic o make_action_string; |
99 |
101 |
100 fun finalize_action ({finalize, ...} : action) context = |
102 fun finalize_action ({finalize, ...} : action) context = |
101 let |
103 let |
102 val s = run_action_function finalize; |
104 val s = run_action_function finalize; |
103 val action_path = make_action_path context; |
105 val action_path = make_action_path context; |
104 val export_name = |
106 val export_name = |
105 Path.binding0 (Path.basic "mirabelle" + action_path + Path.basic "finalize"); |
107 Path.binding0 (Path.basic "mirabelle" + action_path + Path.basic "finalize"); |
|
108 val () = File.append ((Path.dir (#output_dir context)) + Path.basic "mirabelle_ML.log") |
|
109 (prefix_lines (make_action_string context ^ " finalize ") (YXML.content_of s) ^ "\n") |
106 in |
110 in |
107 if s <> "" then |
111 if s <> "" then |
108 Export.export \<^theory> export_name [XML.Text s] |
112 Export.export \<^theory> export_name [XML.Text s] |
109 else |
113 else |
110 () |
114 () |
119 val offset_path = Path.basic (string_of_int (the (Position.offset_of pos))); |
123 val offset_path = Path.basic (string_of_int (the (Position.offset_of pos))); |
120 val export_name = |
124 val export_name = |
121 Path.binding0 (Path.basic "mirabelle" + action_path + Path.basic "goal" + goal_name_path + |
125 Path.binding0 (Path.basic "mirabelle" + action_path + Path.basic "goal" + goal_name_path + |
122 line_path + offset_path); |
126 line_path + offset_path); |
123 val s = run_action_function (fn () => run_action command); |
127 val s = run_action_function (fn () => run_action command); |
|
128 val prefix = make_action_string context ^ " goal." ^ StringCvt.padRight #" " 6 (#name command) ^ |
|
129 Context.theory_long_name thy ^ " " ^ |
|
130 string_of_int (the (Position.line_of pos)) ^ ":" ^ |
|
131 string_of_int (the (Position.offset_of pos)) ^ " " |
|
132 val _ = Substring.triml |
|
133 val () = File.append ((Path.dir (#output_dir context)) + Path.basic "mirabelle_ML.log") |
|
134 (prefix_lines prefix (YXML.content_of s) ^ "\n") |
124 in |
135 in |
125 if s <> "" then |
136 if s <> "" then |
126 Export.export thy export_name [XML.Text s] |
137 Export.export thy export_name [XML.Text s] |
127 else |
138 else |
128 () |
139 () |
187 let |
198 let |
188 val mirabelle_timeout = Options.default_seconds \<^system_option>\<open>mirabelle_timeout\<close>; |
199 val mirabelle_timeout = Options.default_seconds \<^system_option>\<open>mirabelle_timeout\<close>; |
189 val mirabelle_stride = Options.default_int \<^system_option>\<open>mirabelle_stride\<close>; |
200 val mirabelle_stride = Options.default_int \<^system_option>\<open>mirabelle_stride\<close>; |
190 val mirabelle_max_calls = Options.default_int \<^system_option>\<open>mirabelle_max_calls\<close>; |
201 val mirabelle_max_calls = Options.default_int \<^system_option>\<open>mirabelle_max_calls\<close>; |
191 val mirabelle_theories = Options.default_string \<^system_option>\<open>mirabelle_theories\<close>; |
202 val mirabelle_theories = Options.default_string \<^system_option>\<open>mirabelle_theories\<close>; |
192 val mirabelle_output_dir = Options.default_string \<^system_option>\<open>mirabelle_output_dir\<close>; |
203 val mirabelle_output_dir = Options.default_string \<^system_option>\<open>mirabelle_output_dir\<close> |
|
204 |> Path.explode |
|
205 |> Isabelle_System.make_directory; |
193 val check_theory = check_theories (space_explode "," mirabelle_theories); |
206 val check_theory = check_theories (space_explode "," mirabelle_theories); |
194 |
207 |
195 fun make_commands (thy_index, (thy, segments)) = |
208 fun make_commands (thy_index, (thy, segments)) = |
196 let |
209 let |
197 val thy_long_name = Context.theory_long_name thy; |
210 val thy_long_name = Context.theory_long_name thy; |
217 |
230 |
218 (* initialize actions *) |
231 (* initialize actions *) |
219 val contexts = actions |> map_index (fn (n, (label, name, args)) => |
232 val contexts = actions |> map_index (fn (n, (label, name, args)) => |
220 let |
233 let |
221 val make_action = the (get_action name); |
234 val make_action = the (get_action name); |
222 val action_subdir = if label = "" then string_of_int n ^ "." ^ name else label |
235 val action_subdir = if label = "" then string_of_int n ^ "." ^ name else label; |
223 val output_dir = |
236 val output_dir = Path.append mirabelle_output_dir (Path.basic action_subdir); |
224 Path.append (Path.explode mirabelle_output_dir) (Path.basic action_subdir) |
|
225 val context = |
237 val context = |
226 {index = n, label = label, name = name, arguments = args, |
238 {index = n, label = label, name = name, arguments = args, |
227 timeout = mirabelle_timeout, output_dir = output_dir}; |
239 timeout = mirabelle_timeout, output_dir = output_dir}; |
228 in |
240 in |
229 (make_action context, context) |
241 (make_action context, context) |