2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
16 type graph = string * (int -> int)
19 let sort = H.create sorts
22 (* Internal functions *******************************************************)
24 let set_sort f (h:int) (s:string) =
25 H.add sort h s; f (succ h)
27 (* Interface functions ******************************************************)
29 let set_new_sorts f ss =
30 let f i = index := i; f i in
31 C.list_fold_left f set_sort !index ss
34 try f (Some (H.find sort h))
35 with Not_found -> f None
37 let string_of_graph f (s, _) = f s
39 let apply f (_, g) h = f (g h)
41 let graph_of_string f s =
43 let x = S.sscanf s "Z%u" C.start in
44 if x > 0 then f (Some (s, fun h -> x + h)) else f None
46 S.Scan_failure _ | Failure _ | End_of_file -> f None
49 ref (graph_of_string (function Some g -> g | None -> assert false) "Z2")