src/Pure/Isar/toplevel.ML
changeset 29427 7ba952481e29
parent 29386 d5849935560c
child 29435 a5f84ac14609
equal deleted inserted replaced
29425:6baa02c8263e 29427:7ba952481e29
    94   val error_msg: transition -> exn * string -> unit
    94   val error_msg: transition -> exn * string -> unit
    95   val add_hook: (transition -> state -> state -> unit) -> unit
    95   val add_hook: (transition -> state -> state -> unit) -> unit
    96   val transition: bool -> transition -> state -> (state * (exn * string) option) option
    96   val transition: bool -> transition -> state -> (state * (exn * string) option) option
    97   val commit_exit: Position.T -> transition
    97   val commit_exit: Position.T -> transition
    98   val command: transition -> state -> state
    98   val command: transition -> state -> state
    99   val excursion: (transition * transition list) list -> (transition * state) list * (unit -> unit)
    99   val excursion: (transition * transition list) list -> (transition * state) list lazy
   100 end;
   100 end;
   101 
   101 
   102 structure Toplevel: TOPLEVEL =
   102 structure Toplevel: TOPLEVEL =
   103 struct
   103 struct
   104 
   104 
   744 fun excursion input =
   744 fun excursion input =
   745   let
   745   let
   746     val end_pos = if null input then error "No input" else pos_of (fst (List.last input));
   746     val end_pos = if null input then error "No input" else pos_of (fst (List.last input));
   747 
   747 
   748     val immediate = not (Future.enabled ());
   748     val immediate = not (Future.enabled ());
   749     val (future_results, end_state) = fold_map (proof_result immediate) input toplevel;
   749     val (results, end_state) = fold_map (proof_result immediate) input toplevel;
   750     val _ =
   750     val _ =
   751       (case end_state of
   751       (case end_state of
   752         State (NONE, SOME (Theory (Context.Theory _, _), _)) => ()
   752         State (NONE, SOME (Theory (Context.Theory _, _), _)) =>
       
   753           command (commit_exit end_pos) end_state
   753       | _ => error "Unfinished development at end of input");
   754       | _ => error "Unfinished development at end of input");
   754     val results = maps Lazy.force future_results;
   755   in Lazy.lazy (fn () => maps Lazy.force results) end;
   755   in (results, fn () => ignore (command (commit_exit end_pos) end_state)) end;
   756 
   756 
   757 end;
   757 end;