src/Pure/ML/ml_file.ML
author wenzelm
Sat, 05 Mar 2016 21:23:28 +0100
changeset 62523 5335e5c53312
parent 60957 574254152856
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58928
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/ML/ml_file.ML
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     3
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     4
The 'ML_file' command.
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     5
*)
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     6
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     7
structure ML_File: sig end =
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     8
struct
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
     9
60957
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    10
fun ML_file_cmd debug files = Toplevel.generic_theory (fn gthy =>
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    11
  let
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    12
    val [{src_path, lines, digest, pos}: Token.file] = files (Context.theory_of gthy);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    13
    val provide = Resources.provide (src_path, digest);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    14
    val source = Input.source true (cat_lines lines) (pos, pos);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    15
    val flags: ML_Compiler.flags =
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    16
      {SML = false, exchange = false, redirect = true, verbose = true,
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    17
        debug = debug, writeln = writeln, warning = warning};
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    18
  in
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    19
    gthy
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    20
    |> ML_Context.exec (fn () => ML_Context.eval_source flags source)
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    21
    |> Local_Theory.propagate_ml_env
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    22
    |> Context.mapping provide (Local_Theory.background_theory provide)
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    23
  end);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    24
58928
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
    25
val _ =
60957
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    26
  Outer_Syntax.command ("ML_file", @{here}) "read and evaluate Isabelle/ML file"
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    27
    (Resources.parse_files "ML_file" >> ML_file_cmd NONE);
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    28
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    29
val _ =
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    30
  Outer_Syntax.command ("ML_file_debug", @{here})
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    31
    "read and evaluate Isabelle/ML file (with debugger information)"
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    32
    (Resources.parse_files "ML_file_debug" >> ML_file_cmd (SOME true));
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    33
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    34
val _ =
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    35
  Outer_Syntax.command ("ML_file_no_debug", @{here})
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    36
    "read and evaluate Isabelle/ML file (no debugger information)"
574254152856 support for ML files with/without debugger information;
wenzelm
parents: 60956
diff changeset
    37
    (Resources.parse_files "ML_file_no_debug" >> ML_file_cmd (SOME false));
58928
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
    38
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
diff changeset
    39
end;