| author | hoelzl | 
| Thu, 22 Sep 2011 10:02:16 -0400 | |
| changeset 45041 | 0523a6be8ade | 
| parent 44270 | 3eaad39e520c | 
| child 46961 | 5c6955f487e5 | 
| permissions | -rw-r--r-- | 
| 30175 | 1 | (* Title: Pure/System/isar.ML | 
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 2 | Author: Makarius | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 3 | |
| 37306 
2bde06a2a706
discontinued obsolete Isar.context() -- long superseded by @{context};
 wenzelm parents: 
37239diff
changeset | 4 | Global state of the raw Isar read-eval-print loop. | 
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 5 | *) | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 6 | |
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 7 | signature ISAR = | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 8 | sig | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 9 | val init: unit -> unit | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 10 | val exn: unit -> (exn * string) option | 
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 11 | val state: unit -> Toplevel.state | 
| 33289 | 12 |   val goal: unit -> {context: Proof.context, facts: thm list, goal: thm}
 | 
| 27533 | 13 | val print: unit -> unit | 
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 14 | val >> : Toplevel.transition -> bool | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 15 | val >>> : Toplevel.transition list -> unit | 
| 27529 | 16 | val linear_undo: int -> unit | 
| 27524 | 17 | val undo: int -> unit | 
| 27530 | 18 | val kill: unit -> unit | 
| 19 | val kill_proof: unit -> unit | |
| 43684 | 20 | val crashes: exn list Synchronized.var | 
| 38253 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 21 | val toplevel_loop: TextIO.instream -> | 
| 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 22 |     {init: bool, welcome: bool, sync: bool, secure: bool} -> unit
 | 
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 23 | val loop: unit -> unit | 
| 26606 
379596d12f25
replaced Isar loop variants by generic toplevel_loop;
 wenzelm parents: 
26605diff
changeset | 24 | val main: unit -> unit | 
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 25 | end; | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 26 | |
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 27 | structure Isar: ISAR = | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 28 | struct | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 29 | |
| 27432 | 30 | |
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 31 | (** TTY model -- SINGLE-THREADED! **) | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 32 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 33 | (* the global state *) | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 34 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 35 | type history = (Toplevel.state * Toplevel.transition) list; | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 36 | (*previous state, state transition -- regular commands only*) | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 37 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 38 | local | 
| 32738 | 39 | val global_history = Unsynchronized.ref ([]: history); | 
| 40 | val global_state = Unsynchronized.ref Toplevel.toplevel; | |
| 41 | val global_exn = Unsynchronized.ref (NONE: (exn * string) option); | |
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 42 | in | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 43 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 44 | fun edit_history count f = NAMED_CRITICAL "Isar" (fn () => | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 45 | let | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 46 | fun edit 0 (st, hist) = (global_history := hist; global_state := st; global_exn := NONE) | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 47 | | edit n (st, hist) = edit (n - 1) (f st hist); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 48 | in edit count (! global_state, ! global_history) end); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 49 | |
| 33223 | 50 | fun state () = ! global_state; | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 51 | |
| 33223 | 52 | fun exn () = ! global_exn; | 
| 53 | fun set_exn exn = global_exn := exn; | |
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 54 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 55 | end; | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 56 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 57 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 58 | fun init () = edit_history 1 (K (K (Toplevel.toplevel, []))); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 59 | |
| 33289 | 60 | fun goal () = Proof.goal (Toplevel.proof_of (state ())) | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 61 | handle Toplevel.UNDEF => error "No goal present"; | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 62 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 63 | fun print () = Toplevel.print_state false (state ()); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 64 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 65 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 66 | (* history navigation *) | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 67 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 68 | local | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 69 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 70 | fun find_and_undo _ [] = error "Undo history exhausted" | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 71 | | find_and_undo which ((prev, tr) :: hist) = | 
| 38138 
dc65ed8bbb43
find_and_undo: no need to kill_thy again -- Thy_Info.toplevel_begin_theory does that initially (cf. 3ceccd415145);
 wenzelm parents: 
37306diff
changeset | 72 | if which (Toplevel.name_of tr) then (prev, hist) else find_and_undo which hist; | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 73 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 74 | in | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 75 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 76 | fun linear_undo n = edit_history n (K (find_and_undo (K true))); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 77 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 78 | fun undo n = edit_history n (fn st => fn hist => | 
| 36950 | 79 | find_and_undo (if Toplevel.is_proof st then K true else Keyword.is_theory) hist); | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 80 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 81 | fun kill () = edit_history 1 (fn st => fn hist => | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 82 | find_and_undo | 
| 36950 | 83 | (if Toplevel.is_proof st then Keyword.is_theory else Keyword.is_theory_begin) hist); | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 84 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 85 | fun kill_proof () = edit_history 1 (fn st => fn hist => | 
| 36950 | 86 | if Toplevel.is_proof st then find_and_undo Keyword.is_theory hist | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 87 | else raise Toplevel.UNDEF); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 88 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 89 | end; | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 90 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 91 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 92 | (* interactive state transformations *) | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 93 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 94 | fun op >> tr = | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 95 | (case Toplevel.transition true tr (state ()) of | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 96 | NONE => false | 
| 38876 
ec7045139e70
Toplevel.run_command: more careful treatment of interrupts stemming from nested multi-exceptions etc.;
 wenzelm parents: 
38799diff
changeset | 97 | | SOME (_, SOME exn_info) => | 
| 
ec7045139e70
Toplevel.run_command: more careful treatment of interrupts stemming from nested multi-exceptions etc.;
 wenzelm parents: 
38799diff
changeset | 98 | (set_exn (SOME exn_info); | 
| 44270 
3eaad39e520c
more careful treatment of exception serial numbers, with propagation to message channel;
 wenzelm parents: 
43684diff
changeset | 99 | Toplevel.error_msg tr (serial (), ML_Compiler.exn_message (Runtime.EXCURSION_FAIL exn_info)); | 
| 38876 
ec7045139e70
Toplevel.run_command: more careful treatment of interrupts stemming from nested multi-exceptions etc.;
 wenzelm parents: 
38799diff
changeset | 100 | true) | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 101 | | SOME (st', NONE) => | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 102 | let | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 103 | val name = Toplevel.name_of tr; | 
| 36950 | 104 | val _ = if Keyword.is_theory_begin name then init () else (); | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 105 | val _ = | 
| 36950 | 106 | if Keyword.is_regular name | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 107 | then edit_history 1 (fn st => fn hist => (st', (st, tr) :: hist)) else (); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 108 | in true end); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 109 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 110 | fun op >>> [] = () | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 111 | | op >>> (tr :: trs) = if op >> tr then op >>> trs else (); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 112 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 113 | |
| 39234 
d76a2fd129b5
main command loops are supposed to be uninterruptible -- no special treatment here;
 wenzelm parents: 
38876diff
changeset | 114 | (* toplevel loop -- uninterruptible *) | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 115 | |
| 43684 | 116 | val crashes = Synchronized.var "Isar.crashes" ([]: exn list); | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 117 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 118 | local | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 119 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 120 | fun raw_loop secure src = | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 121 | let | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 122 | fun check_secure () = | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 123 | (if secure then warning "Secure loop -- cannot exit to ML" else (); secure); | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 124 | in | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 125 | (case Source.get_single (Source.set_prompt Source.default_prompt src) of | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 126 | NONE => if secure then quit () else () | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 127 | | SOME (tr, src') => if op >> tr orelse check_secure () then raw_loop secure src' else ()) | 
| 29370 | 128 | handle exn => | 
| 31478 | 129 | (Output.error_msg (ML_Compiler.exn_message exn) | 
| 29370 | 130 | handle crash => | 
| 43684 | 131 | (Synchronized.change crashes (cons crash); | 
| 29370 | 132 | warning "Recovering from Isar toplevel crash -- see also Isar.crashes"); | 
| 38272 | 133 | raw_loop secure src) | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 134 | end; | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 135 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 136 | in | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 137 | |
| 38253 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 138 | fun toplevel_loop in_stream {init = do_init, welcome, sync, secure} =
 | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 139 | (Context.set_thread_data NONE; | 
| 32486 | 140 | if do_init then init () else (); | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 141 | if welcome then writeln (Session.welcome ()) else (); | 
| 38253 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 142 | uninterruptible (fn _ => fn () => raw_loop secure (Outer_Syntax.isar in_stream sync)) ()); | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 143 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 144 | end; | 
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 145 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 146 | fun loop () = | 
| 38253 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 147 | toplevel_loop TextIO.stdIn | 
| 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 148 |     {init = false, welcome = false, sync = false, secure = Secure.is_secure ()};
 | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 149 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 150 | fun main () = | 
| 38253 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 151 | toplevel_loop TextIO.stdIn | 
| 
3d4e521014f7
Isabelle_Process: separate input fifo for commands (still using the old tty protocol);
 wenzelm parents: 
38138diff
changeset | 152 |     {init = true, welcome = true, sync = false, secure = Secure.is_secure ()};
 | 
| 29348 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 153 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 154 | |
| 
28b0652aabd8
simplified tty model -- back to plain list history, which is independent of editor model;
 wenzelm parents: 
29314diff
changeset | 155 | |
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 156 | (** command syntax **) | 
| 28300 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 157 | |
| 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 158 | local | 
| 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 159 | |
| 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 160 | val op >> = Scan.>>; | 
| 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 161 | |
| 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 162 | in | 
| 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 163 | |
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 164 | (* global history *) | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 165 | |
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 166 | val _ = | 
| 36953 
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 167 | Outer_Syntax.improper_command "init_toplevel" "init toplevel point-of-interest" Keyword.control | 
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 168 | (Scan.succeed (Toplevel.no_timing o Toplevel.imperative init)); | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 169 | |
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 170 | val _ = | 
| 36953 
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 171 | Outer_Syntax.improper_command "linear_undo" "undo commands" Keyword.control | 
| 36950 | 172 | (Scan.optional Parse.nat 1 >> | 
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 173 | (fn n => Toplevel.no_timing o Toplevel.imperative (fn () => linear_undo n))); | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 174 | |
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 175 | val _ = | 
| 36953 
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 176 | Outer_Syntax.improper_command "undo" "undo commands (skipping closed proofs)" Keyword.control | 
| 36950 | 177 | (Scan.optional Parse.nat 1 >> | 
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 178 | (fn n => Toplevel.no_timing o Toplevel.imperative (fn () => undo n))); | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 179 | |
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 180 | val _ = | 
| 36953 
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 181 | Outer_Syntax.improper_command "undos_proof" "undo commands (skipping closed proofs)" | 
| 36950 | 182 | Keyword.control | 
| 183 | (Scan.optional Parse.nat 1 >> (fn n => Toplevel.no_timing o | |
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 184 | Toplevel.keep (fn state => | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 185 | if Toplevel.is_proof state then (undo n; print ()) else raise Toplevel.UNDEF))); | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 186 | |
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 187 | val _ = | 
| 36953 
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 188 | Outer_Syntax.improper_command "cannot_undo" "partial undo -- Proof General legacy" | 
| 36950 | 189 | Keyword.control | 
| 190 | (Parse.name >> | |
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 191 | (fn "end" => Toplevel.no_timing o Toplevel.imperative (fn () => undo 1) | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 192 |         | txt => Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt))));
 | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 193 | |
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 194 | val _ = | 
| 36953 
2af1ad9aa1a3
renamed structure OuterSyntax to Outer_Syntax, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 195 | Outer_Syntax.improper_command "kill" "kill partial proof or theory development" Keyword.control | 
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 196 | (Scan.succeed (Toplevel.no_timing o Toplevel.imperative kill)); | 
| 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29417diff
changeset | 197 | |
| 26605 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 198 | end; | 
| 
24e60e823d22
The global Isabelle/Isar state and main read-eval-print loop.
 wenzelm parents: diff
changeset | 199 | |
| 28300 
111fc1879250
moved Isar editor commands from isar_syn.ML to isar.ML;
 wenzelm parents: 
27662diff
changeset | 200 | end; |