author | wenzelm |
Tue, 17 May 2005 10:19:44 +0200 | |
changeset 15973 | 5fd94d84470f |
parent 15570 | 8d8c70b41bab |
child 15979 | c81578ac2d31 |
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 |
||
23 |
val pure = "Pure"; |
|
24 |
||
25 |
val session = ref ([pure]: string list); |
|
26 |
val session_path = ref ([]: string list); |
|
27 |
val session_finished = ref false; |
|
15531 | 28 |
val rpath = ref (NONE: Url.T option); |
9414 | 29 |
|
30 |
||
31 |
(* access path *) |
|
6346 | 32 |
|
33 |
fun path () = ! session_path; |
|
34 |
||
10937 | 35 |
fun str_of [] = pure |
6346 | 36 |
| str_of elems = space_implode "/" elems; |
37 |
||
11509 | 38 |
fun name () = "Isabelle/" ^ str_of (path ()); |
39 |
fun welcome () = "Welcome to " ^ name () ^ " (" ^ version ^ ")"; |
|
6346 | 40 |
|
41 |
||
9414 | 42 |
(* add_path *) |
43 |
||
44 |
fun add_path reset s = |
|
45 |
let val sess = ! session @ [s] in |
|
46 |
(case Library.duplicates sess of |
|
47 |
[] => (session := sess; session_path := ((if reset then [] else ! session_path) @ [s])) |
|
48 |
| dups => error ("Duplicate session identifiers " ^ commas_quote dups ^ " in " ^ str_of sess)) |
|
49 |
end; |
|
50 |
||
51 |
||
6346 | 52 |
(* init *) |
53 |
||
54 |
fun init reset parent name = |
|
55 |
if not (parent mem_string (! session)) orelse not (! session_finished) then |
|
56 |
error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name) |
|
57 |
else (add_path reset name; session_finished := false); |
|
58 |
||
59 |
||
60 |
(* finish *) |
|
61 |
||
62 |
fun finish () = |
|
6663 | 63 |
(ThyInfo.finish (); |
6346 | 64 |
Present.finish (); |
65 |
session_finished := true); |
|
66 |
||
67 |
||
68 |
(* use_dir *) |
|
69 |
||
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
70 |
(* |
6346 | 71 |
val root_file = ThyLoad.ml_path "ROOT"; |
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
72 |
*) |
6346 | 73 |
|
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
74 |
fun get_rpath rpath_str = |
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
75 |
(if rpath_str = "" then () else |
15973 | 76 |
if is_some (! rpath) then |
7227
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
77 |
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
|
78 |
else |
15531 | 79 |
rpath := SOME (Url.unpack rpath_str); |
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
80 |
(!rpath, rpath_str <> "")); |
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
81 |
|
15433
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
berghofe
parents:
15269
diff
changeset
|
82 |
fun use_dir root_file 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
|
83 |
Library.setmp print_mode (modes @ ! print_mode) |
15433
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
berghofe
parents:
15269
diff
changeset
|
84 |
(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
|
85 |
(init reset parent name; |
11910 | 86 |
Present.init build info doc doc_graph (path ()) name |
15531 | 87 |
(if dump = "" then NONE else SOME (Path.unpack dump)) (get_rpath rpath_str) verbose; |
15269
f856f4f3258f
isatool usedir: ML root file can now be specified (previously hard-coded as ROOT.ML)
webertj
parents:
14981
diff
changeset
|
88 |
File.use (Path.basic root_file); |
15433
a2cbdf16832e
Added flag for hiding proofs in documents to use_dir.
berghofe
parents:
15269
diff
changeset
|
89 |
finish ())))) () |
10571 | 90 |
handle exn => (writeln (Toplevel.exn_message exn); exit 1); |
6346 | 91 |
|
92 |
||
93 |
end; |