Commits

Sébastien Ferré  committed 65edebd

Ocamldoc.

  • Participants
  • Parent commits fe147dc

Comments (0)

Files changed (1)

-(*
-   Useful code for representation and managing of terms.
-   To be used by logic modules, Node and Context.
-*)
+(** Utility code for the representation and managing of taxonomic relations over terms. *)
 
 open Token
 
   }
 
 (* dictionary of terms *)
-let tbl : (string,t) Hashtbl.t ref = ref (Hashtbl.create 1000)
+let tbl : (string,t) Hashtbl.t = Hashtbl.create 1000
 
 (* load and save *)
 
-type data = (string,t) Hashtbl.t
+type data = (string * t) list
 
 let init () =
-  Hashtbl.clear !tbl
+  Hashtbl.clear tbl
 
 let load (t : data) =
-  tbl := t
+  Hashtbl.clear tbl;
+  List.iter (fun (name,x) -> Hashtbl.add tbl name x) t
 
-let save () = (!tbl : data)
+let save () =
+  let t = Hashtbl.fold (fun name x l -> (name,x)::l) tbl [] in
+  (t : data)
 
 (* Invariants
    - a term absent from tbl has all fields equal to []
 (* get data about a term *)
 let get : string -> t =
   fun name ->
-    try Hashtbl.find !tbl name
+    try Hashtbl.find tbl name
     with Not_found ->
       let data = {version = 0; sufs = []; necs = []; dep = []} in
-      Hashtbl.add !tbl name data; data
+      Hashtbl.add tbl name data; data
 
 let get_sufs : string -> Syntax.t_list list =
   fun name -> (get name).sufs