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;
     1 (*  Title:      Pure/pure_syn.ML
     2     Author:     Makarius
     3 
     4 Minimal outer syntax for bootstrapping Isabelle/Pure.
     5 *)
     6 
     7 structure Pure_Syn: sig end =
     8 struct
     9 
    10 val _ =
    11   Outer_Syntax.command
    12     (("theory", Keyword.tag_theory Keyword.thy_begin), @{here}) "begin theory"
    13     (Thy_Header.args >> (fn header =>
    14       Toplevel.print o
    15         Toplevel.init_theory
    16           (fn () => Thy_Info.toplevel_begin_theory (! ProofGeneral.master_path) header)));
    17 
    18 val _ =
    19   Outer_Syntax.command
    20     (("ML_file", Keyword.tag_ml Keyword.thy_load), @{here}) "ML text from file"
    21     (Resources.parse_files "ML_file" >> (fn files => Toplevel.generic_theory (fn gthy =>
    22         let
    23           val [{src_path, lines, digest, pos}] = files (Context.theory_of gthy);
    24           val provide = Resources.provide (src_path, digest);
    25           val source = {delimited = true, text = cat_lines lines, pos = pos};
    26           val flags = {SML = false, exchange = false, redirect = true, verbose = true};
    27         in
    28           gthy
    29           |> ML_Context.exec (fn () => ML_Context.eval_source flags source)
    30           |> Local_Theory.propagate_ml_env
    31           |> Context.mapping provide (Local_Theory.background_theory provide)
    32         end)));
    33 
    34 end;
    35