src/Pure/Isar/toplevel.ML
changeset 21982 fe30893e50f2
parent 21962 279b129498b6
child 21986 76d3d258cfa3
equal deleted inserted replaced
21981:4bb32c127529 21982:fe30893e50f2
    31   val prompt_state_fn: (state -> string) ref
    31   val prompt_state_fn: (state -> string) ref
    32   val print_state_context: state -> unit
    32   val print_state_context: state -> unit
    33   val print_state_default: bool -> state -> unit
    33   val print_state_default: bool -> state -> unit
    34   val print_state_fn: (bool -> state -> unit) ref
    34   val print_state_fn: (bool -> state -> unit) ref
    35   val print_state: bool -> state -> unit
    35   val print_state: bool -> state -> unit
       
    36   val print_exn_fn: ((exn * string) option -> unit) ref
       
    37   val print_exn_str: (exn * string) option -> string option
    36   val pretty_state: bool -> state -> Pretty.T list
    38   val pretty_state: bool -> state -> Pretty.T list
    37   val quiet: bool ref
    39   val quiet: bool ref
    38   val debug: bool ref
    40   val debug: bool ref
    39   val interact: bool ref
    41   val interact: bool ref
    40   val timing: bool ref
    42   val timing: bool ref
   308 and fail_msg detailed kind ((name, pos), exn) =
   310 and fail_msg detailed kind ((name, pos), exn) =
   309   "Error in " ^ kind ^ " " ^ quote name ^ Position.str_of pos ^ ":\n" ^ exn_msg detailed exn;
   311   "Error in " ^ kind ^ " " ^ quote name ^ Position.str_of pos ^ ":\n" ^ exn_msg detailed exn;
   310 
   312 
   311 in
   313 in
   312 
   314 
       
   315 
       
   316 
   313 fun exn_message exn = exn_msg (! debug) exn;
   317 fun exn_message exn = exn_msg (! debug) exn;
   314 
   318 
   315 fun print_exn NONE = ()
   319 fun print_exn_str NONE = NONE
   316   | print_exn (SOME (exn, s)) = Output.error_msg (cat_lines [exn_message exn, s]);
   320   | print_exn_str (SOME (exn, s)) = SOME (cat_lines [exn_message exn, s]);
       
   321 
       
   322 val print_exn_default = Option.app Output.error_msg o print_exn_str
       
   323 
       
   324 val print_exn_fn = ref print_exn_default;
   317 
   325 
   318 end;
   326 end;
   319 
   327 
   320 
   328 
   321 (* controlled execution *)
   329 (* controlled execution *)
   737 fun >> tr =
   745 fun >> tr =
   738   (case apply true tr (get_state ()) of
   746   (case apply true tr (get_state ()) of
   739     NONE => false
   747     NONE => false
   740   | SOME (state', exn_info) =>
   748   | SOME (state', exn_info) =>
   741       (global_state := (state', exn_info);
   749       (global_state := (state', exn_info);
   742         print_exn exn_info;
   750         !print_exn_fn exn_info;
   743         true));
   751         true));
   744 
   752 
   745 fun >>> [] = ()
   753 fun >>> [] = ()
   746   | >>> (tr :: trs) = if >> tr then >>> trs else ();
   754   | >>> (tr :: trs) = if >> tr then >>> trs else ();
   747 
   755