23 val get_stored_thm: unit -> thm |
23 val get_stored_thm: unit -> thm |
24 val ml_store_thms: string * thm list -> unit |
24 val ml_store_thms: string * thm list -> unit |
25 val ml_store_thm: string * thm -> unit |
25 val ml_store_thm: string * thm -> unit |
26 type antiq = Proof.context -> (Proof.context -> string * string) * Proof.context |
26 type antiq = Proof.context -> (Proof.context -> string * string) * Proof.context |
27 val add_antiq: string -> (Position.T -> antiq context_parser) -> unit |
27 val add_antiq: string -> (Position.T -> antiq context_parser) -> unit |
28 val trace: bool Unsynchronized.ref |
28 val trace_raw: Config.raw |
|
29 val trace: bool Config.T |
29 val eval_antiquotes: ML_Lex.token Antiquote.antiquote list * Position.T -> |
30 val eval_antiquotes: ML_Lex.token Antiquote.antiquote list * Position.T -> |
30 Context.generic option -> (ML_Lex.token list * ML_Lex.token list) * Context.generic option |
31 Context.generic option -> (ML_Lex.token list * ML_Lex.token list) * Context.generic option |
31 val eval: bool -> Position.T -> ML_Lex.token Antiquote.antiquote list -> unit |
32 val eval: bool -> Position.T -> ML_Lex.token Antiquote.antiquote list -> unit |
32 val eval_text: bool -> Position.T -> Symbol_Pos.text -> unit |
33 val eval_text: bool -> Position.T -> Symbol_Pos.text -> unit |
33 val eval_file: Path.T -> unit |
34 val eval_file: Path.T -> unit |
170 val (decls, (_, ctxt')) = fold_map expand ants (Stack.init ctxt, ctxt); |
171 val (decls, (_, ctxt')) = fold_map expand ants (Stack.init ctxt, ctxt); |
171 val ml = decls |> map (fn decl => decl ctxt') |> split_list |> pairself flat; |
172 val ml = decls |> map (fn decl => decl ctxt') |> split_list |> pairself flat; |
172 in (ml, SOME (Context.Proof ctxt')) end; |
173 in (ml, SOME (Context.Proof ctxt')) end; |
173 in ((begin_env @ ml_env @ end_env, ml_body), opt_ctxt') end; |
174 in ((begin_env @ ml_env @ end_env, ml_body), opt_ctxt') end; |
174 |
175 |
175 val trace = Unsynchronized.ref false; |
176 val trace_raw = Config.declare "ML_trace" (fn _ => Config.Bool false); |
|
177 val trace = Config.bool trace_raw; |
176 |
178 |
177 fun eval verbose pos ants = |
179 fun eval verbose pos ants = |
178 let |
180 let |
179 (*prepare source text*) |
181 (*prepare source text*) |
180 val ((env, body), env_ctxt) = |
182 val ((env, body), env_ctxt) = |
181 eval_antiquotes (ants, pos) (Context.thread_data ()) |
183 eval_antiquotes (ants, pos) (Context.thread_data ()) |
182 ||> Option.map (Context.mapping I (Context_Position.set_visible false)); |
184 ||> Option.map (Context.mapping I (Context_Position.set_visible false)); |
183 val _ = |
185 val _ = |
184 if ! trace then tracing (cat_lines [ML_Lex.flatten env, ML_Lex.flatten body]) |
186 (case env_ctxt of |
185 else (); |
187 SOME context => |
|
188 if Config.get (Context.proof_of context) trace then |
|
189 tracing (cat_lines [ML_Lex.flatten env, ML_Lex.flatten body]) |
|
190 else () |
|
191 | NONE => ()); |
186 |
192 |
187 (*prepare static ML environment*) |
193 (*prepare static ML environment*) |
188 val _ = Context.setmp_thread_data env_ctxt |
194 val _ = Context.setmp_thread_data env_ctxt |
189 (fn () => (ML_Compiler.eval false Position.none env; Context.thread_data ())) () |
195 (fn () => (ML_Compiler.eval false Position.none env; Context.thread_data ())) () |
190 |> (fn NONE => () | SOME context' => Context.>> (ML_Env.inherit context')); |
196 |> (fn NONE => () | SOME context' => Context.>> (ML_Env.inherit context')); |