400 end; |
400 end; |
401 |
401 |
402 |
402 |
403 (* prepare theory context *) |
403 (* prepare theory context *) |
404 |
404 |
405 val thy_name = Path.pack o #1 o Path.split_ext o Path.base o Path.unpack; |
405 val thy_name = Path.implode o #1 o Path.split_ext o Path.base o Path.explode; |
406 |
406 |
407 (* FIXME general treatment of tracing*) |
407 (* FIXME general treatment of tracing*) |
408 val update_thy_only = setmp MetaSimplifier.trace_simp false ThyInfo.update_thy_only; |
408 val update_thy_only = setmp MetaSimplifier.trace_simp false ThyInfo.update_thy_only; |
409 |
409 |
410 fun dynamic_context () = |
410 fun dynamic_context () = |
411 (case Context.get_context () of |
411 (case Context.get_context () of |
412 SOME thy => " Using current (dynamic!) one: " ^ quote (Context.theory_name thy) |
412 SOME thy => " Using current (dynamic!) one: " ^ quote (Context.theory_name thy) |
413 | NONE => ""); |
413 | NONE => ""); |
414 |
414 |
415 fun try_update_thy_only file = |
415 fun try_update_thy_only file = |
416 ThyLoad.cond_add_path (Path.dir (Path.unpack file)) (fn () => |
416 ThyLoad.cond_add_path (Path.dir (Path.explode file)) (fn () => |
417 let val name = thy_name file in |
417 let val name = thy_name file in |
418 if is_some (ThyLoad.check_file NONE (ThyLoad.thy_path name)) |
418 if is_some (ThyLoad.check_file NONE (ThyLoad.thy_path name)) |
419 then update_thy_only name |
419 then update_thy_only name |
420 else warning ("Unkown theory context of ML file." ^ dynamic_context ()) |
420 else warning ("Unkown theory context of ML file." ^ dynamic_context ()) |
421 end) (); |
421 end) (); |
431 let val name = thy_name file in |
431 let val name = thy_name file in |
432 if Toplevel.is_toplevel state andalso ThyInfo.known_thy name then |
432 if Toplevel.is_toplevel state andalso ThyInfo.known_thy name then |
433 (ThyInfo.touch_child_thys name; |
433 (ThyInfo.touch_child_thys name; |
434 ThyInfo.pretend_use_thy_only name handle ERROR msg => |
434 ThyInfo.pretend_use_thy_only name handle ERROR msg => |
435 (warning msg; warning ("Failed to register theory: " ^ quote name); |
435 (warning msg; warning ("Failed to register theory: " ^ quote name); |
436 tell_file_retracted (Path.base (Path.unpack file)))) |
436 tell_file_retracted (Path.base (Path.explode file)))) |
437 else raise Toplevel.UNDEF |
437 else raise Toplevel.UNDEF |
438 end; |
438 end; |
439 |
439 |
440 fun vacuous_inform_file_processed file state = |
440 fun vacuous_inform_file_processed file state = |
441 (warning ("No theory " ^ quote (thy_name file)); |
441 (warning ("No theory " ^ quote (thy_name file)); |
442 tell_file_retracted (Path.base (Path.unpack file))); |
442 tell_file_retracted (Path.base (Path.explode file))); |
443 |
443 |
444 |
444 |
445 (* restart top-level loop (keeps most state information) *) |
445 (* restart top-level loop (keeps most state information) *) |
446 |
446 |
447 local |
447 local |
651 fun config_file() = orenv "ISABELLE_PGIPCONFIG" "~~/lib/ProofGeneral/pgip_isar.xml" |
651 fun config_file() = orenv "ISABELLE_PGIPCONFIG" "~~/lib/ProofGeneral/pgip_isar.xml" |
652 fun isabelle_www() = orenv "ISABELLE_HOMEPAGE" "http://isabelle.in.tum.de/" |
652 fun isabelle_www() = orenv "ISABELLE_HOMEPAGE" "http://isabelle.in.tum.de/" |
653 in |
653 in |
654 fun send_pgip_config () = |
654 fun send_pgip_config () = |
655 let |
655 let |
656 val path = Path.unpack (config_file()) |
656 val path = Path.explode (config_file()) |
657 val exists = File.exists path |
657 val exists = File.exists path |
658 val proverinfo = |
658 val proverinfo = |
659 XML.element "proverinfo" |
659 XML.element "proverinfo" |
660 [("name", "Isabelle"), |
660 [("name", "Isabelle"), |
661 ("version", version), |
661 ("version", version), |
676 |
676 |
677 (* Reveal some information about prover state *) |
677 (* Reveal some information about prover state *) |
678 fun send_informguise (openfile, opentheory, openproofpos) = |
678 fun send_informguise (openfile, opentheory, openproofpos) = |
679 let val guisefile = |
679 let val guisefile = |
680 case openfile of SOME f => [XML.element "guisefile" |
680 case openfile of SOME f => [XML.element "guisefile" |
681 [("url",Url.pack (Url.File (Path.unpack f)))] []] |
681 [("url",Url.implode (Url.File (Path.explode f)))] []] |
682 | _ => [] |
682 | _ => [] |
683 val guisetheory = |
683 val guisetheory = |
684 case opentheory of SOME t => [XML.element "guisetheory" [("thyname", t)] []] |
684 case opentheory of SOME t => [XML.element "guisetheory" [("thyname", t)] []] |
685 | _ => [] |
685 | _ => [] |
686 val guiseproof = |
686 val guiseproof = |
1170 |
1170 |
1171 (* load an arbitrary file (must be .thy or .ML) *) |
1171 (* load an arbitrary file (must be .thy or .ML) *) |
1172 |
1172 |
1173 fun use_thy_or_ml_file file = |
1173 fun use_thy_or_ml_file file = |
1174 let |
1174 let |
1175 val (path,extn) = Path.split_ext (Path.unpack file) |
1175 val (path,extn) = Path.split_ext (Path.explode file) |
1176 in |
1176 in |
1177 case extn of |
1177 case extn of |
1178 "" => isarcmd ("use_thy " ^ (quote (Path.pack path))) |
1178 "" => isarcmd ("use_thy " ^ (quote (Path.implode path))) |
1179 | "thy" => isarcmd ("use_thy " ^ (quote (Path.pack path))) |
1179 | "thy" => isarcmd ("use_thy " ^ (quote (Path.implode path))) |
1180 | "ML" => isarcmd ("use " ^ quote file) |
1180 | "ML" => isarcmd ("use " ^ quote file) |
1181 | other => error ("Don't know how to read a file with extension " ^ other) |
1181 | other => error ("Don't know how to read a file with extension " ^ other) |
1182 end |
1182 end |
1183 |
1183 |
1184 |
1184 |
1197 val objtype_attro = xmlattro "objtype" |
1197 val objtype_attro = xmlattro "objtype" |
1198 val objtype_attr = xmlattr "objtype" |
1198 val objtype_attr = xmlattr "objtype" |
1199 val name_attr = xmlattr "name" |
1199 val name_attr = xmlattr "name" |
1200 |
1200 |
1201 fun localfile_of_url url = (* only handle file:/// or file://localhost/ *) |
1201 fun localfile_of_url url = (* only handle file:/// or file://localhost/ *) |
1202 case Url.unpack url of |
1202 case Url.explode url of |
1203 (Url.File path) => File.platform_path path |
1203 (Url.File path) => File.platform_path path |
1204 | _ => error ("Cannot access non-local URL " ^ url) |
1204 | _ => error ("Cannot access non-local URL " ^ url) |
1205 |
1205 |
1206 val fileurl_of = localfile_of_url o (xmlattr "url") |
1206 val fileurl_of = localfile_of_url o (xmlattr "url") |
1207 |
1207 |