src/Pure/Isar/toplevel.ML
changeset 37977 3ceccd415145
parent 37953 ddc3b72f9a42
child 38236 d8c7be27e01d
equal deleted inserted replaced
37976:ce2ea240895c 37977:3ceccd415145
    44   val name: string -> transition -> transition
    44   val name: string -> transition -> transition
    45   val position: Position.T -> transition -> transition
    45   val position: Position.T -> transition -> transition
    46   val interactive: bool -> transition -> transition
    46   val interactive: bool -> transition -> transition
    47   val print: transition -> transition
    47   val print: transition -> transition
    48   val no_timing: transition -> transition
    48   val no_timing: transition -> transition
    49   val init_theory: string -> (bool -> theory) -> transition -> transition
    49   val init_theory: string -> (unit -> theory) -> transition -> transition
       
    50   val modify_init: (unit -> theory) -> transition -> transition
    50   val exit: transition -> transition
    51   val exit: transition -> transition
    51   val keep: (state -> unit) -> transition -> transition
    52   val keep: (state -> unit) -> transition -> transition
    52   val keep': (bool -> state -> unit) -> transition -> transition
    53   val keep': (bool -> state -> unit) -> transition -> transition
    53   val imperative: (unit -> unit) -> transition -> transition
    54   val imperative: (unit -> unit) -> transition -> transition
    54   val ignored: Position.T -> transition
    55   val ignored: Position.T -> transition
   293 
   294 
   294 
   295 
   295 (* primitive transitions *)
   296 (* primitive transitions *)
   296 
   297 
   297 datatype trans =
   298 datatype trans =
   298   Init of string * (bool -> theory) |    (*theory name, init*)
   299   Init of string * (unit -> theory) |    (*theory name, init*)
   299   Exit |                                 (*formal exit of theory*)
   300   Exit |                                 (*formal exit of theory*)
   300   Keep of bool -> state -> unit |        (*peek at state*)
   301   Keep of bool -> state -> unit |        (*peek at state*)
   301   Transaction of (bool -> node -> node) * (state -> unit);  (*node transaction and presentation*)
   302   Transaction of (bool -> node -> node) * (state -> unit);  (*node transaction and presentation*)
   302 
   303 
   303 local
   304 local
   304 
   305 
   305 fun apply_tr int (Init (_, f)) (State (NONE, _)) =
   306 fun apply_tr _ (Init (_, f)) (State (NONE, _)) =
   306       State (SOME (Theory (Context.Theory
   307       State (SOME (Theory (Context.Theory
   307           (Theory.checkpoint (Runtime.controlled_execution f int)), NONE)), NONE)
   308           (Theory.checkpoint (Runtime.controlled_execution f ())), NONE)), NONE)
   308   | apply_tr _ Exit (State (prev as SOME (Theory (Context.Theory _, _)), _)) =
   309   | apply_tr _ Exit (State (prev as SOME (Theory (Context.Theory _, _)), _)) =
   309       State (NONE, prev)
   310       State (NONE, prev)
   310   | apply_tr int (Keep f) state =
   311   | apply_tr int (Keep f) state =
   311       Runtime.controlled_execution (fn x => tap (f int) x) state
   312       Runtime.controlled_execution (fn x => tap (f int) x) state
   312   | apply_tr int (Transaction (f, g)) (State (SOME state, _)) =
   313   | apply_tr int (Transaction (f, g)) (State (SOME state, _)) =
   392 
   393 
   393 
   394 
   394 (* basic transitions *)
   395 (* basic transitions *)
   395 
   396 
   396 fun init_theory name f = add_trans (Init (name, f));
   397 fun init_theory name f = add_trans (Init (name, f));
       
   398 
       
   399 fun modify_init f tr =
       
   400   (case init_of tr of
       
   401     SOME name => init_theory name f (reset_trans tr)
       
   402   | NONE => tr);
       
   403 
   397 val exit = add_trans Exit;
   404 val exit = add_trans Exit;
   398 val keep' = add_trans o Keep;
   405 val keep' = add_trans o Keep;
   399 
   406 
   400 fun present_transaction f g = add_trans (Transaction (f, g));
   407 fun present_transaction f g = add_trans (Transaction (f, g));
   401 fun transaction f = present_transaction f (K ());
   408 fun transaction f = present_transaction f (K ());