src/Pure/ML/ml_context.ML
changeset 56303 4cc3f4db3447
parent 56294 85911b8a6868
child 56304 40274e4f5ebf
equal deleted inserted replaced
56302:c63ab5263008 56303:4cc3f4db3447
    15   val check_antiquotation: Proof.context -> xstring * Position.T -> string
    15   val check_antiquotation: Proof.context -> xstring * Position.T -> string
    16   type decl = Proof.context -> string * string
    16   type decl = Proof.context -> string * string
    17   val add_antiquotation: binding -> (Args.src -> Proof.context -> decl * Proof.context) ->
    17   val add_antiquotation: binding -> (Args.src -> Proof.context -> decl * Proof.context) ->
    18     theory -> theory
    18     theory -> theory
    19   val print_antiquotations: Proof.context -> unit
    19   val print_antiquotations: Proof.context -> unit
    20   val source_trace_raw: Config.raw
       
    21   val source_trace: bool Config.T
       
    22   val eval_antiquotes: ML_Lex.token Antiquote.antiquote list * Position.T ->
    20   val eval_antiquotes: ML_Lex.token Antiquote.antiquote list * Position.T ->
    23     Context.generic option -> (ML_Lex.token list * ML_Lex.token list) * Context.generic option
    21     Context.generic option -> (ML_Lex.token list * ML_Lex.token list) * Context.generic option
    24   val eval: ML_Compiler.flags -> Position.T -> ML_Lex.token Antiquote.antiquote list -> unit
    22   val eval: ML_Compiler.flags -> Position.T -> ML_Lex.token Antiquote.antiquote list -> unit
    25   val eval_file: ML_Compiler.flags -> Path.T -> unit
    23   val eval_file: ML_Compiler.flags -> Path.T -> unit
    26   val eval_source: ML_Compiler.flags -> Symbol_Pos.source -> unit
    24   val eval_source: ML_Compiler.flags -> Symbol_Pos.source -> unit
   135           val (ml_env, ml_body) =
   133           val (ml_env, ml_body) =
   136             decls |> map (fn decl => decl ctxt') |> split_list |> pairself flat;
   134             decls |> map (fn decl => decl ctxt') |> split_list |> pairself flat;
   137         in ((begin_env visible @ ml_env, ml_body), SOME (Context.Proof ctxt')) end;
   135         in ((begin_env visible @ ml_env, ml_body), SOME (Context.Proof ctxt')) end;
   138   in ((ml_env @ end_env, ml_body), opt_ctxt') end;
   136   in ((ml_env @ end_env, ml_body), opt_ctxt') end;
   139 
   137 
   140 val source_trace_raw = Config.declare "ML_source_trace" (fn _ => Config.Bool false);
       
   141 val source_trace = Config.bool source_trace_raw;
       
   142 
       
   143 fun eval flags pos ants =
   138 fun eval flags pos ants =
   144   let
   139   let
   145     val non_verbose = {SML = #SML flags, verbose = false};
   140     val non_verbose = {SML = #SML flags, verbose = false};
   146 
   141 
   147     (*prepare source text*)
   142     (*prepare source text*)
   148     val ((env, body), env_ctxt) = eval_antiquotes (ants, pos) (Context.thread_data ());
   143     val ((env, body), env_ctxt) = eval_antiquotes (ants, pos) (Context.thread_data ());
   149     val _ =
   144     val _ =
   150       (case Option.map Context.proof_of env_ctxt of
   145       (case Option.map Context.proof_of env_ctxt of
   151         SOME ctxt =>
   146         SOME ctxt =>
   152           if Config.get ctxt source_trace andalso Context_Position.is_visible ctxt
   147           if Config.get ctxt ML_Options.source_trace andalso Context_Position.is_visible ctxt
   153           then tracing (cat_lines [ML_Lex.flatten env, ML_Lex.flatten body])
   148           then tracing (cat_lines [ML_Lex.flatten env, ML_Lex.flatten body])
   154           else ()
   149           else ()
   155       | NONE => ());
   150       | NONE => ());
   156 
   151 
   157     (*prepare static ML environment*)
   152     (*prepare static ML environment*)