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
21 (* Internal functions *******************************************************)
23 let set_sort f (h:int) (s:string) =
24 H.add sort h s; f (succ h)
26 (* Interface functions ******************************************************)
28 let set_sorts f ss i =
29 C.list_fold_left f set_sort i ss
31 let get_sort err f h =
32 try f (H.find sort h) with Not_found -> err ()
34 let string_of_graph f (s, _) = f s
36 let apply f (_, g) h = f (g h)
38 let graph_of_string err f s =
40 let x = S.sscanf s "Z%u" C.start in
41 if x > 0 then f (s, fun h -> x + h) else err ()
43 S.Scan_failure _ | Failure _ | End_of_file -> err ()