1 (***********************************************************************)
5 (* Luc Maranget, Jerome Vouillon projet Cristal, *)
6 (* INRIA Rocquencourt *)
8 (* Copyright 2002 Institut National de Recherche en Informatique et *)
9 (* en Automatique. All rights reserved. This file is distributed *)
10 (* under the terms of the Q Public License version 1.0. *)
12 (***********************************************************************)
14 (* $Id: cset.ml 6269 2004-04-29 11:12:49Z maranget $ *)
19 type t = (int * int) list
23 let is_empty = function
27 let singleton c = [c,c]
30 if c1 <= c2 then [c1,c2]
34 let rec union s1 s2 = match s1,s2 with
37 | (c1,d1) as p1::r1, (c2,d2)::r2 ->
40 else begin (* c1 <= c2 *)
44 union ((c1,d2)::r2) r1
49 let rec inter l l' = match l, l' with
52 | (c1, c2)::r, (c1', c2')::r' ->
58 (max c1 c1', c2)::inter r l'
60 (max c1 c1', c2')::inter l r'
62 let rec diff l l' = match l, l' with
65 | (c1, c2)::r, (c1', c2')::r' ->
71 let r'' = if c2' < c2 then (c2' + 1, c2) :: r else r in
73 (c1, c1' - 1)::diff r'' r'
78 let eof = singleton 256
79 and all_chars = interval 0 255
80 and all_chars_eof = interval 0 256
82 let complement s = diff all_chars s
84 let env_to_array env = match env with
87 let res = Array.create 257 x in