(* ||M|| This file is part of HELM, an Hypertextual, Electronic ||A|| Library of Mathematics, developed at the Computer Science ||T|| Department, University of Bologna, Italy. ||I|| ||T|| HELM is free software; you can redistribute it and/or ||A|| modify it under the terms of the GNU General Public License \ / version 2 or (at your option) any later version. \ / This software is distributed as is, NO WARRANTY. V_______________________________________________________________ *) module H = Hashtbl module S = Scanf module C = Cps type graph = string * (int -> int) let sorts = 2 let sort = H.create sorts (* Internal functions *******************************************************) let set_sort h s = H.add sort h s; succ h (* Interface functions ******************************************************) let set_sorts ss i = List.fold_left set_sort i ss let get_sort err f h = try f (H.find sort h) with Not_found -> err () let string_of_graph (s, _) = s let apply (_, g) h = (g h) let graph_of_string err f s = try let x = S.sscanf s "Z%u" C.start in if x > 0 then f (s, fun h -> x + h) else err () with S.Scan_failure _ | Failure _ | End_of_file -> err ()