src/Pure/pure_syn.ML
author wenzelm
Sun, 26 Aug 2012 21:46:50 +0200
changeset 48927 ef462b5558eb
parent 48905 04576657cf94
child 52455 9a8f4fdac3cf
permissions -rw-r--r--
theory def/ref position reports, which enable hyperlinks etc.; more official header command parsing;

(*  Title:      Pure/pure_syn.ML
    Author:     Makarius

Minimal outer syntax for bootstrapping Pure.
*)

structure Pure_Syn: sig end =
struct

val _ =
  Outer_Syntax.command
    (("theory", Keyword.tag_theory Keyword.thy_begin), Position.none) "begin theory context"
    (Thy_Header.args >> (fn header =>
      Toplevel.print o
        Toplevel.init_theory
          (fn () => Thy_Info.toplevel_begin_theory (Thy_Load.get_master_path ()) header)));

val _ =
  Outer_Syntax.command
    (("ML_file", Keyword.tag_ml Keyword.thy_load), Position.none) "ML text from file"
    (Thy_Load.parse_files "ML_file" >> (fn files => Toplevel.generic_theory (fn gthy =>
        let
          val [{src_path, text, pos}] = files (Context.theory_of gthy);
          val provide = Thy_Load.provide (src_path, SHA1.digest text);
        in
          gthy
          |> ML_Context.exec (fn () => ML_Context.eval_text true pos text)
          |> Local_Theory.propagate_ml_env
          |> Context.mapping provide (Local_Theory.background_theory provide)
        end)));

end;