src/Pure/pure_syn.ML
author wenzelm
Tue, 25 Mar 2014 13:18:10 +0100
changeset 56275 600f432ab556
parent 56208 06cc31dff138
child 56304 40274e4f5ebf
permissions -rw-r--r--
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;

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

Minimal outer syntax for bootstrapping Isabelle/Pure.
*)

structure Pure_Syn: sig end =
struct

val _ =
  Outer_Syntax.command
    (("theory", Keyword.tag_theory Keyword.thy_begin), @{here}) "begin theory"
    (Thy_Header.args >> (fn header =>
      Toplevel.print o
        Toplevel.init_theory
          (fn () => Thy_Info.toplevel_begin_theory (! ProofGeneral.master_path) header)));

val _ =
  Outer_Syntax.command
    (("ML_file", Keyword.tag_ml Keyword.thy_load), @{here}) "ML text from file"
    (Resources.parse_files "ML_file" >> (fn files => Toplevel.generic_theory (fn gthy =>
        let
          val [{src_path, lines, digest, pos}] = files (Context.theory_of gthy);
          val provide = Resources.provide (src_path, digest);
          val source = {delimited = true, text = cat_lines lines, pos = pos};
        in
          gthy
          |> ML_Context.exec (fn () => ML_Context.eval_source {SML = false, verbose = true} source)
          |> Local_Theory.propagate_ml_env
          |> Context.mapping provide (Local_Theory.background_theory provide)
        end)));

end;