src/Pure/ML/ml_context.ML
author wenzelm
Fri, 28 Mar 2008 00:02:54 +0100
changeset 26455 1757a6e049f4
parent 26432 095e448b95a0
child 26473 2266e5fd7b63
permissions -rw-r--r--
reorganized signature of ML_Context;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24581
6491d89ba76c tuned comments;
wenzelm
parents: 24574
diff changeset
     1
(*  Title:      Pure/ML/ml_context.ML
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     3
    Author:     Makarius
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     4
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     5
ML context and antiquotations.
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     6
*)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     7
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     8
signature BASIC_ML_CONTEXT =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
     9
sig
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    10
  val store_thm: string * thm -> thm
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    11
  val store_thms: string * thm list -> thm list
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    12
  val bind_thm: string * thm -> unit
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    13
  val bind_thms: string * thm list -> unit
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    14
  val thm: xstring -> thm
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    15
  val thms: xstring -> thm list
25204
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
    16
end
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    17
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    18
signature ML_CONTEXT =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    19
sig
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    20
  include BASIC_ML_CONTEXT
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    21
  val the_generic_context: unit -> Context.generic
26432
095e448b95a0 renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents: 26416
diff changeset
    22
  val the_global_context: unit -> theory
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    23
  val the_local_context: unit -> Proof.context
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    24
  val exec: (unit -> unit) -> Context.generic -> Context.generic
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    25
  val stored_thms: thm list ref
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    26
  val ml_store_thm: string * thm -> unit
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    27
  val ml_store_thms: string * thm list -> unit
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    28
  val add_keywords: string list -> unit
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    29
  val inline_antiq: string ->
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    30
    (Context.generic * Args.T list -> string * (Context.generic * Args.T list)) -> unit
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    31
  val value_antiq: string ->
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    32
    (Context.generic * Args.T list -> (string * string) * (Context.generic * Args.T list)) -> unit
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    33
  val proj_value_antiq: string -> (Context.generic * Args.T list ->
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    34
      (string * string * string) * (Context.generic * Args.T list)) -> unit
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
    35
  val eval_antiquotes_fn: (string * Position.T -> string * string) ref  (* FIXME tmp *)
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    36
  val trace: bool ref
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    37
  val eval: bool -> Position.T -> string -> unit
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    38
  val eval_file: Path.T -> unit
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    39
  val eval_in: Context.generic option -> bool -> Position.T -> string -> unit
25204
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
    40
  val evaluate: (string -> unit) * (string -> 'b) -> bool ->
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
    41
    string * (unit -> 'a) option ref -> string -> 'a
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    42
  val expression: Position.T -> string -> string -> string -> Context.generic -> Context.generic
25204
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
    43
end
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    44
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    45
structure ML_Context: ML_CONTEXT =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    46
struct
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    47
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    48
(** implicit ML context **)
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    49
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    50
val the_generic_context = Context.the_thread_data;
26432
095e448b95a0 renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents: 26416
diff changeset
    51
val the_global_context = Context.theory_of o the_generic_context;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    52
val the_local_context = Context.proof_of o the_generic_context;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    53
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    54
fun exec (e: unit -> unit) context =
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    55
  (case Context.setmp_thread_data (SOME context) (fn () => (e (); Context.thread_data ())) () of
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    56
    SOME context' => context'
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
    57
  | NONE => error "Missing context after execution");
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    58
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    59
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    60
(* theorem bindings *)
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    61
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    62
val store_thms = PureThy.smart_store_thms;
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    63
fun store_thm (name, th) = the_single (store_thms (name, [th]));
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    64
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    65
val stored_thms: thm list ref = ref [];
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    66
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    67
fun no_ml name =
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    68
  if name = "" then true
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    69
  else if ML_Syntax.is_identifier name then false
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    70
  else error ("Cannot bind theorem(s) " ^ quote name ^ " as ML value");
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    71
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    72
val use_text_verbose = use_text (0, "") Output.ml_output true;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    73
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    74
fun ml_store_thm (name, th) =
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    75
  let val th' = store_thm (name, th) in
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    76
    if no_ml name then ()
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    77
    else setmp stored_thms [th']
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    78
      (fn () => use_text_verbose ("val " ^ name ^ " = hd (! ML_Context.stored_thms);")) ()
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    79
  end;
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    80
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    81
fun ml_store_thms (name, ths) =
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    82
  let val ths' = store_thms (name, ths) in
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    83
    if no_ml name then ()
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    84
    else setmp stored_thms ths'
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    85
      (fn () => use_text_verbose ("val " ^ name ^ " = ! ML_Context.stored_thms;")) ()
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    86
  end;
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    87
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    88
fun bind_thm (name, thm) = ml_store_thm (name, Drule.standard thm);
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
    89
fun bind_thms (name, thms) = ml_store_thms (name, map Drule.standard thms);
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    90
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    91
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    92
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    93
(** ML antiquotations **)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    94
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    95
(* maintain keywords *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    96
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    97
val global_lexicon = ref Scan.empty_lexicon;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    98
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
    99
fun add_keywords keywords = CRITICAL (fn () =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   100
  change global_lexicon (Scan.extend_lexicon (map Symbol.explode keywords)));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   101
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   102
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   103
(* maintain commands *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   104
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   105
datatype antiq = Inline of string | ProjValue of string * string * string;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   106
val global_parsers = ref (Symtab.empty:
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   107
  (Context.generic * Args.T list -> antiq * (Context.generic * Args.T list)) Symtab.table);
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   108
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   109
local
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   110
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   111
fun add_item kind name scan = CRITICAL (fn () =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   112
  change global_parsers (fn tab =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   113
   (if not (Symtab.defined tab name) then ()
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   114
    else warning ("Redefined ML antiquotation: " ^ quote name);
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   115
    Symtab.update (name, scan >> kind) tab)));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   116
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   117
in
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   118
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   119
val inline_antiq = add_item Inline;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   120
val proj_value_antiq = add_item ProjValue;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   121
fun value_antiq name scan = proj_value_antiq name (scan >> (fn (a, s) => (a, s, "")));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   122
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   123
end;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   124
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   125
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   126
(* command syntax *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   127
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   128
fun syntax scan src =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   129
  #1 (Args.context_syntax "ML antiquotation" scan src (the_local_context ()));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   130
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   131
fun command src =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   132
  let val ((name, _), pos) = Args.dest_src src in
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   133
    (case Symtab.lookup (! global_parsers) name of
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   134
      NONE => error ("Unknown ML antiquotation command: " ^ quote name ^ Position.str_of pos)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   135
    | SOME scan => syntax scan src)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   136
  end;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   137
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   138
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   139
(* outer syntax *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   140
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   141
structure T = OuterLex;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   142
structure P = OuterParse;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   143
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   144
val antiq =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   145
  P.!!! (P.position P.xname -- P.arguments --| Scan.ahead P.eof)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   146
  >> (fn ((x, pos), y) => Args.src ((x, y), pos));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   147
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   148
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   149
(* input/output wrappers *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   150
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   151
local
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   152
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   153
val isabelle_struct = enclose "structure Isabelle =\nstruct\n" "end;";
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   154
val isabelle_struct0 = isabelle_struct "";
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   155
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   156
fun eval_antiquotes txt_pos =
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   157
  let
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   158
    val ants = Antiquote.scan_antiquotes txt_pos;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   159
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   160
    fun expand (Antiquote.Text s) names = (("", Symbol.escape s), names)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   161
      | expand (Antiquote.Antiq x) names =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   162
          (case command (Antiquote.scan_arguments (! global_lexicon) antiq x) of
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   163
            Inline s => (("", s), names)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   164
          | ProjValue (a, s, f) =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   165
              let
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   166
                val a' = if ML_Syntax.is_identifier a then a else "val";
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   167
                val ([b], names') = Name.variants [a'] names;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   168
                val binding = "val " ^ b ^ " = " ^ s ^ ";\n";
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   169
                val value =
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   170
                  if f = "" then "Isabelle." ^ b
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   171
                  else "(" ^ f ^ " Isabelle." ^ b ^ ")";
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   172
              in ((binding, value), names') end);
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   173
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   174
    val (decls, body) =
25700
185ea28035ac named some critical sections;
wenzelm
parents: 25346
diff changeset
   175
      NAMED_CRITICAL "ML" (fn () => fold_map expand ants ML_Syntax.reserved)
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   176
      |> #1 |> split_list |> pairself implode;
25700
185ea28035ac named some critical sections;
wenzelm
parents: 25346
diff changeset
   177
  in (isabelle_struct decls, body) end;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   178
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   179
in
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   180
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   181
val eval_antiquotes_fn = ref eval_antiquotes;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   182
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   183
val trace = ref false;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   184
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   185
fun eval_wrapper pr verbose pos txt =
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   186
  let
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   187
    val (txt1, txt2) = ! eval_antiquotes_fn (txt, pos);  (* FIXME tmp hook *)
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   188
    val _ = if ! trace then tracing (cat_lines [txt1, txt2]) else ();
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   189
    fun eval p =
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   190
      use_text (the_default 1 (Position.line_of p), the_default "ML" (Position.file_of p)) pr;
25755
9bc082c2cc92 eval_wrapper: CRITICAL;
wenzelm
parents: 25700
diff changeset
   191
  in
9bc082c2cc92 eval_wrapper: CRITICAL;
wenzelm
parents: 25700
diff changeset
   192
    NAMED_CRITICAL "ML" (fn () =>
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   193
     (eval Position.none false txt1;
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   194
      eval pos verbose txt2;
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   195
      eval Position.none false isabelle_struct0))
25755
9bc082c2cc92 eval_wrapper: CRITICAL;
wenzelm
parents: 25700
diff changeset
   196
  end;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   197
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   198
end;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   199
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   200
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   201
(* ML evaluation *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   202
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   203
val eval = eval_wrapper Output.ml_output;
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   204
fun eval_file path = eval true (Position.path path) (File.read path);
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   205
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   206
fun eval_in context verbose pos txt =
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   207
  Context.setmp_thread_data context (fn () => eval verbose pos txt) ();
25204
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
   208
25700
185ea28035ac named some critical sections;
wenzelm
parents: 25346
diff changeset
   209
fun evaluate pr verbose (ref_name, r) txt = NAMED_CRITICAL "ML" (fn () =>
25204
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
   210
  let
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
   211
    val _ = r := NONE;
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   212
    val _ = eval_wrapper pr verbose Position.none
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   213
      ("val _ = (" ^ ref_name ^ " := SOME (fn () => " ^ txt ^ "))");
25204
36cf92f63a44 replaced Secure.evaluate by ML_Context.evaluate;
wenzelm
parents: 25142
diff changeset
   214
  in (case ! r of NONE => error ("Bad evaluation for " ^ ref_name) | SOME e => e) end) ();
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   215
26455
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   216
fun expression pos bind body txt =
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   217
  exec (fn () => eval false pos
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   218
    ("Context.set_thread_data (SOME (let " ^ bind ^ " = " ^ txt ^ " in " ^ body ^
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   219
      " end (ML_Context.the_generic_context ())));"));
1757a6e049f4 reorganized signature of ML_Context;
wenzelm
parents: 26432
diff changeset
   220
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   221
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   222
(* basic antiquotations *)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   223
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   224
fun context x = (Scan.state >> Context.proof_of) x;
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   225
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   226
local
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   227
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   228
val _ = value_antiq "context" (Scan.succeed ("context", "ML_Context.the_local_context ()"));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   229
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   230
val _ = inline_antiq "sort" (context -- Scan.lift Args.name >> (fn (ctxt, s) =>
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   231
  ML_Syntax.atomic (ML_Syntax.print_sort (Syntax.read_sort ctxt s))));
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   232
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   233
val _ = inline_antiq "typ" (Args.typ >> (ML_Syntax.atomic o ML_Syntax.print_typ));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   234
val _ = inline_antiq "term" (Args.term >> (ML_Syntax.atomic o ML_Syntax.print_term));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   235
val _ = inline_antiq "prop" (Args.prop >> (ML_Syntax.atomic o ML_Syntax.print_term));
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   236
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   237
val _ = value_antiq "ctyp" (Args.typ >> (fn T =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   238
  ("ctyp",
26432
095e448b95a0 renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents: 26416
diff changeset
   239
    "Thm.ctyp_of (ML_Context.the_global_context ()) " ^ ML_Syntax.atomic (ML_Syntax.print_typ T))));
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   240
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   241
val _ = value_antiq "cterm" (Args.term >> (fn t =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   242
  ("cterm",
26432
095e448b95a0 renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents: 26416
diff changeset
   243
    "Thm.cterm_of (ML_Context.the_global_context ()) " ^ ML_Syntax.atomic (ML_Syntax.print_term t))));
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   244
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   245
val _ = value_antiq "cprop" (Args.prop >> (fn t =>
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   246
  ("cprop",
26432
095e448b95a0 renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents: 26416
diff changeset
   247
    "Thm.cterm_of (ML_Context.the_global_context ()) " ^ ML_Syntax.atomic (ML_Syntax.print_term t))));
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   248
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   249
fun type_ syn = (context -- Scan.lift Args.name >> (fn (ctxt, c) =>
24695
2892482a4e62 added @{type_name};
wenzelm
parents: 24685
diff changeset
   250
    #1 (Term.dest_Type (ProofContext.read_tyname ctxt c))
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   251
    |> syn ? Sign.base_name
24695
2892482a4e62 added @{type_name};
wenzelm
parents: 24685
diff changeset
   252
    |> ML_Syntax.print_string));
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   253
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   254
val _ = inline_antiq "type_name" (type_ false);
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   255
val _ = inline_antiq "type_syntax" (type_ true);
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   256
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   257
fun const syn = context -- Scan.lift Args.name >> (fn (ctxt, c) =>
25346
7f2e3292e3dd renamed ProofContext.read_const' to ProofContext.read_const_proper;
wenzelm
parents: 25334
diff changeset
   258
  #1 (Term.dest_Const (ProofContext.read_const_proper ctxt c))
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   259
  |> syn ? ProofContext.const_syntax_name ctxt
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   260
  |> ML_Syntax.print_string);
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   261
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   262
val _ = inline_antiq "const_name" (const false);
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   263
val _ = inline_antiq "const_syntax" (const true);
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   264
26188
9cb1b484fe96 added @{const} antiquotation;
wenzelm
parents: 25755
diff changeset
   265
val _ = inline_antiq "const"
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   266
  (context -- Scan.lift Args.name --
26188
9cb1b484fe96 added @{const} antiquotation;
wenzelm
parents: 25755
diff changeset
   267
    Scan.optional (Scan.lift (Args.$$$ "(") |-- Args.enum1 "," Args.typ --| Scan.lift (Args.$$$ ")")) []
9cb1b484fe96 added @{const} antiquotation;
wenzelm
parents: 25755
diff changeset
   268
    >> (fn ((ctxt, c), Ts) =>
9cb1b484fe96 added @{const} antiquotation;
wenzelm
parents: 25755
diff changeset
   269
      let
9cb1b484fe96 added @{const} antiquotation;
wenzelm
parents: 25755
diff changeset
   270
        val (c, _) = Term.dest_Const (ProofContext.read_const_proper ctxt c);
26268
80aaf4d034be added mk_const functions
haftmann
parents: 26188
diff changeset
   271
      in ML_Syntax.atomic (ML_Syntax.print_term (ProofContext.mk_const ctxt (c, Ts))) end));
26188
9cb1b484fe96 added @{const} antiquotation;
wenzelm
parents: 25755
diff changeset
   272
25142
57c717b9dd59 added @{sort}, @{type_syntax} antiquotations;
wenzelm
parents: 24695
diff changeset
   273
in val _ = () end;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   274
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   275
26416
a66f86ef7bb9 added store_thms etc. (formerly in Thy/thm_database.ML);
wenzelm
parents: 26405
diff changeset
   276
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   277
(** fact references **)
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   278
26346
17debd2fff8e simplified get_thm(s): back to plain name argument;
wenzelm
parents: 26336
diff changeset
   279
fun thm name = ProofContext.get_thm (the_local_context ()) name;
17debd2fff8e simplified get_thm(s): back to plain name argument;
wenzelm
parents: 26336
diff changeset
   280
fun thms name = ProofContext.get_thms (the_local_context ()) name;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   281
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   282
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   283
local
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   284
26336
a0e2b706ce73 renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents: 26268
diff changeset
   285
fun print_interval (Facts.FromTo arg) =
a0e2b706ce73 renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents: 26268
diff changeset
   286
      "Facts.FromTo " ^ ML_Syntax.print_pair ML_Syntax.print_int ML_Syntax.print_int arg
a0e2b706ce73 renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents: 26268
diff changeset
   287
  | print_interval (Facts.From i) = "Facts.From " ^ ML_Syntax.print_int i
a0e2b706ce73 renamed datatype thmref to Facts.ref, tuned interfaces;
wenzelm
parents: 26268
diff changeset
   288
  | print_interval (Facts.Single i) = "Facts.Single " ^ ML_Syntax.print_int i;
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   289
26368
3e74b09ce466 thm_antiq: produce error at runtime, not compile time;
wenzelm
parents: 26361
diff changeset
   290
fun thm_antiq kind get get_name = value_antiq kind
26385
ae7564661e76 ML runtime compilation: pass position, tuned signature;
wenzelm
parents: 26374
diff changeset
   291
  (context -- Scan.lift (Args.position Args.name -- Scan.option Args.thm_sel)
26374
be47e9a83b4f simplified thm_antiq;
wenzelm
parents: 26368
diff changeset
   292
  >> (fn (ctxt, ((name, pos), sel)) =>
26368
3e74b09ce466 thm_antiq: produce error at runtime, not compile time;
wenzelm
parents: 26361
diff changeset
   293
      let
26374
be47e9a83b4f simplified thm_antiq;
wenzelm
parents: 26368
diff changeset
   294
        val _ = get ctxt (Facts.Named ((name, pos), sel));
be47e9a83b4f simplified thm_antiq;
wenzelm
parents: 26368
diff changeset
   295
        val txt =
be47e9a83b4f simplified thm_antiq;
wenzelm
parents: 26368
diff changeset
   296
          "(Facts.Named ((" ^ ML_Syntax.print_string name ^ ", Position.none), " ^
be47e9a83b4f simplified thm_antiq;
wenzelm
parents: 26368
diff changeset
   297
            ML_Syntax.print_option (ML_Syntax.print_list print_interval) sel ^ "))";
be47e9a83b4f simplified thm_antiq;
wenzelm
parents: 26368
diff changeset
   298
      in (name, get_name ^ " (ML_Context.the_local_context ()) " ^ txt) end));
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   299
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   300
in
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   301
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   302
val _ = add_keywords ["(", ")", "-", ","];
26368
3e74b09ce466 thm_antiq: produce error at runtime, not compile time;
wenzelm
parents: 26361
diff changeset
   303
val _ = thm_antiq "thm" ProofContext.get_fact_single "ProofContext.get_fact_single";
3e74b09ce466 thm_antiq: produce error at runtime, not compile time;
wenzelm
parents: 26361
diff changeset
   304
val _ = thm_antiq "thms" ProofContext.get_fact "ProofContext.get_fact";
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   305
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   306
end;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   307
24685
c3d56f41483b tuned @{cpat};
wenzelm
parents: 24581
diff changeset
   308
val _ = proj_value_antiq "cpat" (Scan.lift Args.name >>
c3d56f41483b tuned @{cpat};
wenzelm
parents: 24581
diff changeset
   309
    (fn name => ("cpat",
26432
095e448b95a0 renamed ML_Context.the_context to ML_Context.the_global_context;
wenzelm
parents: 26416
diff changeset
   310
      "Thm.cterm_of (ML_Context.the_global_context ()) (Syntax.read_term \
24685
c3d56f41483b tuned @{cpat};
wenzelm
parents: 24581
diff changeset
   311
      \(ProofContext.set_mode ProofContext.mode_pattern (ML_Context.the_local_context ()))"
c3d56f41483b tuned @{cpat};
wenzelm
parents: 24581
diff changeset
   312
      ^ ML_Syntax.print_string name ^ ")", "")));
24574
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   313
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   314
end;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   315
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   316
structure Basic_ML_Context: BASIC_ML_CONTEXT = ML_Context;
e840872e9c7c moved ML_XXX.ML files to Pure/ML;
wenzelm
parents:
diff changeset
   317
open Basic_ML_Context;