Project

General

Profile

Download (1009 Bytes) Statistics
| Branch: | Tag: | Revision:
1
open Basetypes
2

    
3
(* Module to manipulate set of active states.
4

    
5
   It relies on sets of path to represent active ones. *)
6

    
7
(*******************************)
8
module Vars = struct
9
  include Set.Make (struct
10
    type t = path_t
11

    
12
    let compare = compare
13
  end)
14

    
15
  let pp_set fmt rho =
16
    Format.fprintf fmt "@[<v 0>%a@ @]"
17
      (Utils.fprintf_list ~sep:"@ " (fun fmt p ->
18
           Format.fprintf fmt "%a" pp_path p))
19
      (elements rho)
20
end
21

    
22
module Env = struct
23
  include Map.Make (struct
24
    type t = path_t
25

    
26
    let compare = compare
27
  end)
28

    
29
  let from_set s default = Vars.fold (fun e m -> add e default m) s empty
30

    
31
  let find a b =
32
    try find a b
33
    with Not_found ->
34
      Format.printf "Looking for %a@." pp_path a;
35
      raise Not_found
36

    
37
  let keys a = fold (fun key _ -> Vars.add key) a Vars.empty
38

    
39
  let pp_env fmt rho =
40
    Format.fprintf fmt "@[<v 0>%a@ @]"
41
      (Utils.fprintf_list ~sep:"@ " (fun fmt (p, b) ->
42
           Format.fprintf fmt "%a -> %b" pp_path p b))
43
      (bindings rho)
44
end
(1-1/3)