Commit 624aece4 authored by Pietro Abate's avatar Pietro Abate

[r2005-01-28 14:28:55 by afrisch] Standalone cduce_types library

Original author: afrisch
Date: 2005-01-28 14:29:12+00:00
parent 00a3e244
......@@ -148,7 +148,8 @@ OBJECTS = \
misc/html.cmo \
\
types/sortedList.cmo types/boolean.cmo types/ident.cmo \
types/intervals_int.cmo types/intervals.cmo types/chars.cmo types/atoms.cmo \
types/intervals.cmo \
types/chars.cmo types/atoms.cmo \
types/normal.cmo \
types/types.cmo types/sample.cmo types/sequence.cmo types/patterns.cmo \
types/builtin_defs.cmo \
......
DIRS= misc types
SRC= \
misc/serialize.mli \
misc/serialize.ml \
misc/custom.ml \
misc/custom.ml \
misc/encodings.mli \
misc/encodings.ml \
misc/imap.mli \
misc/imap.ml \
misc/state.mli \
misc/state.ml \
misc/pool.mli \
misc/pool.ml \
misc/ns.mli \
misc/ns.ml \
types/sortedList.mli \
types/sortedList.ml \
types/atoms.mli \
types/atoms.ml \
misc/bool.mli \
misc/bool.ml \
types/chars.mli \
types/chars.ml \
types/ident.ml \
types/intervals.mli \
types/intervals.ml \
misc/inttbl.mli \
misc/inttbl.ml \
types/normal.mli \
types/normal.ml \
misc/pretty.mli \
misc/pretty.ml \
misc/stats.mli \
misc/stats.ml \
types/ident.ml \
types/types.mli \
types/types.ml
ML_SRC=$(filter %.ml,$(SRC))
OBJECTS=$(ML_SRC:.ml=.$(EXT))
CAMLC=ocamlc
CAMLOPT=ocamlopt
ifeq ($(NATIVE),true)
EXT=cmx
EXTA=cmxa
CAML=$(CAMLOPT)
else
EXT=cmo
EXTA=cma
CAML=$(CAMLC)
endif
cduce_types: $(OBJECTS)
$(CAML) -pack -o cduce_types.$(EXT) $(INCLUDES) $^
$(CAML) -a -o cduce_types.$(EXTA) $(INCLUDES) cduce_types.$(EXT)
HIDE=@
INCLUDES = $(DIRS:%=-I %)
types/intervals.$(EXT): types/intervals.ml cat1
$(CAML) -c $(INCLUDES) -pp './cat1 types/intervals_int.ml' $<
types/intervals.cmi: types/intervals.mli cat1
$(CAML) -c $(INCLUDES) -pp './cat1 types/intervals_int.mli' $<
misc/stats.$(EXT): misc/stats.ml
$(CAML) -c $(INCLUDES) -pp 'sed s/Unix\\.gettimeofday\(\)/0./' $<
cat1:
echo "cat \$$1" > cat1
chmod +x cat1
.SUFFIXES: .ml .mli .cmo .cmi .cmx
.ml.cmo:
@echo "Build $@"
$(HIDE)$(CAMLC) -c $(INCLUDES) $<
.ml.cmx:
@echo "Build $@"
$(HIDE)$(CAMLOPT) -c $(INCLUDES) $<
.mli.cmi:
@echo "Build $@"
$(HIDE)$(CAMLC) -c $(INCLUDES) $<
.PHONY: compute_depend
compute_depend:
ocamldep $(INCLUDES) $(SRC) > types_depend
include types_depend
clean:
for i in $(DIRS); do \
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
done
This diff is collapsed.
......@@ -38,7 +38,7 @@ module Timer = struct
let stop c x =
assert(c.is_in);
c.is_in <- false;
c.total <- c.total +. (Unix.gettimeofday () -. c.last);
c.total <- c.total +. (Unix.gettimeofday() -. c.last);
x
end
......
module V = struct
include Custom.Int
let print ppf i = Format.fprintf ppf "%i" i
let from_int i = i
let mk = int_of_string
let to_string = string_of_int
let get_int i = i
let is_int _ = true
let add = (+)
let mult = ( * )
let sub = (-)
let div = (/)
let modulo = (mod)
let succ = succ
let pred = pred
let lt (x:int) y = x < y
let gt (x:int) y = x > y
let zero = 0
let one = 1
let minus_one = (-1)
let is_zero = (=) 0
end
module I = Custom.Pair(Custom.Int)(Custom.Int)
module IL = Custom.List(I)
include IL
let empty = []
let any = [min_int,max_int]
let bounded (a:int) b = if (a <= b) then [a,b] else []
let left a = [min_int,a]
let right a = [a,max_int]
let atom a = [a,a]
let rec iadd l ((a,b) as i) = match l with
| [] -> [a,b]
| (a1,_) :: _ when (b < pred a1) && (a1 > min_int) ->
(a,b)::l
| ((_,b1) as i') :: l' when (succ b1 < a) && (b1 < max_int) ->
i'::(iadd l' i)
| (a1,b1) :: l' -> iadd l' (min a a1, max b b1)
let rec neg' start l = match l with
| [] -> [start,max_int]
| [a,b] when b = max_int -> if (a > start) then [start, pred a] else []
| (a,b) :: l' -> if (a > start) then (start, pred a) :: (neg' (succ b) l')
else neg' (succ b) l'
let neg l = neg' min_int l
let cup i1 i2 =
List.fold_left iadd i1 i2
let cap i1 i2 =
neg (cup (neg i1) (neg i2))
let diff i1 i2 =
neg (cup (neg i1) i2)
let is_empty = function [] -> true | _ -> false
let rec disjoint a b =
match (a,b) with
| [],_ | _,[] -> true
| (xa,ya) :: a', (xb,yb) :: b' ->
let c = V.compare xa xb in
if c = 0 then false
else
if c < 0 then (ya < xb) && (disjoint a' b)
else (yb < xa) && (disjoint a b')
(* TODO: can optimize this to stop running through the list earlier *)
let contains n = List.exists (fun (a,b) -> (a <= n) && (n <= b))
let sample = function (x,_) :: _ -> x | [] -> raise Not_found
let single = function
| [ (x,y) ] when (x:int) = y -> x
| [] -> raise Not_found
| _ -> raise Exit
let print =
List.map
(fun (a,b) ppf ->
if (a=b) then Format.fprintf ppf "%i" a
else match (a=min_int,b=max_int) with
| true,true -> Format.fprintf ppf "Int"
| false,false -> Format.fprintf ppf "%i--%i" a b
| true,false -> Format.fprintf ppf "*--%i" b
| false,true -> Format.fprintf ppf "%i--*" a
)
let add l1 l2 = any
let negat l = any
let sub l1 l2 = any
let mul l1 l2 = any
module V : sig
include Custom.T
val print : Format.formatter -> t -> unit
val mk: string -> t
val from_int: int -> t
val to_string: t -> string
val is_int: t -> bool
val get_int: t -> int
val is_zero: t -> bool
val add: t -> t -> t
val mult: t -> t -> t
val sub: t -> t -> t
val div: t -> t -> t
val modulo: t -> t -> t
val succ: t -> t
val pred: t -> t
val lt: t -> t -> bool
val gt: t -> t -> bool
val zero : t
val one : t
val minus_one : t
end
include Custom.T
val print : t -> (Format.formatter -> unit) list
val empty : t
val any : t
val cup : t -> t -> t
val cap : t -> t -> t
val diff : t -> t -> t
(** closed interval *)
val bounded : V.t -> V.t -> t
(** left opened interval (i.e. * -- something ) *)
val left : V.t -> t
(** right opened interval (i.e. something -- * ) *)
val right : V.t -> t
val atom : V.t -> t
val disjoint : t -> t -> bool
val is_empty : t -> bool
val contains : V.t -> t -> bool
val sample : t -> V.t
val single : t -> V.t
(* raise Not_found if empty.
raise Exit if empty and not singleton *)
val add : t -> t -> t
val mul : t -> t -> t
val sub : t -> t -> t
val negat : t -> t
misc/serialize.cmo: misc/serialize.cmi
misc/serialize.cmx: misc/serialize.cmi
misc/custom.cmo: misc/serialize.cmi
misc/custom.cmx: misc/serialize.cmx
misc/custom.cmo: misc/serialize.cmi
misc/custom.cmx: misc/serialize.cmx
misc/encodings.cmi: misc/custom.cmo misc/serialize.cmi
misc/encodings.cmo: misc/custom.cmo misc/serialize.cmi misc/encodings.cmi
misc/encodings.cmx: misc/custom.cmx misc/serialize.cmx misc/encodings.cmi
misc/imap.cmo: misc/imap.cmi
misc/imap.cmx: misc/imap.cmi
misc/state.cmo: misc/state.cmi
misc/state.cmx: misc/state.cmi
misc/pool.cmi: misc/custom.cmo
misc/pool.cmo: misc/custom.cmo misc/serialize.cmi misc/state.cmi \
misc/pool.cmi
misc/pool.cmx: misc/custom.cmx misc/serialize.cmx misc/state.cmx \
misc/pool.cmi
misc/ns.cmi: misc/custom.cmo misc/encodings.cmi misc/serialize.cmi
misc/ns.cmo: misc/custom.cmo misc/encodings.cmi misc/pool.cmi \
misc/serialize.cmi misc/state.cmi misc/ns.cmi
misc/ns.cmx: misc/custom.cmx misc/encodings.cmx misc/pool.cmx \
misc/serialize.cmx misc/state.cmx misc/ns.cmi
types/sortedList.cmi: misc/custom.cmo misc/serialize.cmi
types/sortedList.cmo: misc/custom.cmo misc/serialize.cmi types/sortedList.cmi
types/sortedList.cmx: misc/custom.cmx misc/serialize.cmx types/sortedList.cmi
types/atoms.cmi: misc/custom.cmo misc/encodings.cmi misc/ns.cmi
types/atoms.cmo: misc/custom.cmo misc/encodings.cmi misc/imap.cmi misc/ns.cmi \
misc/pool.cmi types/sortedList.cmi types/atoms.cmi
types/atoms.cmx: misc/custom.cmx misc/encodings.cmx misc/imap.cmx misc/ns.cmx \
misc/pool.cmx types/sortedList.cmx types/atoms.cmi
misc/bool.cmi: misc/custom.cmo
misc/bool.cmo: misc/custom.cmo misc/serialize.cmi misc/bool.cmi
misc/bool.cmx: misc/custom.cmx misc/serialize.cmx misc/bool.cmi
types/chars.cmi: misc/custom.cmo
types/chars.cmo: misc/custom.cmo types/chars.cmi
types/chars.cmx: misc/custom.cmx types/chars.cmi
types/ident.cmo: misc/encodings.cmi misc/ns.cmi misc/pool.cmi \
types/sortedList.cmi
types/ident.cmx: misc/encodings.cmx misc/ns.cmx misc/pool.cmx \
types/sortedList.cmx
types/intervals.cmi: misc/custom.cmo
types/intervals.cmo: misc/serialize.cmi types/intervals.cmi
types/intervals.cmx: misc/serialize.cmx types/intervals.cmi
types/intervals.cmo: misc/serialize.cmi types/intervals.cmi
types/intervals.cmx: misc/serialize.cmx types/intervals.cmi
misc/inttbl.cmo: misc/inttbl.cmi
misc/inttbl.cmx: misc/inttbl.cmi
types/normal.cmo: types/normal.cmi
types/normal.cmx: types/normal.cmi
misc/pretty.cmo: misc/pretty.cmi
misc/pretty.cmx: misc/pretty.cmi
misc/stats.cmo: misc/stats.cmi
misc/stats.cmx: misc/stats.cmi
types/ident.cmo: misc/encodings.cmi misc/ns.cmi misc/pool.cmi \
types/sortedList.cmi
types/ident.cmx: misc/encodings.cmx misc/ns.cmx misc/pool.cmx \
types/sortedList.cmx
types/types.cmi: types/atoms.cmi types/chars.cmi misc/custom.cmo \
types/ident.cmo types/intervals.cmi misc/inttbl.cmi misc/ns.cmi
types/types.cmo: types/atoms.cmi misc/bool.cmi types/chars.cmi \
misc/custom.cmo misc/encodings.cmi types/ident.cmo types/intervals.cmi \
misc/inttbl.cmi types/normal.cmi misc/pool.cmi misc/pretty.cmi \
misc/serialize.cmi types/sortedList.cmi misc/state.cmi misc/stats.cmi \
types/types.cmi
types/types.cmx: types/atoms.cmx misc/bool.cmx types/chars.cmx \
misc/custom.cmx misc/encodings.cmx types/ident.cmx types/intervals.cmx \
misc/inttbl.cmx types/normal.cmx misc/pool.cmx misc/pretty.cmx \
misc/serialize.cmx types/sortedList.cmx misc/state.cmx misc/stats.cmx \
types/types.cmi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment