From ba524ddfaabc80b31a439544de46c40366565ae8 Mon Sep 17 00:00:00 2001 From: ppedrot Date: Fri, 6 Sep 2013 17:18:44 +0000 Subject: Moving Searchstack to CStack, and normalizing names a bit. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16765 85f007b7-540e-0410-9357-904b9bb8a0f7 --- lib/cSig.mli | 15 ++++++++++++++ lib/cStack.ml | 35 ++++++++++++++++++++++++++++++++ lib/cStack.mli | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/clib.mllib | 1 + lib/lib.mllib | 1 - lib/searchstack.ml | 25 ----------------------- lib/searchstack.mli | 25 ----------------------- lib/util.ml | 7 ++++++- lib/util.mli | 10 ++++++++- 9 files changed, 124 insertions(+), 53 deletions(-) create mode 100644 lib/cSig.mli create mode 100644 lib/cStack.ml create mode 100644 lib/cStack.mli delete mode 100644 lib/searchstack.ml delete mode 100644 lib/searchstack.mli (limited to 'lib') diff --git a/lib/cSig.mli b/lib/cSig.mli new file mode 100644 index 0000000000..4858d16c37 --- /dev/null +++ b/lib/cSig.mli @@ -0,0 +1,15 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* 'a t +(** Create an empty stack. *) + +val push : 'a -> 'a t -> unit +(** Add an element to a stack. *) + +val find : ('a -> bool) -> 'a t -> 'a +(** Find the first element satisfying the predicate. + @raise Not_found it there is none. *) + +val find_map : ('a -> 'b option) -> 'a t -> 'b +(** Find the first element that returns [Some _]. + @raise Not_found it there is none. *) + +val seek : ('c -> 'a -> ('b, 'c) seek) -> 'c -> 'a t -> 'b +(** Find the first element that returns [Some _]. + @raise Not_found it there is none. *) + +val is_empty : 'a t -> bool +(** Whether a stack is empty. *) + +val iter : ('a -> unit) -> 'a t -> unit +(** Iterate a function over elements, from the last added one. *) + +val clear : 'a t -> unit +(** Empty a stack. *) + +val length : 'a t -> int +(** Length of a stack. *) + +val pop : 'a t -> 'a +(** Remove and returns the first element of the stack. + @raise Empty if empty. *) + +val top : 'a t -> 'a +(** Remove the first element of the stack without modifying it. + @raise Empty if empty. *) + +val to_list : 'a t -> 'a list +(** Convert to a list. *) + diff --git a/lib/clib.mllib b/lib/clib.mllib index 30821492ea..833182bcea 100644 --- a/lib/clib.mllib +++ b/lib/clib.mllib @@ -19,6 +19,7 @@ CObj CList CString CArray +CStack Util Loc Flags diff --git a/lib/lib.mllib b/lib/lib.mllib index 9f29613d19..f45c34610a 100644 --- a/lib/lib.mllib +++ b/lib/lib.mllib @@ -2,7 +2,6 @@ Xml_lexer Xml_parser Xml_printer Errors -Searchstack Bigint Dyn Segmenttree diff --git a/lib/searchstack.ml b/lib/searchstack.ml deleted file mode 100644 index 8d160e5723..0000000000 --- a/lib/searchstack.ml +++ /dev/null @@ -1,25 +0,0 @@ -(************************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* raise Stack.Empty | x::xs -> l := xs; x -let top l = match !l with [] -> raise Stack.Empty | x::_ -> x -let find f i l = - let rec aux i = function - | [] -> raise Not_found - | x::xs -> match f i x with `Stop x -> x | `Cont i -> aux i xs in - aux i !l -let is_empty l = match !l with [] -> true | _ -> false -let iter f l = List.iter f !l -let clear l = l := [] -let length l = List.length !l -let to_list l = !l diff --git a/lib/searchstack.mli b/lib/searchstack.mli deleted file mode 100644 index 6c81a2a9c9..0000000000 --- a/lib/searchstack.mli +++ /dev/null @@ -1,25 +0,0 @@ -(************************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* 'a t -val push : 'a -> 'a t -> unit -val find : ('c -> 'a -> ('c, 'b) search) -> 'c -> 'a t -> 'b -val is_empty : 'a t -> bool -val iter : ('a -> unit) -> 'a t -> unit -val clear : 'a t -> unit -val length : 'a t -> int - -(* may raise Stack.Empty *) -val pop : 'a t -> 'a -val top : 'a t -> 'a - -(* Extra *) -val to_list : 'a t -> 'a list diff --git a/lib/util.ml b/lib/util.ml index b7364cbc53..2db11131da 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -69,6 +69,10 @@ module Array : CArray.ExtS = CArray module Map = CMap +(* Stacks *) + +module Stack = CStack + (* Matrices *) let matrix_transpose mat = @@ -118,7 +122,8 @@ let delayed_force f = f () (* Misc *) -type ('a,'b) union = Inl of 'a | Inr of 'b +type ('a, 'b) union = ('a, 'b) CSig.union = Inl of 'a | Inr of 'b +type ('a, 'b) seek = ('a, 'b) CSig.seek = Stop of 'a | Next of 'b (*s interruption *) diff --git a/lib/util.mli b/lib/util.mli index 72217fd0ef..8dec93e309 100644 --- a/lib/util.mli +++ b/lib/util.mli @@ -63,6 +63,10 @@ module Array : CArray.ExtS module Map : module type of CMap +(** {6 Stacks.} *) + +module Stack : module type of CStack + (** {6 Streams. } *) val stream_nth : int -> 'a Stream.t -> 'a @@ -90,7 +94,11 @@ val delayed_force : 'a delayed -> 'a (** {6 Misc. } *) -type ('a, 'b) union = Inl of 'a | Inr of 'b +type ('a, 'b) union = ('a, 'b) CSig.union = Inl of 'a | Inr of 'b +(** Union type *) + +type ('a, 'b) seek = ('a, 'b) CSig.seek = Stop of 'a | Next of 'b +(** Type isomorphic to union used for browsable structures. *) (** {6 ... } *) (** Coq interruption: set the following boolean reference to interrupt Coq -- cgit v1.2.3