MatitaLog.message "Type 'go ();;' to enter an interactive matitac";
MatitaLog.message ""
-let rec go () =
+let clean_exit n =
+ match !status with
+ None -> exit n
+ | Some status ->
+ let baseuri = MatitaTypes.get_string_option !status "baseuri" in
+ MatitacleanLib.clean_baseuris ~verbose:false [baseuri];
+ exit n
+
+let rec interactive_loop () =
let str = Stream.of_channel stdin in
try
run_script str MatitaEngine.eval_from_stream_greedy
with
| MatitaEngine.Drop -> pp_ocaml_mode ()
- | Sys.Break -> MatitaLog.error "user break!"; go ()
- | MatitaTypes.Command_error _ -> go ()
+ | Sys.Break -> MatitaLog.error "user break!"; interactive_loop ()
+ | MatitaTypes.Command_error _ -> interactive_loop ()
| CicTextualParser2.Parse_error (floc,err) ->
(* check for EOI *)
if Stream.peek str = None then
- exit 0
+ clean_exit 0
else
let (x, y) = CicAst.loc_of_floc floc in
MatitaLog.error (sprintf "Parse error at %d-%d: %s" x y err);
- go ()
- | exn -> MatitaLog.error (Printexc.to_string exn); go ()
+ interactive_loop ()
+ | exn -> MatitaLog.error (Printexc.to_string exn); interactive_loop ()
+
+let go () =
+ Helm_registry.load_from "matita.conf.xml";
+ Http_getter.init ();
+ MetadataTypes.ownerize_tables (Helm_registry.get "matita.owner");
+ status := Some (ref (Lazy.force MatitaEngine.initial_status));
+ Sys.catch_break true;
+ interactive_loop ()
-let clean_exit n =
- match !status with
- None -> exit n
- | Some status ->
- let baseuri = MatitaTypes.get_string_option !status "baseuri" in
- MatitacleanLib.clean_baseuris ~verbose:false [baseuri];
- exit n
-
let main ~mode =
Helm_registry.load_from "matita.conf.xml";
Http_getter.init ();
MetadataTypes.ownerize_tables (Helm_registry.get "matita.owner");
-(*
- MatitaDb.clean_owner_environment ();
- MatitaDb.create_owner_environment ();
-*)
status := Some (ref (Lazy.force MatitaEngine.initial_status));
Sys.catch_break true;
let fname = fname () in
* http://helm.cs.unibo.it/
*)
+val interactive_loop : unit -> unit
+
+(** go initializes the status and calls interactive_loop *)
val go : unit -> unit
val main : mode:[ `COMPILER | `TOPLEVEL ] -> unit
+
+(** clean_exit n
+ performs an exit [n] after a complete clean-up of what was partially compiled
+*)
+val clean_exit : int -> unit