src/Pure/ML/ml_test.ML
author wenzelm
Tue, 24 Mar 2009 11:57:41 +0100
changeset 30683 e8ac1f9d9469
parent 30681 27ee3f4ea99c
child 30704 d6d4828e74a2
permissions -rw-r--r--
datatype antiquote: maintain original Position.range, which is eventually attached to the resulting ML tokens;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/ML/ml_test.ML
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
     3
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
     4
Test of advanced ML compiler invocation in Poly/ML 5.3.
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
     5
*)
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
     6
30646
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
     7
signature ML_TEST =
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
     8
sig
30668
df8a3c2fd5a2 maintain parse trees cumulatively;
wenzelm
parents: 30646
diff changeset
     9
  val get_result: Proof.context -> PolyML.parseTree list
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    10
  val eval: bool -> Position.T -> ML_Lex.token list -> unit
30646
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    11
end
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    12
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    13
structure ML_Test: ML_TEST =
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    14
struct
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    15
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    16
(* eval ML source tokens *)
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    17
30646
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    18
structure Result = GenericDataFun
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    19
(
30668
df8a3c2fd5a2 maintain parse trees cumulatively;
wenzelm
parents: 30646
diff changeset
    20
  type T = PolyML.parseTree list;
df8a3c2fd5a2 maintain parse trees cumulatively;
wenzelm
parents: 30646
diff changeset
    21
  val empty = [];
df8a3c2fd5a2 maintain parse trees cumulatively;
wenzelm
parents: 30646
diff changeset
    22
  fun extend _ = [];
df8a3c2fd5a2 maintain parse trees cumulatively;
wenzelm
parents: 30646
diff changeset
    23
  fun merge _ _ = [];
30646
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    24
);
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    25
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    26
val get_result = Result.get o Context.Proof;
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
    27
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    28
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    29
fun use_text ({name_space = space, print, error, ...}: use_context) verbose pos toks =
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    30
  let
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    31
    (* input *)
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    32
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    33
    val input = toks |> map (fn tok =>
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    34
      (serial (), (String.explode (ML_Lex.text_of tok), ML_Lex.pos_of tok)));
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    35
    val index_pos = Inttab.lookup (Inttab.make (map (apsnd snd) input));
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    36
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    37
    fun pos_of ({file, startLine = line, startPosition = i, endPosition = j, ...}: location) =
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    38
      (case (index_pos i, index_pos j) of
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    39
        (SOME p, SOME q) => Position.encode_range (p, q)
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    40
      | (SOME p, NONE) => p
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    41
      | _ => Position.line_file line file);
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    42
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    43
    val in_buffer = ref (map (apsnd fst) input);
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    44
    val current_line = ref (the_default 1 (Position.line_of pos));
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    45
    fun get () =
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    46
      (case ! in_buffer of
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    47
        [] => NONE
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    48
      | (_, []) :: rest => (in_buffer := rest; get ())
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    49
      | (i, c :: cs) :: rest =>
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    50
          (in_buffer := (i, cs) :: rest;
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    51
           if c = #"\n" then current_line := ! current_line + 1 else ();
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    52
           SOME c));
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    53
    fun get_index () = (case ! in_buffer of [] => 0 | (i, _) :: _ => i);
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    54
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    55
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    56
    (* output *)
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    57
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    58
    val out_buffer = ref ([]: string list);
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    59
    fun output () = implode (rev (! out_buffer));
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    60
    fun put s = out_buffer := s :: ! out_buffer;
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    61
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    62
    fun put_message {message, hard, location, context = _} =
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    63
     (put (if hard then "Error: " else "Warning: ");
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    64
      put (Pretty.string_of (Pretty.from_ML (pretty_ml message)));
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    65
      put (Position.str_of (pos_of location) ^ "\n"));
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
    66
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    67
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    68
    (* results *)
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    69
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    70
    fun apply_result {fixes, types, signatures, structures, functors, values} =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    71
      let
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    72
        fun add_prefix prefix (PrettyBlock (ind, consistent, context, prts)) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    73
              let
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    74
                fun make_prefix context =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    75
                  (case get_first (fn ContextParentStructure p => SOME p | _ => NONE) context of
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    76
                    SOME (name, sub_context) => make_prefix sub_context ^ name ^ "."
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    77
                  | NONE => prefix);
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    78
                val this_prefix = make_prefix context;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    79
              in PrettyBlock (ind, consistent, context, map (add_prefix this_prefix) prts) end
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    80
          | add_prefix prefix (prt as PrettyString s) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    81
              if prefix = "" then prt else PrettyString (prefix ^ s)
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    82
          | add_prefix _ (prt as PrettyBreak _) = prt;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    83
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    84
        val depth = get_print_depth ();
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    85
        val with_struct = ! PolyML.Compiler.printTypesWithStructureName;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    86
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    87
        fun display disp x =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    88
          if depth > 0 then
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    89
            (disp x
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    90
              |> with_struct ? add_prefix ""
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    91
              |> pretty_ml |> Pretty.from_ML |> Pretty.string_of |> put; put "\n")
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    92
          else ();
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    93
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    94
        fun apply_fix (a, b) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    95
          (display PolyML.NameSpace.displayFix (a, b); #enterFix space (a, b));
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    96
        fun apply_type (a, b) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    97
          (display PolyML.NameSpace.displayType (b, depth); #enterType space (a, b));
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    98
        fun apply_sig (a, b) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
    99
          (display PolyML.NameSpace.displaySig (b, depth, space); #enterSig space (a, b));
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   100
        fun apply_struct (a, b) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   101
          (display PolyML.NameSpace.displayStruct (b, depth, space); #enterStruct space (a, b));
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   102
        fun apply_funct (a, b) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   103
          (display PolyML.NameSpace.displayFunct (b, depth, space); #enterFunct space (a, b));
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   104
        fun apply_val (a, b) =
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   105
          (display PolyML.NameSpace.displayVal (b, depth, space); #enterVal space (a, b));
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   106
      in
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   107
        List.app apply_fix fixes;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   108
        List.app apply_type types;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   109
        List.app apply_sig signatures;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   110
        List.app apply_struct structures;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   111
        List.app apply_funct functors;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   112
        List.app apply_val values
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   113
      end;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   114
30646
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
   115
    fun result_fun (parse_tree, code) () =
30668
df8a3c2fd5a2 maintain parse trees cumulatively;
wenzelm
parents: 30646
diff changeset
   116
     (Context.>> (Result.map (append (the_list parse_tree)));
30681
27ee3f4ea99c error "Static Errors";
wenzelm
parents: 30680
diff changeset
   117
      (case code of NONE => error "Static Errors" | SOME result => apply_result (result ())));
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   118
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   119
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   120
    (* compiler invocation *)
30646
d26ad4576d5c proper signature;
wenzelm
parents: 30644
diff changeset
   121
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   122
    val parameters =
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   123
     [PolyML.Compiler.CPOutStream put,
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   124
      PolyML.Compiler.CPNameSpace space,
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   125
      PolyML.Compiler.CPErrorMessageProc put_message,
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   126
      PolyML.Compiler.CPLineNo (fn () => ! current_line),
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   127
      PolyML.Compiler.CPLineOffset get_index,
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   128
      PolyML.Compiler.CPFileName (the_default "ML" (Position.file_of pos)),
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   129
      PolyML.Compiler.CPPrintInAlphabeticalOrder false,
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   130
      PolyML.Compiler.CPCompilerResultFun result_fun];
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   131
    val _ =
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   132
      (while not (List.null (! in_buffer)) do
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   133
        PolyML.compiler (get, parameters) ())
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   134
      handle exn =>
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   135
       (put ("Exception- " ^ General.exnMessage exn ^ " raised");
30677
df6ca2f50199 eliminated Output.ml_output;
wenzelm
parents: 30668
diff changeset
   136
        error (output ()); raise exn);
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   137
  in if verbose then print (output ()) else () end;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   138
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   139
val eval = use_text ML_Context.local_context;
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   140
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   141
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   142
(* ML test command *)
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   143
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   144
fun ML_test (txt, pos) =
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   145
  let
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   146
    val _ = Position.report Markup.ML_source pos;
30644
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   147
    val ants = ML_Lex.read_antiq (Symbol_Pos.explode (txt, pos), pos);
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   148
    val ((env, body), env_ctxt) = ML_Context.eval_antiquotes (ants, pos) (Context.thread_data ());
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   149
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   150
    val _ = Context.setmp_thread_data env_ctxt
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   151
        (fn () => (eval false Position.none env; Context.thread_data ())) ()
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   152
      |> (fn NONE => () | SOME context' => Context.>> (ML_Context.inherit_env context'));
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   153
    val _ = eval true pos body;
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   154
    val _ = eval false Position.none (ML_Lex.tokenize "structure Isabelle = struct end");
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   155
  in () end;
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   156
30644
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   157
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   158
local structure P = OuterParse and K = OuterKeyword in
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   159
30644
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   160
fun inherit_env (context as Context.Proof lthy) =
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   161
      Context.Proof (LocalTheory.map_contexts (ML_Context.inherit_env context) lthy)
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   162
  | inherit_env context = context;
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   163
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   164
val _ =
30644
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   165
  OuterSyntax.command "ML_test" "advanced ML compiler test" (K.tag_ml K.thy_decl)
2948f4494e86 ML_Lex.read_antiq;
wenzelm
parents: 30640
diff changeset
   166
    (P.ML_source >> (fn src =>
30680
0863bb353065 more systematic type use_context;
wenzelm
parents: 30677
diff changeset
   167
      Toplevel.generic_theory (ML_Context.exec (fn () => ML_test src) #> inherit_env)));
30640
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   168
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   169
end;
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   170
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   171
end;
3f3d1e218b64 Test of advanced ML compiler invocation in Poly/ML 5.3.
wenzelm
parents:
diff changeset
   172