| author | nipkow |
| Tue, 09 Aug 2005 11:44:38 +0200 | |
| changeset 17040 | 6682c93b7d9f |
| parent 16728 | c4c9d5df26ba |
| child 17074 | f6284547701b |
| permissions | -rw-r--r-- |
| 6346 | 1 |
(* Title: Pure/Isar/session.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
5 |
Session management -- maintain state of logic images. |
|
6 |
*) |
|
7 |
||
8 |
signature SESSION = |
|
9 |
sig |
|
| 11509 | 10 |
val name: unit -> string |
| 6346 | 11 |
val welcome: unit -> string |
|
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
12 |
val use_dir: string -> bool -> string list -> bool -> bool -> string -> bool -> string |
|
15433
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
berghofe
parents:
15269
diff
changeset
|
13 |
-> string -> string -> string -> int -> bool -> bool -> unit |
| 6346 | 14 |
val finish: unit -> unit |
15 |
end; |
|
16 |
||
17 |
structure Session: SESSION = |
|
18 |
struct |
|
19 |
||
20 |
||
21 |
(* session state *) |
|
22 |
||
| 16451 | 23 |
val session = ref ([Context.PureN]: string list); |
| 6346 | 24 |
val session_path = ref ([]: string list); |
25 |
val session_finished = ref false; |
|
| 15979 | 26 |
val remote_path = ref (NONE: Url.T option); |
| 9414 | 27 |
|
28 |
||
29 |
(* access path *) |
|
| 6346 | 30 |
|
31 |
fun path () = ! session_path; |
|
32 |
||
| 16451 | 33 |
fun str_of [] = Context.PureN |
| 6346 | 34 |
| str_of elems = space_implode "/" elems; |
35 |
||
| 11509 | 36 |
fun name () = "Isabelle/" ^ str_of (path ()); |
37 |
fun welcome () = "Welcome to " ^ name () ^ " (" ^ version ^ ")";
|
|
| 6346 | 38 |
|
39 |
||
| 9414 | 40 |
(* add_path *) |
41 |
||
42 |
fun add_path reset s = |
|
43 |
let val sess = ! session @ [s] in |
|
44 |
(case Library.duplicates sess of |
|
45 |
[] => (session := sess; session_path := ((if reset then [] else ! session_path) @ [s])) |
|
46 |
| dups => error ("Duplicate session identifiers " ^ commas_quote dups ^ " in " ^ str_of sess))
|
|
47 |
end; |
|
48 |
||
49 |
||
| 6346 | 50 |
(* init *) |
51 |
||
52 |
fun init reset parent name = |
|
53 |
if not (parent mem_string (! session)) orelse not (! session_finished) then |
|
54 |
error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name)
|
|
55 |
else (add_path reset name; session_finished := false); |
|
56 |
||
57 |
||
58 |
(* finish *) |
|
59 |
||
60 |
fun finish () = |
|
| 16728 | 61 |
(Output.accumulated_time (); |
62 |
ThyInfo.finish (); |
|
| 6346 | 63 |
Present.finish (); |
64 |
session_finished := true); |
|
65 |
||
66 |
||
67 |
(* use_dir *) |
|
68 |
||
|
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
69 |
fun get_rpath rpath_str = |
|
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
70 |
(if rpath_str = "" then () else |
| 15979 | 71 |
if is_some (! remote_path) then |
|
7227
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
72 |
error "Path for remote theory browsing information may only be set once" |
|
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
73 |
else |
| 15979 | 74 |
remote_path := SOME (Url.unpack rpath_str); |
75 |
(! remote_path, rpath_str <> "")); |
|
|
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
76 |
|
| 15979 | 77 |
fun use_dir root build modes reset info doc doc_graph parent name dump rpath_str level verbose hide = |
|
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11527
diff
changeset
|
78 |
Library.setmp print_mode (modes @ ! print_mode) |
|
15433
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
berghofe
parents:
15269
diff
changeset
|
79 |
(Library.setmp Proofterm.proofs level (Library.setmp IsarOutput.hide_commands hide (fn () => |
|
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11527
diff
changeset
|
80 |
(init reset parent name; |
| 11910 | 81 |
Present.init build info doc doc_graph (path ()) name |
| 15531 | 82 |
(if dump = "" then NONE else SOME (Path.unpack dump)) (get_rpath rpath_str) verbose; |
| 16715 | 83 |
ThyInfo.time_use root; |
|
15433
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
berghofe
parents:
15269
diff
changeset
|
84 |
finish ())))) () |
| 10571 | 85 |
handle exn => (writeln (Toplevel.exn_message exn); exit 1); |
| 6346 | 86 |
|
87 |
||
88 |
end; |