31 val pretty_abstract: state -> Pretty.T |
31 val pretty_abstract: state -> Pretty.T |
32 type transition |
32 type transition |
33 val empty: transition |
33 val empty: transition |
34 val name_of: transition -> string |
34 val name_of: transition -> string |
35 val pos_of: transition -> Position.T |
35 val pos_of: transition -> Position.T |
36 val body_range_of: transition -> Position.range |
|
37 val timing_of: transition -> Time.time |
36 val timing_of: transition -> Time.time |
38 val type_error: transition -> string |
37 val type_error: transition -> string |
39 val name: string -> transition -> transition |
38 val name: string -> transition -> transition |
40 val positions: Position.T -> Position.range -> transition -> transition |
39 val position: Position.T -> transition -> transition |
41 val markers: Input.source list -> transition -> transition |
40 val markers: Input.source list -> transition -> transition |
42 val timing: Time.time -> transition -> transition |
41 val timing: Time.time -> transition -> transition |
43 val init_theory: (unit -> theory) -> transition -> transition |
42 val init_theory: (unit -> theory) -> transition -> transition |
44 val is_init: transition -> bool |
43 val is_init: transition -> bool |
45 val modify_init: (unit -> theory) -> transition -> transition |
44 val modify_init: (unit -> theory) -> transition -> transition |
46 val exit: transition -> transition |
45 val exit: transition -> transition |
47 val keep: (state -> unit) -> transition -> transition |
46 val keep: (state -> unit) -> transition -> transition |
48 val keep': (bool -> state -> unit) -> transition -> transition |
47 val keep': (bool -> state -> unit) -> transition -> transition |
49 val keep_proof: (state -> unit) -> transition -> transition |
48 val keep_proof: (state -> unit) -> transition -> transition |
50 val is_ignored: transition -> bool |
49 val is_ignored: transition -> bool |
51 val ignored: Position.range -> transition |
50 val ignored: Position.T -> transition |
52 val malformed: Position.range -> string -> transition |
51 val malformed: Position.T -> string -> transition |
53 val generic_theory: (generic_theory -> generic_theory) -> transition -> transition |
52 val generic_theory: (generic_theory -> generic_theory) -> transition -> transition |
54 val theory': (bool -> theory -> theory) -> transition -> transition |
53 val theory': (bool -> theory -> theory) -> transition -> transition |
55 val theory: (theory -> theory) -> transition -> transition |
54 val theory: (theory -> theory) -> transition -> transition |
56 val begin_main_target: bool -> (theory -> local_theory) -> transition -> transition |
55 val begin_main_target: bool -> (theory -> local_theory) -> transition -> transition |
57 val end_main_target: transition -> transition |
56 val end_main_target: transition -> transition |
334 |
333 |
335 (* datatype transition *) |
334 (* datatype transition *) |
336 |
335 |
337 datatype transition = Transition of |
336 datatype transition = Transition of |
338 {name: string, (*command name*) |
337 {name: string, (*command name*) |
339 pos: Position.T, (*source position: reference point*) |
338 pos: Position.T, (*source position*) |
340 body_range: Position.range, (*source position: main body*) |
|
341 markers: Input.source list, (*semantic document markers*) |
339 markers: Input.source list, (*semantic document markers*) |
342 timing: Time.time, (*prescient timing information*) |
340 timing: Time.time, (*prescient timing information*) |
343 trans: trans list}; (*primitive transitions (union)*) |
341 trans: trans list}; (*primitive transitions (union)*) |
344 |
342 |
345 fun make_transition (name, pos, body_range, markers, timing, trans) = |
343 fun make_transition (name, pos, markers, timing, trans) = |
346 Transition {name = name, pos = pos, body_range = body_range, markers = markers, |
344 Transition {name = name, pos = pos, markers = markers, timing = timing, trans = trans}; |
347 timing = timing, trans = trans}; |
345 |
348 |
346 fun map_transition f (Transition {name, pos, markers, timing, trans}) = |
349 fun map_transition f (Transition {name, pos, body_range, markers, timing, trans}) = |
347 make_transition (f (name, pos, markers, timing, trans)); |
350 make_transition (f (name, pos, body_range, markers, timing, trans)); |
348 |
351 |
349 val empty = make_transition ("", Position.none, [], Time.zeroTime, []); |
352 val empty = make_transition ("", Position.none, Position.no_range, [], Time.zeroTime, []); |
|
353 |
350 |
354 |
351 |
355 (* diagnostics *) |
352 (* diagnostics *) |
356 |
353 |
357 fun name_of (Transition {name, ...}) = name; |
354 fun name_of (Transition {name, ...}) = name; |
358 fun pos_of (Transition {pos, ...}) = pos; |
355 fun pos_of (Transition {pos, ...}) = pos; |
359 fun body_range_of (Transition {body_range, ...}) = body_range; |
|
360 fun timing_of (Transition {timing, ...}) = timing; |
356 fun timing_of (Transition {timing, ...}) = timing; |
361 |
357 |
362 fun command_msg msg tr = |
358 fun command_msg msg tr = |
363 msg ^ "command " ^ quote (Markup.markup Markup.keyword1 (name_of tr)) ^ |
359 msg ^ "command " ^ quote (Markup.markup Markup.keyword1 (name_of tr)) ^ |
364 Position.here (pos_of tr); |
360 Position.here (pos_of tr); |
367 fun type_error tr = command_msg "Bad context for " tr; |
363 fun type_error tr = command_msg "Bad context for " tr; |
368 |
364 |
369 |
365 |
370 (* modify transitions *) |
366 (* modify transitions *) |
371 |
367 |
372 fun name name = map_transition (fn (_, pos, body_range, markers, timing, trans) => |
368 fun name name = map_transition (fn (_, pos, markers, timing, trans) => |
373 (name, pos, body_range, markers, timing, trans)); |
369 (name, pos, markers, timing, trans)); |
374 |
370 |
375 fun positions pos body_range = map_transition (fn (name, _, _, markers, timing, trans) => |
371 fun position pos = map_transition (fn (name, _, markers, timing, trans) => |
376 (name, pos, body_range, markers, timing, trans)); |
372 (name, pos, markers, timing, trans)); |
377 |
373 |
378 fun markers markers = map_transition (fn (name, pos, body_range, _, timing, trans) => |
374 fun markers markers = map_transition (fn (name, pos, _, timing, trans) => |
379 (name, pos, body_range, markers, timing, trans)); |
375 (name, pos, markers, timing, trans)); |
380 |
376 |
381 fun timing timing = map_transition (fn (name, pos, body_range, markers, _, trans) => |
377 fun timing timing = map_transition (fn (name, pos, markers, _, trans) => |
382 (name, pos, body_range, markers, timing, trans)); |
378 (name, pos, markers, timing, trans)); |
383 |
379 |
384 fun add_trans tr = map_transition (fn (name, pos, body_range, markers, timing, trans) => |
380 fun add_trans tr = map_transition (fn (name, pos, markers, timing, trans) => |
385 (name, pos, body_range, markers, timing, tr :: trans)); |
381 (name, pos, markers, timing, tr :: trans)); |
386 |
382 |
387 val reset_trans = map_transition (fn (name, pos, body_range, markers, timing, _) => |
383 val reset_trans = map_transition (fn (name, pos, markers, timing, _) => |
388 (name, pos, body_range, markers, timing, [])); |
384 (name, pos, markers, timing, [])); |
389 |
385 |
390 |
386 |
391 (* basic transitions *) |
387 (* basic transitions *) |
392 |
388 |
393 fun init_theory f = add_trans (Init f); |
389 fun init_theory f = add_trans (Init f); |
412 else if is_skipped_proof st then () |
408 else if is_skipped_proof st then () |
413 else warning "No proof state"); |
409 else warning "No proof state"); |
414 |
410 |
415 fun is_ignored tr = name_of tr = "<ignored>"; |
411 fun is_ignored tr = name_of tr = "<ignored>"; |
416 |
412 |
417 fun ignored range = |
413 fun ignored pos = |
418 empty |> name "<ignored>" |> positions (#1 range) range |> keep (fn _ => ()); |
414 empty |> name "<ignored>" |> position pos |> keep (fn _ => ()); |
419 |
415 |
420 fun malformed range msg = |
416 fun malformed pos msg = |
421 empty |> name "<malformed>" |> positions (#1 range) range |> keep (fn _ => error msg); |
417 empty |> name "<malformed>" |> position pos |> keep (fn _ => error msg); |
422 |
418 |
423 |
419 |
424 (* theory transitions *) |
420 (* theory transitions *) |
425 |
421 |
426 fun generic_theory f = transaction (fn _ => |
422 fun generic_theory f = transaction (fn _ => |
596 |
592 |
597 (** toplevel transactions **) |
593 (** toplevel transactions **) |
598 |
594 |
599 (* runtime position *) |
595 (* runtime position *) |
600 |
596 |
601 fun exec_id id (tr as Transition {pos, body_range, ...}) = |
597 fun exec_id id (tr as Transition {pos, ...}) = |
602 let val put_id = Position.put_id (Document_ID.print id) |
598 let val put_id = Position.put_id (Document_ID.print id) |
603 in positions (put_id pos) (apply2 put_id body_range) tr end; |
599 in position (put_id pos) tr end; |
604 |
600 |
605 fun setmp_thread_position (Transition {pos, ...}) f x = |
601 fun setmp_thread_position (Transition {pos, ...}) f x = |
606 Position.setmp_thread_data pos f x; |
602 Position.setmp_thread_data pos f x; |
607 |
603 |
608 |
604 |