| author | wenzelm | 
| Tue, 23 Mar 2021 13:13:31 +0100 | |
| changeset 73473 | 2cc9bd9a7357 | 
| parent 72747 | 5f9d66155081 | 
| child 73761 | ef1a18e20ace | 
| permissions | -rw-r--r-- | 
| 62862 | 1  | 
(* Title: Pure/ML/ml_file.ML  | 
2  | 
Author: Makarius  | 
|
3  | 
||
4  | 
Commands to load ML files.  | 
|
5  | 
*)  | 
|
6  | 
||
7  | 
signature ML_FILE =  | 
|
8  | 
sig  | 
|
| 
72747
 
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
 
wenzelm 
parents: 
69851 
diff
changeset
 | 
9  | 
val command: string -> bool option -> (theory -> Token.file) ->  | 
| 
68816
 
5a53724fe247
support named ML environments, notably "Isabelle", "SML";
 
wenzelm 
parents: 
67381 
diff
changeset
 | 
10  | 
Toplevel.transition -> Toplevel.transition  | 
| 
72747
 
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
 
wenzelm 
parents: 
69851 
diff
changeset
 | 
11  | 
val ML: bool option -> (theory -> Token.file) -> Toplevel.transition -> Toplevel.transition  | 
| 
 
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
 
wenzelm 
parents: 
69851 
diff
changeset
 | 
12  | 
val SML: bool option -> (theory -> Token.file) -> Toplevel.transition -> Toplevel.transition  | 
| 62862 | 13  | 
end;  | 
14  | 
||
15  | 
structure ML_File: ML_FILE =  | 
|
16  | 
struct  | 
|
17  | 
||
| 
72747
 
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
 
wenzelm 
parents: 
69851 
diff
changeset
 | 
18  | 
fun command environment debug get_file = Toplevel.generic_theory (fn gthy =>  | 
| 62862 | 19  | 
let  | 
| 
72747
 
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
 
wenzelm 
parents: 
69851 
diff
changeset
 | 
20  | 
val file = get_file (Context.theory_of gthy);  | 
| 69851 | 21  | 
val provide = Resources.provide_file file;  | 
22  | 
val source = Token.file_source file;  | 
|
| 
67377
 
143665524d8e
check formal comments recursively, within arbitrary cartouches (unknown sublanguages);
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
23  | 
|
| 67381 | 24  | 
val _ = Thy_Output.check_comments (Context.proof_of gthy) (Input.source_explode source);  | 
| 
67377
 
143665524d8e
check formal comments recursively, within arbitrary cartouches (unknown sublanguages);
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
25  | 
|
| 
68816
 
5a53724fe247
support named ML environments, notably "Isabelle", "SML";
 
wenzelm 
parents: 
67381 
diff
changeset
 | 
26  | 
val flags: ML_Compiler.flags =  | 
| 
68820
 
2e4df245754e
clarified environment: allow "read>write" specification;
 
wenzelm 
parents: 
68816 
diff
changeset
 | 
27  | 
      {environment = environment, redirect = true, verbose = true,
 | 
| 
62902
 
3c0f53eae166
more conventional theory syntax for ML bootstrap, with 'ML_file' instead of 'use';
 
wenzelm 
parents: 
62873 
diff
changeset
 | 
28  | 
debug = debug, writeln = writeln, warning = warning};  | 
| 62862 | 29  | 
in  | 
30  | 
gthy  | 
|
31  | 
|> ML_Context.exec (fn () => ML_Context.eval_source flags source)  | 
|
32  | 
|> Local_Theory.propagate_ml_env  | 
|
33  | 
|> Context.mapping provide (Local_Theory.background_theory provide)  | 
|
34  | 
end);  | 
|
35  | 
||
| 
68820
 
2e4df245754e
clarified environment: allow "read>write" specification;
 
wenzelm 
parents: 
68816 
diff
changeset
 | 
36  | 
val ML = command "";  | 
| 
 
2e4df245754e
clarified environment: allow "read>write" specification;
 
wenzelm 
parents: 
68816 
diff
changeset
 | 
37  | 
val SML = command ML_Env.SML;  | 
| 62862 | 38  | 
|
39  | 
end;  |