src/Pure/pure_syn.ML
author wenzelm
Mon Mar 10 15:04:01 2014 +0100 (2014-03-10)
changeset 56026 893fe12639bc
parent 55828 42ac3cfb89f6
child 56204 f70e69208a8c
permissions -rw-r--r--
tuned signature -- prefer Name_Space.get with its builtin error;
wenzelm@48879
     1
(*  Title:      Pure/pure_syn.ML
wenzelm@48879
     2
    Author:     Makarius
wenzelm@48879
     3
wenzelm@52546
     4
Minimal outer syntax for bootstrapping Isabelle/Pure.
wenzelm@48879
     5
*)
wenzelm@48879
     6
wenzelm@48879
     7
structure Pure_Syn: sig end =
wenzelm@48879
     8
struct
wenzelm@48879
     9
wenzelm@48879
    10
val _ =
wenzelm@48879
    11
  Outer_Syntax.command
wenzelm@52455
    12
    (("theory", Keyword.tag_theory Keyword.thy_begin), Position.file "pure_syn.ML")
wenzelm@52455
    13
    "begin theory context"
wenzelm@48879
    14
    (Thy_Header.args >> (fn header =>
wenzelm@48879
    15
      Toplevel.print o
wenzelm@48879
    16
        Toplevel.init_theory
wenzelm@54450
    17
          (fn () => Thy_Info.toplevel_begin_theory (! ProofGeneral.master_path) header)));
wenzelm@48879
    18
wenzelm@48879
    19
val _ =
wenzelm@48879
    20
  Outer_Syntax.command
wenzelm@52455
    21
    (("ML_file", Keyword.tag_ml Keyword.thy_load), Position.file "pure_syn.ML")
wenzelm@52455
    22
    "ML text from file"
wenzelm@48905
    23
    (Thy_Load.parse_files "ML_file" >> (fn files => Toplevel.generic_theory (fn gthy =>
wenzelm@48879
    24
        let
wenzelm@55788
    25
          val [{src_path, lines, digest, pos}] = files (Context.theory_of gthy);
wenzelm@55788
    26
          val provide = Thy_Load.provide (src_path, digest);
wenzelm@55828
    27
          val source = {delimited = true, text = cat_lines lines, pos = pos};
wenzelm@48879
    28
        in
wenzelm@48879
    29
          gthy
wenzelm@55828
    30
          |> ML_Context.exec (fn () => ML_Context.eval_source true source)
wenzelm@48879
    31
          |> Local_Theory.propagate_ml_env
wenzelm@48879
    32
          |> Context.mapping provide (Local_Theory.background_theory provide)
wenzelm@48879
    33
        end)));
wenzelm@48879
    34
wenzelm@48879
    35
end;
wenzelm@48879
    36