src/Pure/pure_syn.ML
author wenzelm
Tue Mar 25 13:18:10 2014 +0100 (2014-03-25 ago)
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;
     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         in
    27           gthy
    28           |> ML_Context.exec (fn () => ML_Context.eval_source {SML = false, verbose = true} source)
    29           |> Local_Theory.propagate_ml_env
    30           |> Context.mapping provide (Local_Theory.background_theory provide)
    31         end)));
    32 
    33 end;
    34