cherry pick from local- branch
[SXSI/xpathcomp.git] / tagSet.ml
1 (* module Ptset = 
2 struct 
3   include Set.Make (struct type t = int let compare = (-) end)
4   let hash = Hashtbl.hash
5 end
6   *)
7 module M  : FiniteCofinite.S with type elt = Tag.t and type set = Ptset.Int.t =
8   FiniteCofinite.Make(Ptset.Int)
9 include M
10
11
12 let tag t = singleton t
13 let pcdata = singleton Tag.pcdata
14 let attribute = singleton Tag.attribute
15 let star = diff any (cup pcdata attribute)
16 let node = neg attribute
17
18 let print ppf t = 
19   let print_set s = 
20     Format.fprintf ppf "{";
21     Ptset.Int.iter 
22       (fun t -> Format.fprintf ppf "'%s' " (Tag.to_string t))      
23       s;
24     Format.fprintf ppf "}"
25   in
26   if is_finite t then
27        if is_empty t then
28        Format.fprintf ppf "∅" else  print_set (positive t)
29   else
30   Format.fprintf ppf "Σ";
31   if not (is_any t) then
32   (Format.fprintf ppf "\\" ; print_set (negative t))