]> matita.cs.unibo.it Git - helm.git/commitdiff
1. metadata are no longer stored in .moo files.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Sat, 3 Dec 2005 10:35:10 +0000 (10:35 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Sat, 3 Dec 2005 10:35:10 +0000 (10:35 +0000)
   They are now stored (and retrieved) in .metadata files if -nodb is set.
   In this way the "library" library no longer depends on "content_pres"
2. removed files in grafite_parser that were commited by mistake

30 files changed:
helm/ocaml/METAS/meta.helm-grafite2.src
helm/ocaml/METAS/meta.helm-library.src
helm/ocaml/grafite/grafiteAst.ml
helm/ocaml/grafite/grafiteAstPp.ml
helm/ocaml/grafite/grafiteAstPp.mli
helm/ocaml/grafite/grafiteMarshal.ml
helm/ocaml/grafite/grafiteMarshal.mli
helm/ocaml/grafite/grafiteParser.ml
helm/ocaml/grafite2/grafiteEngine.ml
helm/ocaml/grafite2/grafiteMisc.ml
helm/ocaml/grafite2/grafiteMisc.mli
helm/ocaml/grafite2/grafiteTypes.ml
helm/ocaml/grafite2/grafiteTypes.mli
helm/ocaml/grafite2/matitaSync.ml
helm/ocaml/grafite_parser/grafiteDisambiguate.cmi [deleted file]
helm/ocaml/grafite_parser/grafiteDisambiguate.cmo [deleted file]
helm/ocaml/grafite_parser/grafiteDisambiguate.cmx [deleted file]
helm/ocaml/grafite_parser/grafiteDisambiguate.ml
helm/ocaml/grafite_parser/grafiteDisambiguate.o [deleted file]
helm/ocaml/grafite_parser/grafite_parser.a [deleted file]
helm/ocaml/grafite_parser/grafite_parser.cma [deleted file]
helm/ocaml/grafite_parser/grafite_parser.cmxa [deleted file]
helm/ocaml/grafite_parser/matitaDisambiguator.cmx [deleted file]
helm/ocaml/library/.depend
helm/ocaml/library/Makefile
helm/ocaml/library/libraryClean.ml
helm/ocaml/library/libraryMisc.ml
helm/ocaml/library/libraryMisc.mli
helm/ocaml/library/libraryNoDb.ml [new file with mode: 0644]
helm/ocaml/library/libraryNoDb.mli [new file with mode: 0644]

index c6603db5c8e22f12f2d2b6c7b8a8248653bf360a..058167e4adc2b614384b3ba2b4c93598ec16adc0 100644 (file)
@@ -1,4 +1,4 @@
-requires="helm-library helm-tactics helm-cic_disambiguation"
+requires="helm-library helm-grafite helm-tactics helm-cic_disambiguation"
 version="0.0.1"
 archive(byte)="grafite2.cma"
 archive(native)="grafite2.cmxa"
index 366269cf9eb3eb7f39bdd31a0279eff80f818eca..d4955e05d1be1bd619f31cb7c87b619e71fe3ba0 100644 (file)
@@ -1,4 +1,4 @@
-requires="helm-grafite helm-metadata"
+requires="helm-cic_acic helm-metadata"
 version="0.0.1"
 archive(byte)="library.cma"
 archive(native)="library.cmxa"
index a7b0f3eea365541a15647a4e1919453702abfe13..3d176fbe5190d721f0728c85f7b7c3b28ddbbec0 100644 (file)
@@ -112,14 +112,6 @@ type alias_spec =
   | Symbol_alias of string * int * string (* name, instance no, description *)
   | Number_alias of int * string          (* instance no, description *)
 
-type metadata =
-  | Dependency of string  (* baseuri without trailing slash *)
-  | Baseuri of string 
-
-let compare_metadata = Pervasives.compare
-
-let eq_metadata = (=)
-
 (** To be increased each time the command type below changes, used for "safe"
  * marshalling *)
 let magic = 4
@@ -145,8 +137,6 @@ type ('term,'obj) command =
         CicNotationPt.cic_appl_pattern
       (* description (i.e. id), symbol, arg pattern, appl pattern *)
 
-  | Metadata of loc * metadata
-
     (* DEBUGGING *)
   | Dump of loc (* dump grammar on stdout *)
     (* DEBUGGING *)
@@ -155,26 +145,6 @@ type ('term,'obj) command =
 (* composed magic: term + command magics. No need to change this value *)
 let magic = magic + 10000 * CicNotationPt.magic
 
-let reash_cmd_uris =
-  let reash_uri uri = UriManager.uri_of_string (UriManager.string_of_uri uri) in
-  function
-  | Default (loc, name, uris) ->
-      let uris = List.map reash_uri uris in
-      Default (loc, name, uris)
-  | Interpretation (loc, dsc, args, cic_appl_pattern) ->
-      let rec aux =
-        function
-        | CicNotationPt.UriPattern uri ->
-            CicNotationPt.UriPattern (reash_uri uri)
-        | CicNotationPt.ApplPattern args ->
-            CicNotationPt.ApplPattern (List.map aux args)
-        | CicNotationPt.VarPattern _
-        | CicNotationPt.ImplicitPattern as pat -> pat
-      in
-      let appl_pattern = aux cic_appl_pattern in
-      Interpretation (loc, dsc, args, appl_pattern)
-  | cmd -> cmd
-
 type ('term, 'lazy_term, 'reduction, 'ident) tactical =
   | Tactic of loc * ('term, 'lazy_term, 'reduction, 'ident) tactic
   | Do of loc * int * ('term, 'lazy_term, 'reduction, 'ident) tactical
index 7687bc5222235543bd6da28bd876f6253710b54f..ce4a585b3e609d52b510af84c0632e74c1356453 100644 (file)
@@ -206,11 +206,6 @@ let pp_dir_opt = function
   | Some `LeftToRight -> "> "
   | Some `RightToLeft -> "< "
 
-let pp_metadata =
-  function
-  | Dependency buri -> sprintf "dependency %s" buri
-  | Baseuri buri -> sprintf "baseuri %s" buri
-
 let pp_command = function
   | Include (_,path) -> "include " ^ path
   | Qed _ -> "qed"
@@ -235,7 +230,6 @@ let pp_command = function
         (pp_associativity assoc)
         (pp_precedence prec)
         (pp_l2_pattern l2_pattern)
-  | Metadata (_, m) -> sprintf "metadata %s" (pp_metadata m)
   | Render _
   | Dump _ -> assert false  (* ZACK: debugging *)
 
@@ -293,7 +287,6 @@ let pp_cic_command = function
   | Render _
   | Dump _
   | Interpretation _
-  | Metadata _
   | Notation _
   | Obj _ -> assert false (* not implemented *)
 
index eefcd9ccbbea325c3b6cc2904d85ef17163498f0..1ecfb4352a4063fa7a2687cc57711c35c242c7e4 100644 (file)
@@ -30,7 +30,6 @@ val pp_tactic:
 
 val pp_command:
   (CicNotationPt.term,CicNotationPt.obj) GrafiteAst.command -> string
-val pp_metadata: GrafiteAst.metadata -> string
 val pp_macro: ('a -> string) -> 'a GrafiteAst.macro -> string
 
 val pp_comment:
index dd9febedbc66fe9f384395fe47229a972b6eb905..8b4f8858b8bf8f3b33b0b50f0670c1499d370d80 100644 (file)
@@ -28,24 +28,48 @@ exception Corrupt_moo of string
 exception Version_mismatch of string
 
 type ast_command = (Cic.term, Cic.obj) GrafiteAst.command
-type moo = ast_command list * GrafiteAst.metadata list  (** <moo, metadata> *)
+type moo = ast_command list
 
 let marshal_flags = []
 
+let rehash_cmd_uris =
+  let rehash_uri uri = UriManager.uri_of_string (UriManager.string_of_uri uri) in
+  function
+  | GrafiteAst.Default (loc, name, uris) ->
+      let uris = List.map rehash_uri uris in
+      GrafiteAst.Default (loc, name, uris)
+  | GrafiteAst.Interpretation (loc, dsc, args, cic_appl_pattern) ->
+      let rec aux =
+        function
+        | CicNotationPt.UriPattern uri ->
+            CicNotationPt.UriPattern (rehash_uri uri)
+        | CicNotationPt.ApplPattern args ->
+            CicNotationPt.ApplPattern (List.map aux args)
+        | CicNotationPt.VarPattern _
+        | CicNotationPt.ImplicitPattern as pat -> pat
+      in
+      let appl_pattern = aux cic_appl_pattern in
+      GrafiteAst.Interpretation (loc, dsc, args, appl_pattern)
+  | GrafiteAst.Coercion (loc, term, close) ->
+      GrafiteAst.Coercion (loc, CicUtil.rehash_term term, close)
+  | GrafiteAst.Notation _
+  | GrafiteAst.Alias _ as cmd -> cmd
+  | cmd ->
+      prerr_endline "Found a command not expected in a .moo:";
+      prerr_endline (GrafiteAstPp.pp_cic_command cmd);
+      assert false
+
 (** .moo file format
  * - an integer -- magic number -- denoting the version of the dumped data
  *   structure. Different magic numbers stand for incompatible data structures
  * - an integer -- checksum -- denoting the hash value (computed with
  *   Hashtbl.hash) of the string representation of the dumped data structur
- * - marshalled pair: first component is a list of GrafiteAst.command (real moo
- *   content), second component is a list of GrafiteAst.metadata
+ * - marshalled data: list of GrafiteAst.command
  *)
 
-let save_moo ~fname (moo, metadata) =
+let save_moo ~fname moo =
  let oc = open_out fname in
- let marshalled = 
-   Marshal.to_string (List.rev moo, List.rev metadata) marshal_flags 
- in
+ let marshalled = Marshal.to_string (List.rev moo) marshal_flags in
  let checksum = Hashtbl.hash marshalled in
  output_binary_int oc GrafiteAst.magic;
  output_binary_int oc checksum;
@@ -67,7 +91,7 @@ let load_moo ~fname =
         let (moo:moo) =
           Marshal.from_string marshalled 0
         in
-        moo
+        List.map rehash_cmd_uris moo
       with End_of_file -> raise (Corrupt_moo fname))
     ()
 
index 8fb1b23988c931e3121a8960e604715ddc2178f9..9be797a44fb6e76ba389e37f3db31c4d55e65fec 100644 (file)
@@ -29,7 +29,7 @@ exception Corrupt_moo of string
 exception Version_mismatch of string
 
 type ast_command = (Cic.term, Cic.obj) GrafiteAst.command
-type moo = ast_command list * GrafiteAst.metadata list  (** <moo, metadata> *)
+type moo = ast_command list
 
 val save_moo: fname:string -> moo -> unit
 
index 3d0ea500bc9034d858a2c7f213bf63e6f92231fd..64db522950c31e50e788c07878ced0dc5775d2d9 100644 (file)
@@ -492,10 +492,6 @@ EXTEND
     | IDENT "interpretation"; id = QSTRING;
       (symbol, args, l3) = interpretation ->
         GrafiteAst.Interpretation (loc, id, (symbol, args), l3)
-    | IDENT "metadata"; [ IDENT "dependency" | IDENT "baseuri" ] ; URI ->
-        (** metadata commands lives only in .moo, where they are in marshalled
-         * form *)
-        raise (HExtlib.Localized (loc,CicNotationParser.Parse_error "metadata not allowed here"))
 
     | IDENT "dump" -> GrafiteAst.Dump loc
     | IDENT "render"; u = URI ->
index fe67c2fc4fb589e112ed4145bccb0ec626765e6c..70fb767a87f419bedb3eeab075351b66f81de789 100644 (file)
@@ -25,7 +25,8 @@
 
 exception Drop
 exception UnableToInclude of string
-exception IncludedFileNotCompiled of string
+exception IncludedFileNotCompiled of string (* file name *)
+exception MetadataNotFound of string        (* file name *)
 
 type options = { 
   do_heavy_checks: bool ; 
@@ -476,15 +477,23 @@ let rec eval_command = {ec_go = fun ~disambiguate_command opts status cmd ->
   | GrafiteAst.Include (loc, path) ->
      let absolute_path = make_absolute opts.include_paths path in
      let moopath = GrafiteMisc.obj_file_of_script ~basedir absolute_path in
-     let status = ref status in
+     let metadatapath =
+       GrafiteMisc.metadata_file_of_script ~basedir absolute_path in
      if not (Sys.file_exists moopath) then
        raise (IncludedFileNotCompiled moopath);
+     let status =
+       if Helm_registry.get_bool "db.nodb" then
+         if not (Sys.file_exists metadatapath) then
+           raise (MetadataNotFound metadatapath)
+         else
+           GrafiteTypes.add_metadata
+             (LibraryNoDb.load_metadata ~fname:metadatapath) status
+       else
+         status
+     in
+     let status = ref status in
      eval_from_moo.efm_go status moopath;
      !status
-  | GrafiteAst.Metadata (loc, m) ->
-      (match m with
-      | GrafiteAst.Dependency uri -> GrafiteTypes.add_moo_metadata [m] status
-      | GrafiteAst.Baseuri _ -> status)
   | GrafiteAst.Set (loc, name, value) -> 
       let status = 
         if name = "baseuri" then begin
@@ -500,7 +509,7 @@ let rec eval_command = {ec_go = fun ~disambiguate_command opts status cmd ->
             HLog.message ("cleaning baseuri " ^ value);
             LibraryClean.clean_baseuris ~basedir [value]
           end;
-          GrafiteTypes.add_moo_metadata [GrafiteAst.Baseuri value] status
+          GrafiteTypes.add_metadata [LibraryNoDb.Baseuri value] status
         end else
           status
       in
@@ -551,7 +560,7 @@ let rec eval_command = {ec_go = fun ~disambiguate_command opts status cmd ->
       let status = GrafiteTypes.add_moo_content [stm] status in
       let uris =
         List.map
-          (fun uri -> GrafiteAst.Dependency (UriManager.buri_of_uri uri))
+          (fun uri -> LibraryNoDb.Dependency (UriManager.buri_of_uri uri))
           (CicNotationUtil.find_appl_pattern_uris cic_appl_pattern)
       in
       let diff =
@@ -559,7 +568,7 @@ let rec eval_command = {ec_go = fun ~disambiguate_command opts status cmd ->
          DisambiguateChoices.lookup_symbol_by_dsc symbol dsc]
       in
       let status = MatitaSync.set_proof_aliases status diff in
-      let status = GrafiteTypes.add_moo_metadata uris status in
+      let status = GrafiteTypes.add_metadata uris status in
       status
   | GrafiteAst.Notation _ as stm -> GrafiteTypes.add_moo_content [stm] status
   | GrafiteAst.Obj (loc,obj) ->
@@ -645,9 +654,9 @@ let rec eval_command = {ec_go = fun ~disambiguate_command opts status cmd ->
   let ast_of_cmd cmd =
     GrafiteAst.Executable (DisambiguateTypes.dummy_floc,
       GrafiteAst.Command (DisambiguateTypes.dummy_floc,
-        (GrafiteAst.reash_cmd_uris cmd)))
+        cmd))
   in
-  let moo, metadata = GrafiteMarshal.load_moo fname in
+  let moo = GrafiteMarshal.load_moo fname in
   List.iter 
     (fun ast -> 
       let ast = ast_of_cmd ast in
@@ -656,19 +665,7 @@ let rec eval_command = {ec_go = fun ~disambiguate_command opts status cmd ->
          ~disambiguate_tactic:(fun status _ tactic -> ref status,tactic)
          ~disambiguate_command:(fun status cmd -> status,cmd)
          !status ast)
-    moo;
-  List.iter
-    (fun m ->
-      let ast =
-        ast_of_cmd (GrafiteAst.Metadata (DisambiguateTypes.dummy_floc, m))
-      in
-      status :=
-        eval_ast.ea_go
-         ~disambiguate_tactic:(fun status _ tactic -> ref status,tactic)
-         ~disambiguate_command:(fun status cmd -> status,cmd)
-         !status ast)
-    metadata
-
+    moo
 } and eval_ast = {ea_go = fun ~disambiguate_tactic ~disambiguate_command
   ?(do_heavy_checks=false) ?(include_paths=[]) ?(clean_baseuri=true) status st 
 ->
index 910f8a483dd16617c9e4cfdde5ff8c1b8507f970..8739b7a070fb4c70c2a0b997432684c04197fe6f 100644 (file)
@@ -72,3 +72,8 @@ let baseuri_of_file file =
 let obj_file_of_script ~basedir f =
   let baseuri = baseuri_of_file f in
    LibraryMisc.obj_file_of_baseuri ~basedir ~baseuri
+
+let metadata_file_of_script ~basedir f =
+  let baseuri = baseuri_of_file f in
+   LibraryMisc.metadata_file_of_baseuri ~basedir ~baseuri
+
index 8cc384abcd0d38abf3d40691d024cda17f9ae823..9f1486b0b3ce8cedfe616c5e5f8442ed1ee7fbb9 100644 (file)
@@ -33,3 +33,4 @@ val is_empty: string -> bool
 val baseuri_of_file : string -> string
 
 val obj_file_of_script : basedir:string -> string -> string
+val metadata_file_of_script : basedir:string -> string -> string
index 2e2daf4e773de903e1561ce19fc2c64810a76e58..c73e8bd3ce395af92af7a52e00b53900ad503adb 100644 (file)
@@ -53,6 +53,7 @@ type status = {
   aliases: DisambiguateTypes.environment;
   multi_aliases: DisambiguateTypes.multiple_environment;
   moo_content_rev: GrafiteMarshal.moo;
+  metadata: LibraryNoDb.metadata list;
   proof_status: proof_status;
   options: options;
   objects: UriManager.uri list;
@@ -115,7 +116,7 @@ let get_proof_conclusion status goal =
   | _ -> raise (Statement_error "no ongoing proof")
  
 let add_moo_content cmds status =
-  let content, metadata = status.moo_content_rev in
+  let content = status.moo_content_rev in
   let content' =
     List.fold_right
       (fun cmd acc ->
@@ -132,7 +133,7 @@ let add_moo_content cmds status =
   in
 (*   prerr_endline ("new moo content: " ^ String.concat " " (List.map
     GrafiteAstPp.pp_command content')); *)
-  { status with moo_content_rev = content', metadata }
+  { status with moo_content_rev = content' }
 
 let get_option status name =
   try
@@ -174,26 +175,29 @@ let get_string_option status name =
 
 let qualify status name = get_string_option status "baseuri" ^ "/" ^ name
 
-let add_moo_metadata new_metadata status =
-  let content, metadata = status.moo_content_rev in
-  let metadata' =
-    List.fold_left
-      (fun acc m ->
-        match m with
-        | GrafiteAst.Dependency buri ->
-            let is_self = (* self dependency *)
-              try
-                get_string_option status "baseuri" = buri
-              with Option_error _ -> false  (* baseuri not yet set *)
-            in
-            if is_self
-              || List.exists (GrafiteAst.eq_metadata m) metadata (* duplicate *)
-            then acc
-            else m :: acc
-        | _ -> m :: acc)
-      metadata new_metadata
-  in
-  { status with moo_content_rev = content, metadata' }
+let add_metadata new_metadata status =
+  if Helm_registry.get_bool "db.nodb" then
+    let metadata = status.metadata in
+    let metadata' =
+      List.fold_left
+        (fun acc m ->
+          match m with
+          | LibraryNoDb.Dependency buri ->
+              let is_self = (* self dependency *)
+                try
+                  get_string_option status "baseuri" = buri
+                with Option_error _ -> false  (* baseuri not yet set *)
+              in
+              if is_self (* duplicate *)
+                || List.exists (LibraryNoDb.eq_metadata m) metadata
+              then acc
+              else m :: acc
+          | _ -> m :: acc)
+        metadata new_metadata
+    in
+    { status with metadata = metadata' }
+  else
+    status
 
 let dump_status status = 
   HLog.message "status.aliases:\n";
index 17544d5bda1c2220fb321f7ca83aa03ef77d68f5..361a00825e2ee50c1a1fd0a541645c33338860d4 100644 (file)
@@ -48,6 +48,7 @@ type status = {
   aliases: DisambiguateTypes.environment;         (** disambiguation aliases *)
   multi_aliases: DisambiguateTypes.multiple_environment;
   moo_content_rev: GrafiteMarshal.moo;
+  metadata: LibraryNoDb.metadata list;
   proof_status: proof_status;                             (** logical status *)
   options: options;
   objects: UriManager.uri list;  (** in-scope objects *)
@@ -59,7 +60,7 @@ val dump_status : status -> unit
 
   (** list is not reversed, head command will be the first emitted *)
 val add_moo_content: GrafiteMarshal.ast_command list -> status -> status
-val add_moo_metadata: GrafiteAst.metadata list -> status -> status
+val add_metadata: LibraryNoDb.metadata list -> status -> status
 
 val get_option : status -> string -> option_value
 val get_string_option : status -> string -> string
index 26ebbd03224f8e720bec51af988f10df84816e91..2424d178f896b6b46c3e444e8a0acad1c6052d29 100644 (file)
@@ -56,7 +56,7 @@ let set_proof_aliases status new_aliases =
     (function
     | GrafiteAst.Ident_alias (_, suri) ->
         let buri = UriManager.buri_of_uri (UriManager.uri_of_string suri) in
-        Some (GrafiteAst.Dependency buri)
+        Some (LibraryNoDb.Dependency buri)
     | _ -> None)
  in
  let aliases =
@@ -75,7 +75,7 @@ let set_proof_aliases status new_aliases =
      DisambiguatePp.aliases_of_domain_and_codomain_items_list new_aliases
    in
    let status = add_moo_content (commands_of_aliases aliases) new_status in
-   let status = add_moo_metadata (deps_of_aliases aliases) status in
+   let status = add_metadata (deps_of_aliases aliases) status in
    status
 
 (** given a uri and a type list (the contructors types) builds a list of pairs
diff --git a/helm/ocaml/grafite_parser/grafiteDisambiguate.cmi b/helm/ocaml/grafite_parser/grafiteDisambiguate.cmi
deleted file mode 100644 (file)
index 51403bf..0000000
Binary files a/helm/ocaml/grafite_parser/grafiteDisambiguate.cmi and /dev/null differ
diff --git a/helm/ocaml/grafite_parser/grafiteDisambiguate.cmo b/helm/ocaml/grafite_parser/grafiteDisambiguate.cmo
deleted file mode 100644 (file)
index d78935a..0000000
Binary files a/helm/ocaml/grafite_parser/grafiteDisambiguate.cmo and /dev/null differ
diff --git a/helm/ocaml/grafite_parser/grafiteDisambiguate.cmx b/helm/ocaml/grafite_parser/grafiteDisambiguate.cmx
deleted file mode 100644 (file)
index bef7464..0000000
Binary files a/helm/ocaml/grafite_parser/grafiteDisambiguate.cmx and /dev/null differ
index 9e52f92b17fd2d7382be7e4f07589fbb885ba4e0..3c79cc0405806d1cd4b01f88b1eacbcbfbe56985 100644 (file)
@@ -238,7 +238,6 @@ let disambiguate_command status =
   | GrafiteAst.Dump _
   | GrafiteAst.Include _
   | GrafiteAst.Interpretation _
-  | GrafiteAst.Metadata _
   | GrafiteAst.Notation _
   | GrafiteAst.Qed _
   | GrafiteAst.Render _
diff --git a/helm/ocaml/grafite_parser/grafiteDisambiguate.o b/helm/ocaml/grafite_parser/grafiteDisambiguate.o
deleted file mode 100644 (file)
index 14ccd78..0000000
Binary files a/helm/ocaml/grafite_parser/grafiteDisambiguate.o and /dev/null differ
diff --git a/helm/ocaml/grafite_parser/grafite_parser.a b/helm/ocaml/grafite_parser/grafite_parser.a
deleted file mode 100644 (file)
index 40b142e..0000000
Binary files a/helm/ocaml/grafite_parser/grafite_parser.a and /dev/null differ
diff --git a/helm/ocaml/grafite_parser/grafite_parser.cma b/helm/ocaml/grafite_parser/grafite_parser.cma
deleted file mode 100644 (file)
index 9bdad07..0000000
Binary files a/helm/ocaml/grafite_parser/grafite_parser.cma and /dev/null differ
diff --git a/helm/ocaml/grafite_parser/grafite_parser.cmxa b/helm/ocaml/grafite_parser/grafite_parser.cmxa
deleted file mode 100644 (file)
index cd3799f..0000000
Binary files a/helm/ocaml/grafite_parser/grafite_parser.cmxa and /dev/null differ
diff --git a/helm/ocaml/grafite_parser/matitaDisambiguator.cmx b/helm/ocaml/grafite_parser/matitaDisambiguator.cmx
deleted file mode 100644 (file)
index 1f8b72b..0000000
Binary files a/helm/ocaml/grafite_parser/matitaDisambiguator.cmx and /dev/null differ
index 1ad51256bd42037569ba99dd8aa467f059ce6f64..279a4ea6526d0f06530e4823d0b949a29adc0ba6 100644 (file)
@@ -1,4 +1,3 @@
-coercGraph.cmi: coercDb.cmi 
 cicElim.cmo: cicElim.cmi 
 cicElim.cmx: cicElim.cmi 
 cicRecord.cmo: cicRecord.cmi 
@@ -7,15 +6,17 @@ libraryMisc.cmo: libraryMisc.cmi
 libraryMisc.cmx: libraryMisc.cmi 
 libraryDb.cmo: libraryDb.cmi 
 libraryDb.cmx: libraryDb.cmi 
-coercGraph.cmo: coercDb.cmi coercGraph.cmi 
-coercGraph.cmx: coercDb.cmx coercGraph.cmi 
 coercDb.cmo: coercDb.cmi 
 coercDb.cmx: coercDb.cmi 
 librarySync.cmo: libraryDb.cmi coercDb.cmi cicRecord.cmi cicElim.cmi \
     librarySync.cmi 
 librarySync.cmx: libraryDb.cmx coercDb.cmx cicRecord.cmx cicElim.cmx \
     librarySync.cmi 
-libraryClean.cmo: librarySync.cmi libraryMisc.cmi libraryDb.cmi \
-    libraryClean.cmi 
-libraryClean.cmx: librarySync.cmx libraryMisc.cmx libraryDb.cmx \
-    libraryClean.cmi 
+coercGraph.cmo: librarySync.cmi coercDb.cmi coercGraph.cmi 
+coercGraph.cmx: librarySync.cmx coercDb.cmx coercGraph.cmi 
+libraryNoDb.cmo: libraryNoDb.cmi 
+libraryNoDb.cmx: libraryNoDb.cmi 
+libraryClean.cmo: librarySync.cmi libraryNoDb.cmi libraryMisc.cmi \
+    libraryDb.cmi libraryClean.cmi 
+libraryClean.cmx: librarySync.cmx libraryNoDb.cmx libraryMisc.cmx \
+    libraryDb.cmx libraryClean.cmi 
index c22a61976a4f5a1a04c6235b1c45cf49d81d1b2f..ee07c81629ee9d7b543244f284eec26e3fab62f1 100644 (file)
@@ -9,6 +9,7 @@ INTERFACE_FILES = \
        coercDb.mli \
        librarySync.mli \
        coercGraph.mli \
+       libraryNoDb.mli \
        libraryClean.mli \
        $(NULL)
 IMPLEMENTATION_FILES = \
index a7a3d7345886027bec83229911b6a4928aa84ac0..00f2c4ef0f168e13eecc6c49c701acd502974aae 100644 (file)
@@ -122,10 +122,10 @@ let close_uri_list uri_to_remove =
   in
   uri_to_remove, depend
 
-let rec close_using_db uris next =
+let rec close_db uris next =
   match next with
   | [] -> uris
-  | l -> let uris, next = close_uri_list l in close_using_db uris next @ uris
+  | l -> let uris, next = close_uri_list l in close_db uris next @ uris
   
 let cleaned_no = ref 0;;
 
@@ -145,7 +145,7 @@ let moo_root_dir = lazy (
   String.sub url 7 (String.length url - 7)  (* remove heading "file:///" *)
 )
 
-let close_using_moos buris =
+let close_nodb buris =
   let rev_deps = Hashtbl.create 97 in
   let all_moos =
     HExtlib.find ~test:(fun name -> Filename.check_suffix name ".moo")
@@ -153,11 +153,11 @@ let close_using_moos buris =
   in
   List.iter
     (fun path -> 
-      let _, metadata = GrafiteMarshal.load_moo ~fname:path in
+      let metadata = LibraryNoDb.load_metadata ~fname:path in
       let baseuri_of_current_moo = 
         let rec aux = function 
           | [] -> assert false
-          | GrafiteAst.Baseuri buri::_ -> buri
+          | LibraryNoDb.Baseuri buri::_ -> buri
           | _ :: tl -> aux tl
         in
         aux metadata
@@ -165,7 +165,7 @@ let close_using_moos buris =
       let deps = 
         HExtlib.filter_map 
           (function 
-          | GrafiteAst.Dependency buri -> Some buri
+          | LibraryNoDb.Dependency buri -> Some buri
           | _ -> None ) 
         metadata
       in
@@ -198,9 +198,9 @@ let clean_baseuris ?(verbose=true) ~basedir buris =
     List.iter debug_prerr buris; 
   let l = 
     if Helm_registry.get_bool "db.nodb" then
-      close_using_moos buris
+      close_nodb buris
     else
-      close_using_db [] buris 
+      close_db [] buris 
   in
   let l = HExtlib.list_uniq (List.fast_sort Pervasives.compare l) in
   let l = List.map UriManager.uri_of_string l in
index 2b6d64f6300c1bd887fb9cae119828d5ae7c8832..e953859b6d47bd3152525133bffb00f4b54bb91c 100644 (file)
  * http://helm.cs.unibo.it/
  *)
 
-
 let obj_file_of_baseuri ~basedir ~baseuri =
  let path = basedir ^ "/xml" ^ Pcre.replace ~pat:"^cic:" ~templ:"" baseuri in
   path ^ ".moo"
+
+let metadata_file_of_baseuri ~basedir ~baseuri =
+ let path = basedir ^ "/xml" ^ Pcre.replace ~pat:"^cic:" ~templ:"" baseuri in
+  path ^ ".metadata"
index fc93095ebba2e5a76599544a61475bc61bb05cbb..03a4742c5796125f1210e0076144633a929a8278 100644 (file)
@@ -23,5 +23,6 @@
  * http://helm.cs.unibo.it/
  *)
 
-
 val obj_file_of_baseuri: basedir:string -> baseuri:string -> string
+val metadata_file_of_baseuri: basedir:string -> baseuri:string -> string
+
diff --git a/helm/ocaml/library/libraryNoDb.ml b/helm/ocaml/library/libraryNoDb.ml
new file mode 100644 (file)
index 0000000..12a2e96
--- /dev/null
@@ -0,0 +1,75 @@
+(* Copyright (C) 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/
+ *)
+
+open Printf
+
+exception Checksum_failure of string
+exception Corrupt_metadata of string
+exception Version_mismatch of string
+
+let magic = 1
+
+type metadata =
+  | Dependency of string  (* baseuri without trailing slash *)
+  | Baseuri of string 
+
+let eq_metadata (m1:metadata) (m2:metadata) = m1 = m2
+
+let marshal_flags = []
+
+(** .metadata file format
+ * - an integer -- magic number -- denoting the version of the dumped data
+ *   structure. Different magic numbers stand for incompatible data structures
+ * - an integer -- checksum -- denoting the hash value (computed with
+ *   Hashtbl.hash) of the string representation of the dumped data structur
+ * - marshalled data: list of metadata
+ *)
+
+let save_metadata ~fname metadata =
+  let oc = open_out fname in
+  let marshalled = Marshal.to_string metadata marshal_flags in
+  let checksum = Hashtbl.hash marshalled in
+  output_binary_int oc magic;
+  output_binary_int oc checksum;
+  output_string oc marshalled;
+  close_out oc
+
+let load_metadata ~fname =
+  let ic = open_in fname in
+  HExtlib.finally
+    (fun () -> close_in ic)
+    (fun () ->
+      try
+        let file_magic = input_binary_int ic in
+        if file_magic <> magic then raise (Version_mismatch fname);
+        let file_checksum = input_binary_int ic in
+        let marshalled = HExtlib.input_all ic in
+        let checksum = Hashtbl.hash marshalled in
+        if checksum <> file_checksum then raise (Checksum_failure fname);
+        let (metadata:metadata list) = Marshal.from_string marshalled 0 in
+        metadata
+      with End_of_file -> raise (Corrupt_metadata fname))
+    ()
+
diff --git a/helm/ocaml/library/libraryNoDb.mli b/helm/ocaml/library/libraryNoDb.mli
new file mode 100644 (file)
index 0000000..33b1b1e
--- /dev/null
@@ -0,0 +1,36 @@
+(* Copyright (C) 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/
+ *)
+
+(* TODO the strings below should be UriManager.uri, but UriManager ATM does not
+ * support their format *)
+type metadata =
+  | Dependency of string  (* baseuri without trailing slash *)
+  | Baseuri of string 
+
+val eq_metadata: metadata -> metadata -> bool
+
+val save_metadata: fname:string -> metadata list -> unit
+val load_metadata: fname:string -> metadata list
+