26 val theory_of: state -> theory |
26 val theory_of: state -> theory |
27 val sign_of: state -> Sign.sg |
27 val sign_of: state -> Sign.sg |
28 val proof_of: state -> Proof.state |
28 val proof_of: state -> Proof.state |
29 type transition |
29 type transition |
30 exception TERMINATE |
30 exception TERMINATE |
31 exception BREAK |
31 exception BREAK of state |
32 val empty: transition |
32 val empty: transition |
33 val name: string -> transition -> transition |
33 val name: string -> transition -> transition |
34 val position: Position.T -> transition -> transition |
34 val position: Position.T -> transition -> transition |
35 val interactive: bool -> transition -> transition |
35 val interactive: bool -> transition -> transition |
36 val print: transition -> transition |
36 val print: transition -> transition |
229 |
229 |
230 fun raised name = "exception " ^ name ^ " raised"; |
230 fun raised name = "exception " ^ name ^ " raised"; |
231 fun raised_msg name msg = raised name ^ ": " ^ msg; |
231 fun raised_msg name msg = raised name ^ ": " ^ msg; |
232 |
232 |
233 fun exn_message TERMINATE = "Exit." |
233 fun exn_message TERMINATE = "Exit." |
234 | exn_message BREAK = "Break." |
234 | exn_message (BREAK _) = "Break." |
235 | exn_message Interrupt = "Interrupt (exec)" |
235 | exn_message Interrupt = "Interrupt (exec)." |
236 | exn_message (ERROR_MESSAGE msg) = msg |
236 | exn_message (ERROR_MESSAGE msg) = msg |
237 | exn_message (THEORY (msg, _)) = msg |
237 | exn_message (THEORY (msg, _)) = msg |
238 | exn_message (ProofContext.CONTEXT (msg, _)) = msg |
238 | exn_message (ProofContext.CONTEXT (msg, _)) = msg |
239 | exn_message (Proof.STATE (msg, _)) = msg |
239 | exn_message (Proof.STATE (msg, _)) = msg |
240 | exn_message (ProofHistory.FAIL msg) = msg |
240 | exn_message (ProofHistory.FAIL msg) = msg |
|
241 | exn_message (Attrib.ATTRIB_FAIL info) = fail_message "attribute" info |
|
242 | exn_message (Method.METHOD_FAIL info) = fail_message "method" info |
241 | exn_message (Syntax.AST (msg, _)) = raised_msg "AST" msg |
243 | exn_message (Syntax.AST (msg, _)) = raised_msg "AST" msg |
242 | exn_message (TYPE (msg, _, _)) = raised_msg "TYPE" msg |
244 | exn_message (TYPE (msg, _, _)) = raised_msg "TYPE" msg |
243 | exn_message (TERM (msg, _)) = raised_msg "TERM" msg |
245 | exn_message (TERM (msg, _)) = raised_msg "TERM" msg |
244 | exn_message (THM (msg, _, _)) = raised_msg "THM" msg |
246 | exn_message (THM (msg, _, _)) = raised_msg "THM" msg |
245 | exn_message Library.OPTION = raised "Library.OPTION" |
247 | exn_message Library.OPTION = raised "Library.OPTION" |
246 | exn_message (Library.LIST msg) = raised_msg "Library.LIST" msg |
248 | exn_message (Library.LIST msg) = raised_msg "Library.LIST" msg |
247 | exn_message exn = General.exnMessage exn; |
249 | exn_message exn = General.exnMessage exn |
|
250 and fail_message kind ((name, pos), exn) = |
|
251 "Error in " ^ kind ^ " " ^ name ^ Position.str_of pos ^ ":\n" ^ exn_message exn; |
248 |
252 |
249 fun print_exn None = () |
253 fun print_exn None = () |
250 | print_exn (Some (exn, s)) = error_msg (cat_lines [exn_message exn, s]); |
254 | print_exn (Some (exn, s)) = error_msg (cat_lines [exn_message exn, s]); |
251 |
255 |
252 |
256 |
296 handle |
300 handle |
297 TERMINATE => None |
301 TERMINATE => None |
298 | FAIL exn_info => Some (state, Some exn_info) |
302 | FAIL exn_info => Some (state, Some exn_info) |
299 | PureThy.ROLLBACK (copy_thy, opt_exn) => |
303 | PureThy.ROLLBACK (copy_thy, opt_exn) => |
300 Some (rollback tr copy_thy state, apsome (fn exn => (exn, at_command tr)) opt_exn) |
304 Some (rollback tr copy_thy state, apsome (fn exn => (exn, at_command tr)) opt_exn) |
|
305 | exn as BREAK break_state => Some (break_state, Some (exn, at_command tr)) |
301 | exn => Some (state, Some (exn, at_command tr)); |
306 | exn => Some (state, Some (exn, at_command tr)); |
302 |
307 |
303 |
308 |
304 (* excursion: toplevel -- apply transformers -- toplevel *) |
309 (* excursion: toplevel -- apply transformers -- toplevel *) |
305 |
310 |
344 Some (transform_interrupt_isar Source.get_single src) |
349 Some (transform_interrupt_isar Source.get_single src) |
345 handle Interrupt => None; |
350 handle Interrupt => None; |
346 |
351 |
347 fun raw_loop src = |
352 fun raw_loop src = |
348 (case get_interruptible src of |
353 (case get_interruptible src of |
349 None => (writeln "\nInterrupt (read)"; raw_loop src) |
354 None => (writeln "\nInterrupt (read)."; raw_loop src) |
350 | Some None => () |
355 | Some None => () |
351 | Some (Some (tr, src')) => if >> tr then raw_loop src' else ()); |
356 | Some (Some (tr, src')) => if >> tr then raw_loop src' else ()); |
352 |
357 |
353 |
358 |
354 fun loop src = mask_interrupt raw_loop src; |
359 fun loop src = mask_interrupt raw_loop src; |