author | wenzelm |
Thu, 15 Aug 2024 12:43:17 +0200 | |
changeset 80712 | 05b16602a683 |
parent 78728 | 72631efa3821 |
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 |
|
78728
72631efa3821
explicitly reject 'handle' with catch-all patterns;
wenzelm
parents:
78035
diff
changeset
|
9 |
val command: string -> bool -> 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 |
||
78728
72631efa3821
explicitly reject 'handle' with catch-all patterns;
wenzelm
parents:
78035
diff
changeset
|
18 |
fun command environment catch_all 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 |
|
73761 | 24 |
val _ = Document_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 = |
78728
72631efa3821
explicitly reject 'handle' with catch-all patterns;
wenzelm
parents:
78035
diff
changeset
|
27 |
{environment = environment, redirect = true, verbose = true, catch_all = catch_all, |
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 |
|
78035 | 31 |
|> Local_Theory.touch_ml_env |
62862 | 32 |
|> ML_Context.exec (fn () => ML_Context.eval_source flags source) |
33 |
|> Local_Theory.propagate_ml_env |
|
34 |
|> Context.mapping provide (Local_Theory.background_theory provide) |
|
35 |
end); |
|
36 |
||
78728
72631efa3821
explicitly reject 'handle' with catch-all patterns;
wenzelm
parents:
78035
diff
changeset
|
37 |
val ML = command "" false; |
72631efa3821
explicitly reject 'handle' with catch-all patterns;
wenzelm
parents:
78035
diff
changeset
|
38 |
val SML = command ML_Env.SML true; |
62862 | 39 |
|
40 |
end; |