X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fcommon%2Fhierarchy.ml;h=375390bdca10aec79410cef305c2345c2a6735e2;hb=f7bb626faf6b9d89c0ee5ac48b1d97c69d189f8a;hp=f916e1e4316671761f0218d76f11b84ee40bd30f;hpb=c8011c7ad75be5d03c4d4bb2e6900af32ad65c07;p=helm.git diff --git a/helm/software/lambda-delta/common/hierarchy.ml b/helm/software/lambda-delta/common/hierarchy.ml index f916e1e43..375390bdc 100644 --- a/helm/software/lambda-delta/common/hierarchy.ml +++ b/helm/software/lambda-delta/common/hierarchy.ml @@ -16,8 +16,7 @@ module C = Cps type graph = string * (int -> int) let sorts = 2 -let sort = H.create sorts -let index = ref 0 +let sort = H.create sorts (* Internal functions *******************************************************) @@ -26,24 +25,19 @@ let set_sort f (h:int) (s:string) = (* Interface functions ******************************************************) -let set_new_sorts f ss = - let f i = index := i; f i in - C.list_fold_left f set_sort !index ss +let set_sorts f ss i = + C.list_fold_left f set_sort i ss -let get_sort f h = - try f (Some (H.find sort h)) - with Not_found -> f None +let get_sort err f h = + try f (H.find sort h) with Not_found -> err () let string_of_graph f (s, _) = f s let apply f (_, g) h = f (g h) -let graph_of_string f s = +let graph_of_string err f s = try let x = S.sscanf s "Z%u" C.start in - if x > 0 then f (Some (s, fun h -> x + h)) else f None + if x > 0 then f (s, fun h -> x + h) else err () with - S.Scan_failure _ | Failure _ | End_of_file -> f None - -let graph = - ref (graph_of_string (function Some g -> g | None -> assert false) "Z2") + S.Scan_failure _ | Failure _ | End_of_file -> err ()