]> matita.cs.unibo.it Git - helm.git/commitdiff
* new interface matitaTypes.mli
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Tue, 5 Jul 2005 13:57:07 +0000 (13:57 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Tue, 5 Jul 2005 13:57:07 +0000 (13:57 +0000)
* when exiting with an error message matitac cleans what it produced during
  the interrupted compilation

helm/matita/.depend
helm/matita/Makefile.in
helm/matita/matitaSync.ml
helm/matita/matitaSync.mli
helm/matita/matitaTypes.mli [new file with mode: 0644]
helm/matita/matitacLib.ml
helm/matita/matitacLib.mli
helm/matita/matitacleanLib.ml
helm/matita/matitacleanLib.mli

index d6272980d7947fa0a48797829ef805874a8ead47..8a4e05d8a06e7456e8e8008310b28a35fdfe741c 100644 (file)
@@ -1,32 +1,24 @@
-matitacleanLib.cmo: matitaSync.cmi matitaMisc.cmi matitaDb.cmi \
-    matitacleanLib.cmi 
-matitacleanLib.cmx: matitaSync.cmx matitaMisc.cmx matitaDb.cmx \
-    matitacleanLib.cmi 
-matitaclean.cmo: matitacleanLib.cmi matitaDb.cmi 
-matitaclean.cmx: matitacleanLib.cmx matitaDb.cmx 
-matitacLib.cmo: matitaTypes.cmo matitaMisc.cmi matitaLog.cmi matitaExcPp.cmi \
-    matitaEngine.cmi buildTimeConf.cmo matitacLib.cmi 
-matitacLib.cmx: matitaTypes.cmx matitaMisc.cmx matitaLog.cmx matitaExcPp.cmx \
-    matitaEngine.cmx buildTimeConf.cmx matitacLib.cmi 
-matitac.cmo: matitacLib.cmi 
-matitac.cmx: matitacLib.cmx 
+matita.cmo: matitaTypes.cmi matitaScript.cmi matitaMisc.cmi \
+    matitaMathView.cmi matitaLog.cmi matitaGui.cmi matitaGtkMisc.cmi \
+    matitaEngine.cmi matitaDisambiguator.cmi buildTimeConf.cmo 
+matita.cmx: matitaTypes.cmx matitaScript.cmx matitaMisc.cmx \
+    matitaMathView.cmx matitaLog.cmx matitaGui.cmx matitaGtkMisc.cmx \
+    matitaEngine.cmx matitaDisambiguator.cmx buildTimeConf.cmx 
 matitaDb.cmo: matitaMisc.cmi matitaDb.cmi 
 matitaDb.cmx: matitaMisc.cmx matitaDb.cmi 
-matitadep.cmo: matitaMisc.cmi matitaExcPp.cmi 
-matitadep.cmx: matitaMisc.cmx matitaExcPp.cmx 
-matitaDisambiguator.cmo: matitaTypes.cmo matitaDisambiguator.cmi 
+matitaDisambiguator.cmo: matitaTypes.cmi matitaDisambiguator.cmi 
 matitaDisambiguator.cmx: matitaTypes.cmx matitaDisambiguator.cmi 
-matitaEngine.cmo: matitaTypes.cmo matitaSync.cmi matitaMisc.cmi matitaLog.cmi \
+matitaEngine.cmo: matitaTypes.cmi matitaSync.cmi matitaMisc.cmi matitaLog.cmi \
     matitaDisambiguator.cmi matitaDb.cmi matitaEngine.cmi 
 matitaEngine.cmx: matitaTypes.cmx matitaSync.cmx matitaMisc.cmx matitaLog.cmx \
     matitaDisambiguator.cmx matitaDb.cmx matitaEngine.cmi 
-matitaExcPp.cmo: matitaTypes.cmo matitaExcPp.cmi 
+matitaExcPp.cmo: matitaTypes.cmi matitaExcPp.cmi 
 matitaExcPp.cmx: matitaTypes.cmx matitaExcPp.cmi 
 matitaGeneratedGui.cmo: matitaGeneratedGui.cmi 
 matitaGeneratedGui.cmx: matitaGeneratedGui.cmi 
-matitaGtkMisc.cmo: matitaTypes.cmo matitaGeneratedGui.cmi matitaGtkMisc.cmi 
+matitaGtkMisc.cmo: matitaTypes.cmi matitaGeneratedGui.cmi matitaGtkMisc.cmi 
 matitaGtkMisc.cmx: matitaTypes.cmx matitaGeneratedGui.cmx matitaGtkMisc.cmi 
-matitaGui.cmo: matitaTypes.cmo matitaScript.cmi matitaMisc.cmi matitaLog.cmi \
+matitaGui.cmo: matitaTypes.cmi matitaScript.cmi matitaMisc.cmi matitaLog.cmi \
     matitaGtkMisc.cmi matitaGeneratedGui.cmi matitaExcPp.cmi \
     buildTimeConf.cmo matitaGui.cmi 
 matitaGui.cmx: matitaTypes.cmx matitaScript.cmx matitaMisc.cmx matitaLog.cmx \
@@ -34,37 +26,47 @@ matitaGui.cmx: matitaTypes.cmx matitaScript.cmx matitaMisc.cmx matitaLog.cmx \
     buildTimeConf.cmx matitaGui.cmi 
 matitaLog.cmo: matitaLog.cmi 
 matitaLog.cmx: matitaLog.cmi 
-matitaMathView.cmo: matitaTypes.cmo matitaScript.cmi matitaMisc.cmi \
+matitaMathView.cmo: matitaTypes.cmi matitaScript.cmi matitaMisc.cmi \
     matitaGui.cmi matitaGtkMisc.cmi matitaExcPp.cmi buildTimeConf.cmo \
     matitaMathView.cmi 
 matitaMathView.cmx: matitaTypes.cmx matitaScript.cmx matitaMisc.cmx \
     matitaGui.cmx matitaGtkMisc.cmx matitaExcPp.cmx buildTimeConf.cmx \
     matitaMathView.cmi 
-matitaMisc.cmo: matitaTypes.cmo buildTimeConf.cmo matitaMisc.cmi 
+matitaMisc.cmo: matitaTypes.cmi buildTimeConf.cmo matitaMisc.cmi 
 matitaMisc.cmx: matitaTypes.cmx buildTimeConf.cmx matitaMisc.cmi 
-matita.cmo: matitaTypes.cmo matitaScript.cmi matitaMisc.cmi \
-    matitaMathView.cmi matitaLog.cmi matitaGui.cmi matitaGtkMisc.cmi \
-    matitaEngine.cmi matitaDisambiguator.cmi buildTimeConf.cmo 
-matita.cmx: matitaTypes.cmx matitaScript.cmx matitaMisc.cmx \
-    matitaMathView.cmx matitaLog.cmx matitaGui.cmx matitaGtkMisc.cmx \
-    matitaEngine.cmx matitaDisambiguator.cmx buildTimeConf.cmx 
-matitaScript.cmo: matitacleanLib.cmi matitaTypes.cmo matitaSync.cmi \
+matitaScript.cmo: matitacleanLib.cmi matitaTypes.cmi matitaSync.cmi \
     matitaMisc.cmi matitaLog.cmi matitaEngine.cmi matitaDisambiguator.cmi \
     matitaDb.cmi matitaScript.cmi 
 matitaScript.cmx: matitacleanLib.cmx matitaTypes.cmx matitaSync.cmx \
     matitaMisc.cmx matitaLog.cmx matitaEngine.cmx matitaDisambiguator.cmx \
     matitaDb.cmx matitaScript.cmi 
-matitaSync.cmo: matitaTypes.cmo matitaMisc.cmi matitaLog.cmi matitaDb.cmi \
+matitaSync.cmo: matitaTypes.cmi matitaMisc.cmi matitaLog.cmi matitaDb.cmi \
     matitaSync.cmi 
 matitaSync.cmx: matitaTypes.cmx matitaMisc.cmx matitaLog.cmx matitaDb.cmx \
     matitaSync.cmi 
-matitaTypes.cmo: matitaLog.cmi 
-matitaTypes.cmx: matitaLog.cmx 
-matitaDisambiguator.cmi: matitaTypes.cmo 
-matitaEngine.cmi: matitaTypes.cmo 
+matitaTypes.cmo: matitaLog.cmi matitaTypes.cmi 
+matitaTypes.cmx: matitaLog.cmx matitaTypes.cmi 
+matitac.cmo: matitacLib.cmi 
+matitac.cmx: matitacLib.cmx 
+matitacLib.cmo: matitacleanLib.cmi matitaTypes.cmi matitaMisc.cmi \
+    matitaLog.cmi matitaExcPp.cmi matitaEngine.cmi buildTimeConf.cmo \
+    matitacLib.cmi 
+matitacLib.cmx: matitacleanLib.cmx matitaTypes.cmx matitaMisc.cmx \
+    matitaLog.cmx matitaExcPp.cmx matitaEngine.cmx buildTimeConf.cmx \
+    matitacLib.cmi 
+matitaclean.cmo: matitacleanLib.cmi matitaDb.cmi 
+matitaclean.cmx: matitacleanLib.cmx matitaDb.cmx 
+matitacleanLib.cmo: matitaSync.cmi matitaMisc.cmi matitaDb.cmi \
+    matitacleanLib.cmi 
+matitacleanLib.cmx: matitaSync.cmx matitaMisc.cmx matitaDb.cmx \
+    matitacleanLib.cmi 
+matitadep.cmo: matitaMisc.cmi matitaExcPp.cmi 
+matitadep.cmx: matitaMisc.cmx matitaExcPp.cmx 
+matitaDisambiguator.cmi: matitaTypes.cmi 
+matitaEngine.cmi: matitaTypes.cmi 
 matitaGtkMisc.cmi: matitaGeneratedGui.cmi 
 matitaGui.cmi: matitaLog.cmi matitaGeneratedGui.cmi matitaDisambiguator.cmi 
-matitaMathView.cmi: matitaTypes.cmo 
-matitaMisc.cmi: matitaTypes.cmo 
-matitaScript.cmi: matitaTypes.cmo 
-matitaSync.cmi: matitaTypes.cmo 
+matitaMathView.cmi: matitaTypes.cmi 
+matitaMisc.cmi: matitaTypes.cmi 
+matitaScript.cmi: matitaTypes.cmi 
+matitaSync.cmi: matitaTypes.cmi 
index 4d03f8dfc89781fab555e1e3af328dea8571353a..ac2ec13d3264ae155d5aeb85e6eff650d2e43654 100644 (file)
@@ -48,8 +48,9 @@ CCMOS =                               \
        matitaSync.cmo          \
        matitaDisambiguator.cmo \
        matitaEngine.cmo        \
+       matitacleanLib.cmo      \
        matitacLib.cmo
-CLEANCMOS = $(CCMOS) matitacleanLib.cmo
+CLEANCMOS = $(CCMOS)
 
 
 all: matita matitac matitatop cicbrowser matitadep matitaclean
index 23e3b048f45bd015a184d2b6273b9cd257c1406e..29e19c690ea20744954a79b4bdcc260d007d6324 100644 (file)
@@ -222,7 +222,7 @@ let time_travel ~present ~past =
       MatitaLog.debug "l2:";
       List.iter MatitaLog.debug l2
     
-let remove uri =
+let remove ~verbose uri =
   let derived_uris_of_uri uri =
     UriManager.innertypesuri_of_uri uri ::
     (match UriManager.bodyuri_of_uri uri with
@@ -237,10 +237,10 @@ let remove uri =
   List.iter 
     (fun uri -> 
       (try
-        MatitaLog.debug ("Removing: " ^ UriManager.string_of_uri uri);
+        if verbose then
+         MatitaLog.debug ("Removing: " ^ UriManager.string_of_uri uri);
         MatitaMisc.safe_remove (Http_getter.resolve' uri)
       with Http_getter_types.Key_not_found _ -> ());
       remove_coercion uri; 
       ignore (MatitaDb.remove_uri uri))
   to_remove
-
index bb573fcb17bebc8b95f53cbdaed290d02edb8514..66787ad4673b9dd7731f66d18f12c989a0297ebf 100644 (file)
@@ -43,5 +43,4 @@ val set_proof_aliases :
   (* removes the object from DB, Disk, CoercionsDB, getter 
    * asserts the uri is resolved to file:// so it is only for 
    * user's objects *)
-val remove: UriManager.uri -> unit
-
+val remove: verbose:bool -> UriManager.uri -> unit
diff --git a/helm/matita/matitaTypes.mli b/helm/matita/matitaTypes.mli
new file mode 100644 (file)
index 0000000..662dad6
--- /dev/null
@@ -0,0 +1,100 @@
+(* Copyright (C) 2004-2005, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
+exception Cancel
+exception Statement_error of string
+val statement_error : string -> 'a
+
+exception Command_error of string
+val command_error : string -> 'a
+
+exception Option_error of string * string
+exception Unbound_identifier of string
+
+type proof_status =
+    No_proof
+  | Incomplete_proof of ProofEngineTypes.status
+  | Proof of ProofEngineTypes.proof
+  | Intermediate of Cic.metasenv
+
+module StringMap : Map.S with type key = String.t
+
+type option_value =
+  | String of string
+  | Int of int
+type options = option_value StringMap.t
+val no_options : 'a StringMap.t
+
+type status = {
+  aliases : DisambiguateTypes.environment;
+  moo_content_rev : string list;
+  proof_status : proof_status;
+  options : options;
+  objects : (UriManager.uri * string) list;
+}
+
+val dump_status : status -> unit
+val get_option : status -> StringMap.key -> option_value
+val get_string_option : status -> StringMap.key -> string
+val set_option : status -> StringMap.key -> string -> status
+
+class type console =
+  object
+    method choose_uri : string list -> string
+    method clear : unit -> unit
+    method echo_error : string -> unit
+    method echo_message : string -> unit
+    method show : ?msg:string -> unit -> unit
+    method wrap_exn : (unit -> 'a) -> 'a option
+  end
+
+type abouts = [ `Blank | `Current_proof | `Us ]
+
+type mathViewer_entry =
+  [ `About of abouts
+  | `Check of string
+  | `Cic of Cic.term * Cic.metasenv
+  | `Dir of string
+  | `Uri of UriManager.uri
+  | `Whelp of string * UriManager.uri list ]
+
+val string_of_entry :
+  [< `About of [< `Blank | `Current_proof | `Us ]
+   | `Check of 'a
+   | `Cic of 'b * 'c
+   | `Dir of string
+   | `Uri of UriManager.uri
+   | `Whelp of string * 'd ] ->
+  string
+
+val entry_of_string :
+  string -> [> `About of [> `Blank | `Current_proof | `Us ] ]
+
+class type mathViewer =
+  object
+    method show_entry : ?reuse:bool -> mathViewer_entry -> unit
+    method show_uri_list :
+      ?reuse:bool -> entry:mathViewer_entry -> UriManager.uri list -> unit
+  end
index fbc393cfb3bed6472ae6de4874975b3786c632ff..ec722490ab07863238622c7e1f0d2cda14ddbaa9 100644 (file)
@@ -98,6 +98,14 @@ let rec go () =
       MatitaLog.error (sprintf "Parse error at %d-%d: %s" x y err);
       go ()
   | exn -> MatitaLog.error (Printexc.to_string exn); 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 main ~mode = 
   Helm_registry.load_from "matita.conf.xml";
@@ -140,7 +148,7 @@ let main ~mode =
      begin
       MatitaLog.error
        "there are still incomplete proofs at the end of the script";
-      exit 2
+      clean_exit 2
      end
     else
      begin
@@ -157,19 +165,23 @@ let main ~mode =
   | Sys.Break ->
       MatitaLog.error "user break!";
       if mode = `COMPILER then
-        exit ~-1
+        clean_exit ~-1
       else
         pp_ocaml_mode ()
   | MatitaEngine.Drop ->
       if mode = `COMPILER then 
-        exit 1 
+        clean_exit 1 
       else 
         pp_ocaml_mode ()
   | CicTextualParser2.Parse_error (floc,err) ->
      let (x, y) = CicAst.loc_of_floc floc in
      MatitaLog.error (sprintf "Parse error at %d-%d: %s" x y err);
      if mode = `COMPILER then
-       exit 1
+       clean_exit 1
      else
        pp_ocaml_mode ()
-
+  | _ ->
+     if mode = `COMPILER then 
+       clean_exit 3
+     else 
+       pp_ocaml_mode ()
index aad2b29acbf02878cedc95383b16a91d5d1d3fec..b778b91f3e80457fadac61afdbcca9b8095fd001 100644 (file)
@@ -1,2 +1,27 @@
+(* Copyright (C) 2004-2005, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
 val go : unit -> unit
 val main : mode:[ `COMPILER | `TOPLEVEL ] -> unit
index 37c87d770a1df3e836ed5745e8f675ac85e8998d..a616519c1c2a4a1eacfab508f3e14d0103d87681 100644 (file)
@@ -115,14 +115,14 @@ let rec fix uris next =
   | [] -> uris
   | l -> let uris, next = close_uri_list l in fix uris next @ uris
   
-let clean_baseuris buris =
+let clean_baseuris ?(verbose=true) buris =
   let buris = List.map HGM.strip_trailing_slash buris in
   (* List.iter prerr_endline buris; *)
   let l = fix [] buris in
   let l = MatitaMisc.list_uniq (List.fast_sort Pervasives.compare l) in
   let l = List.map UriManager.uri_of_string l in
   (* List.iter (fun u -> prerr_endline (UriManager.string_of_uri u)) l; *)
-  List.iter MatitaSync.remove l
+  List.iter (MatitaSync.remove ~verbose) l
   
 let is_empty buri = HG.ls (HGM.strip_trailing_slash buri ^ "/") = []
 
index 0de7f586736e4a5080484afe173dd27b1d3b84ba..7077ed41e66a7a987d88e1ed3174ba663e6bbbc8 100644 (file)
@@ -23,7 +23,7 @@
  * http://helm.cs.unibo.it/
  *)
 
-val clean_baseuris : string list -> unit
+val clean_baseuris : ?verbose:bool -> string list -> unit
 val baseuri_of_file : string -> string 
 
 val baseuri_of_baseuri_decl : ('a, 'b, 'c) TacticAst.statement -> string option