src/Pure/pure_syn.ML
author wenzelm
Sat Apr 19 17:23:05 2014 +0200 (2014-04-19)
changeset 56618 874bdedb2313
parent 56304 40274e4f5ebf
child 56895 f058120aaad4
permissions -rw-r--r--
added command 'SML_export' and 'SML_import' for exchange of toplevel bindings;
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@56204
    12
    (("theory", Keyword.tag_theory Keyword.thy_begin), @{here}) "begin theory"
wenzelm@48879
    13
    (Thy_Header.args >> (fn header =>
wenzelm@48879
    14
      Toplevel.print o
wenzelm@48879
    15
        Toplevel.init_theory
wenzelm@54450
    16
          (fn () => Thy_Info.toplevel_begin_theory (! ProofGeneral.master_path) header)));
wenzelm@48879
    17
wenzelm@48879
    18
val _ =
wenzelm@48879
    19
  Outer_Syntax.command
wenzelm@56204
    20
    (("ML_file", Keyword.tag_ml Keyword.thy_load), @{here}) "ML text from file"
wenzelm@56208
    21
    (Resources.parse_files "ML_file" >> (fn files => Toplevel.generic_theory (fn gthy =>
wenzelm@48879
    22
        let
wenzelm@55788
    23
          val [{src_path, lines, digest, pos}] = files (Context.theory_of gthy);
wenzelm@56208
    24
          val provide = Resources.provide (src_path, digest);
wenzelm@55828
    25
          val source = {delimited = true, text = cat_lines lines, pos = pos};
wenzelm@56618
    26
          val flags = {SML = false, exchange = false, redirect = true, verbose = true};
wenzelm@48879
    27
        in
wenzelm@48879
    28
          gthy
wenzelm@56304
    29
          |> ML_Context.exec (fn () => ML_Context.eval_source flags source)
wenzelm@48879
    30
          |> Local_Theory.propagate_ml_env
wenzelm@48879
    31
          |> Context.mapping provide (Local_Theory.background_theory provide)
wenzelm@48879
    32
        end)));
wenzelm@48879
    33
wenzelm@48879
    34
end;
wenzelm@48879
    35