equal
deleted
inserted
replaced
53 |
53 |
54 |
54 |
55 (*Read a file specified by thy_file containing theory tname*) |
55 (*Read a file specified by thy_file containing theory tname*) |
56 fun read_thy tname thy_file = |
56 fun read_thy tname thy_file = |
57 let |
57 let |
58 val intext = read_file thy_file; |
58 val intext = File.read thy_file; |
59 val outext = ThySyn.parse tname intext; |
59 val outext = ThySyn.parse tname intext; |
60 in |
60 in |
61 write_file (out_name tname) outext |
61 File.write (out_name tname) outext |
62 end; |
62 end; |
63 |
63 |
64 |
64 |
65 (*Check if a theory was completly loaded *) |
65 (*Check if a theory was completly loaded *) |
66 fun already_loaded thy = |
66 fun already_loaded thy = |
98 |
98 |
99 (*Find a file using a list of paths if no absolute or relative path is |
99 (*Find a file using a list of paths if no absolute or relative path is |
100 specified.*) |
100 specified.*) |
101 fun find_file "" name = |
101 fun find_file "" name = |
102 let fun find_it (cur :: paths) = |
102 let fun find_it (cur :: paths) = |
103 if file_exists (tack_on cur name) then |
103 if File.exists (tack_on cur name) then |
104 (if cur = "." then name else tack_on cur name) |
104 (if cur = "." then name else tack_on cur name) |
105 else |
105 else |
106 find_it paths |
106 find_it paths |
107 | find_it [] = "" |
107 | find_it [] = "" |
108 in find_it (!tmp_loadpath @ !loadpath) end |
108 in find_it (!tmp_loadpath @ !loadpath) end |
109 | find_file path name = |
109 | find_file path name = |
110 if file_exists (tack_on path name) then tack_on path name |
110 if File.exists (tack_on path name) then tack_on path name |
111 else ""; |
111 else ""; |
112 |
112 |
113 |
113 |
114 (*Get absolute pathnames for a new or already loaded theory *) |
114 (*Get absolute pathnames for a new or already loaded theory *) |
115 fun get_filenames path name = |
115 fun get_filenames path name = |
118 val absolute_path = absolute_path (OS.FileSys.getDir ()); |
118 val absolute_path = absolute_path (OS.FileSys.getDir ()); |
119 val thy_file = absolute_path found; |
119 val thy_file = absolute_path found; |
120 val (thy_path, _) = split_filename thy_file; |
120 val (thy_path, _) = split_filename thy_file; |
121 val found = find_file path (name ^ ".ML"); |
121 val found = find_file path (name ^ ".ML"); |
122 val ml_file = if thy_file = "" then absolute_path found |
122 val ml_file = if thy_file = "" then absolute_path found |
123 else if file_exists (tack_on thy_path (name ^ ".ML")) |
123 else if File.exists (tack_on thy_path (name ^ ".ML")) |
124 then tack_on thy_path (name ^ ".ML") |
124 then tack_on thy_path (name ^ ".ML") |
125 else ""; |
125 else ""; |
126 val searched_dirs = if path = "" then (!tmp_loadpath @ !loadpath) |
126 val searched_dirs = if path = "" then (!tmp_loadpath @ !loadpath) |
127 else [path] |
127 else [path] |
128 in if thy_file = "" andalso ml_file = "" then |
128 in if thy_file = "" andalso ml_file = "" then |
249 else |
249 else |
250 (writeln ("Reading \"" ^ name ^ ".thy\""); |
250 (writeln ("Reading \"" ^ name ^ ".thy\""); |
251 |
251 |
252 init_thyinfo (); |
252 init_thyinfo (); |
253 read_thy tname thy_file; |
253 read_thy tname thy_file; |
254 SymbolInput.use (out_name tname); |
254 Use.use (out_name tname); |
255 |
255 |
256 if not (!delete_tmpfiles) then () |
256 if not (!delete_tmpfiles) then () |
257 else OS.FileSys.remove (out_name tname); |
257 else OS.FileSys.remove (out_name tname); |
258 |
258 |
259 thyfile2html tname abs_path |
259 thyfile2html tname abs_path |
262 set_info tname (Some (file_info thy_file)) None; |
262 set_info tname (Some (file_info thy_file)) None; |
263 (*mark thy_file as successfully loaded*) |
263 (*mark thy_file as successfully loaded*) |
264 |
264 |
265 if ml_file = "" then () |
265 if ml_file = "" then () |
266 else (writeln ("Reading \"" ^ name ^ ".ML\""); |
266 else (writeln ("Reading \"" ^ name ^ ".ML\""); |
267 SymbolInput.use ml_file); |
267 Use.use ml_file); |
268 |
268 |
269 (*Store theory again because it could have been redefined*) |
269 (*Store theory again because it could have been redefined*) |
270 use_strings |
270 use_strings |
271 ["val _ = store_theory (" ^ tname ^ ".thy, " ^ quote tname ^ ");"]; |
271 ["val _ = store_theory (" ^ tname ^ ".thy, " ^ quote tname ^ ");"]; |
272 |
272 |
457 OS.FileSys.chDir old_dir |
457 OS.FileSys.chDir old_dir |
458 end; |
458 end; |
459 |
459 |
460 in |
460 in |
461 |
461 |
462 val use_dir = gen_use_dir use; |
462 val use_dir = gen_use_dir Use.use; |
463 val exit_use_dir = gen_use_dir exit_use; |
463 val exit_use_dir = gen_use_dir Use.exit_use; |
464 |
464 |
465 end |
465 end |
466 |
466 |
467 end; |
467 end; |