4 Commands to load ML files. |
4 Commands to load ML files. |
5 *) |
5 *) |
6 |
6 |
7 signature ML_FILE = |
7 signature ML_FILE = |
8 sig |
8 sig |
9 val command: string option -> bool option -> (theory -> Token.file list) -> |
9 val command: string -> bool option -> (theory -> Token.file list) -> |
10 Toplevel.transition -> Toplevel.transition |
10 Toplevel.transition -> Toplevel.transition |
11 val ML: bool option -> (theory -> Token.file list) -> Toplevel.transition -> Toplevel.transition |
11 val ML: bool option -> (theory -> Token.file list) -> Toplevel.transition -> Toplevel.transition |
12 val SML: bool option -> (theory -> Token.file list) -> Toplevel.transition -> Toplevel.transition |
12 val SML: bool option -> (theory -> Token.file list) -> Toplevel.transition -> Toplevel.transition |
13 end; |
13 end; |
14 |
14 |
15 structure ML_File: ML_FILE = |
15 structure ML_File: ML_FILE = |
16 struct |
16 struct |
17 |
17 |
18 fun command env debug files = Toplevel.generic_theory (fn gthy => |
18 fun command environment debug files = Toplevel.generic_theory (fn gthy => |
19 let |
19 let |
20 val [{src_path, lines, digest, pos}: Token.file] = files (Context.theory_of gthy); |
20 val [{src_path, lines, digest, pos}: Token.file] = files (Context.theory_of gthy); |
21 val provide = Resources.provide (src_path, digest); |
21 val provide = Resources.provide (src_path, digest); |
22 val source = Input.source true (cat_lines lines) (pos, pos); |
22 val source = Input.source true (cat_lines lines) (pos, pos); |
23 |
23 |
24 val _ = Thy_Output.check_comments (Context.proof_of gthy) (Input.source_explode source); |
24 val _ = Thy_Output.check_comments (Context.proof_of gthy) (Input.source_explode source); |
25 |
25 |
26 val flags: ML_Compiler.flags = |
26 val flags: ML_Compiler.flags = |
27 {read = env, write = env, redirect = true, verbose = true, |
27 {environment = environment, redirect = true, verbose = true, |
28 debug = debug, writeln = writeln, warning = warning}; |
28 debug = debug, writeln = writeln, warning = warning}; |
29 in |
29 in |
30 gthy |
30 gthy |
31 |> ML_Context.exec (fn () => ML_Context.eval_source flags source) |
31 |> ML_Context.exec (fn () => ML_Context.eval_source flags source) |
32 |> Local_Theory.propagate_ml_env |
32 |> Local_Theory.propagate_ml_env |
33 |> Context.mapping provide (Local_Theory.background_theory provide) |
33 |> Context.mapping provide (Local_Theory.background_theory provide) |
34 end); |
34 end); |
35 |
35 |
36 val ML = command NONE; |
36 val ML = command ""; |
37 val SML = command (SOME ML_Env.SML); |
37 val SML = command ML_Env.SML; |
38 |
38 |
39 end; |
39 end; |