Allows easy debugging printing of Envs.

This commit is contained in:
Leonard Gerard 2011-05-10 20:29:01 +02:00
parent 1d390848fe
commit 75b7ceab5a
2 changed files with 12 additions and 5 deletions

View file

@ -35,12 +35,12 @@ let name id =
id.source
(* used only for debuging *)
let fprint_t ff id = Format.fprintf ff "%s" (name id)
let print_ident ff id = Format.fprintf ff "%s" (name id)
module M = struct
type t = ident
let compare = ident_compare
let fprint = fprint_t
let print_t = print_ident
end
module Env =
@ -67,14 +67,20 @@ struct
else (env1,(add key elt env2)))
env
(empty, empty)
(* Print Env *)
let print_t print_value ff m =
Format.fprintf ff "@[<hov>{@ ";
iter (fun k v -> Format.fprintf ff "%a => %a,@ " M.print_t k print_value v) m;
Format.fprintf ff "}@]";
end
module IdentSet = struct
include (Set.Make(M))
let fprint_t ff s =
let print_t ff s =
Format.fprintf ff "@[<hov>{@ ";
iter (fun e -> Format.fprintf ff "%a@ " M.fprint e) s;
iter (fun e -> Format.fprintf ff "%a,@ " M.print_t e) s;
Format.fprintf ff "}@]";
end

View file

@ -43,11 +43,12 @@ sig
val union : 'a t -> 'a t -> 'a t
val diff : 'a t -> 'b t -> 'a t
val partition : (key -> bool) -> 'a t -> 'a t * 'a t
val print_t : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit
end
(** A set of identifiers. *)
module IdentSet :
sig
include (Set.S with type elt = ident)
val fprint_t : Format.formatter -> t -> unit
val print_t : Format.formatter -> t -> unit
end