src/Pure/Isar/isar_cmd.ML
changeset 26415 1b624d6e9163
parent 26403 8f66999d03a4
child 26425 6561665c5cb1
equal deleted inserted replaced
26414:2780de5a1422 26415:1b624d6e9163
   198     "local\
   198     "local\
   199     \  type T = " ^ typ ^ ";\
   199     \  type T = " ^ typ ^ ";\
   200     \  val oracle: theory -> T -> term = " ^ oracle ^ ";\n\
   200     \  val oracle: theory -> T -> term = " ^ oracle ^ ";\n\
   201     \  val name = " ^ quote name ^ ";\n\
   201     \  val name = " ^ quote name ^ ";\n\
   202     \  exception Arg of T;\n\
   202     \  exception Arg of T;\n\
   203     \  val _ = ML_Context.>> (Theory.add_oracle (name, fn (thy, Arg x) => oracle thy x));\n\
   203     \  val _ = Context.>> (Theory.add_oracle (name, fn (thy, Arg x) => oracle thy x));\n\
   204     \  val thy = ML_Context.the_context ();\n\
   204     \  val thy = ML_Context.the_context ();\n\
   205     \  val invoke_" ^ name ^ " = Thm.invoke_oracle_i thy (Sign.full_name thy name);\n\
   205     \  val invoke_" ^ name ^ " = Thm.invoke_oracle_i thy (Sign.full_name thy name);\n\
   206     \in\n\
   206     \in\n\
   207     \  fun " ^ name ^ " thy x = invoke_" ^ name ^ " (thy, Arg x);\n\
   207     \  fun " ^ name ^ " thy x = invoke_" ^ name ^ " (thy, Arg x);\n\
   208     \end;\n";
   208     \end;\n";
   314 val init_toplevel = Toplevel.imperative (fn () => raise Toplevel.RESTART);
   314 val init_toplevel = Toplevel.imperative (fn () => raise Toplevel.RESTART);
   315 
   315 
   316 val welcome = Toplevel.imperative (writeln o Session.welcome);
   316 val welcome = Toplevel.imperative (writeln o Session.welcome);
   317 
   317 
   318 val exit = Toplevel.keep (fn state =>
   318 val exit = Toplevel.keep (fn state =>
   319  (CRITICAL (fn () => ML_Context.set_context (try Toplevel.generic_theory_of state));
   319  (CRITICAL (fn () => Context.set_thread_data (try Toplevel.generic_theory_of state));
   320   raise Toplevel.TERMINATE));
   320   raise Toplevel.TERMINATE));
   321 
   321 
   322 val quit = Toplevel.imperative quit;
   322 val quit = Toplevel.imperative quit;
   323 
   323 
   324 
   324 
   378 
   378 
   379 
   379 
   380 (* use ML text *)
   380 (* use ML text *)
   381 
   381 
   382 fun use path = Toplevel.keep (fn state =>
   382 fun use path = Toplevel.keep (fn state =>
   383   ML_Context.setmp (try Toplevel.generic_theory_of state) (ThyInfo.load_file false) path);
   383   Context.setmp_thread_data (try Toplevel.generic_theory_of state) (ThyInfo.load_file false) path);
   384 
   384 
   385 (*passes changes of theory context*)
   385 (*passes changes of theory context*)
   386 fun use_mltext_theory (txt, pos) =
   386 fun use_mltext_theory (txt, pos) =
   387   Toplevel.theory' (fn int => Context.theory_map (ML_Context.use_mltext_update int pos txt));
   387   Toplevel.theory' (fn int => Context.theory_map (ML_Context.use_mltext_update int pos txt));
   388 
   388 
   631    if int then OuterSyntax.check_text s NONE else ()));
   631    if int then OuterSyntax.check_text s NONE else ()));
   632 
   632 
   633 local
   633 local
   634 
   634 
   635 fun present _ txt true node = OuterSyntax.check_text txt (SOME node)
   635 fun present _ txt true node = OuterSyntax.check_text txt (SOME node)
   636   | present f (s, _) false node =
   636   | present f (s, _) false node = Context.setmp_thread_data
   637       ML_Context.setmp (try (Toplevel.cases_node I (Context.Proof o Proof.context_of)) node) f s;
   637       (try (Toplevel.cases_node I (Context.Proof o Proof.context_of)) node) f s;
   638 
   638 
   639 fun present_local_theory f (loc, txt) = Toplevel.present_local_theory loc (present f txt);
   639 fun present_local_theory f (loc, txt) = Toplevel.present_local_theory loc (present f txt);
   640 fun present_proof f txt = Toplevel.print o Toplevel.present_proof (present f txt);
   640 fun present_proof f txt = Toplevel.print o Toplevel.present_proof (present f txt);
   641 
   641 
   642 in
   642 in