aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorfilliatr1999-12-02 16:43:08 +0000
committerfilliatr1999-12-02 16:43:08 +0000
commit162fc39bcc36953402d668b5d7ac7b88c9966461 (patch)
tree764403e3752e1c183ecf6831ba71e430a4b3799b /lib
parent33019e47a55caf3923d08acd66077f0a52947b47 (diff)
modifs pour premiere edition de liens
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@189 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
-rw-r--r--lib/util.ml14
-rw-r--r--lib/util.mli8
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml
index 0cab4540e2..e1e524cf4a 100644
--- a/lib/util.ml
+++ b/lib/util.ml
@@ -13,6 +13,12 @@ exception UserError of string * std_ppcmds (* User errors *)
let error string = raise (UserError(string,[< 'sTR string >]))
let errorlabstrm l pps = raise (UserError(l,pps))
+(* raising located exceptions *)
+type loc = int * int
+let anomaly_loc (loc,s,strm) = Stdpp.raise_with_loc loc (Anomaly (s,strm))
+let user_err_loc (loc,s,strm) = Stdpp.raise_with_loc loc (UserError (s,strm))
+let invalid_arg_loc (loc,s) = Stdpp.raise_with_loc loc (Invalid_argument s)
+
(* Strings *)
let explode s =
@@ -214,6 +220,14 @@ let list_share_tails l1 l2 =
in
shr_rev [] (List.rev l1, List.rev l2)
+let list_except_assoc e =
+ let rec except_e = function
+ | [] -> []
+ | (x,_ as y)::l -> if x=e then l else y::except_e l
+ in
+ except_e
+
+
(* Arrays *)
let array_exists f v =
diff --git a/lib/util.mli b/lib/util.mli
index a3a20aaacf..2060b73758 100644
--- a/lib/util.mli
+++ b/lib/util.mli
@@ -19,6 +19,12 @@ exception UserError of string * std_ppcmds
val error : string -> 'a
val errorlabstrm : string -> std_ppcmds -> 'a
+type loc = int * int
+
+val anomaly_loc : loc * string * std_ppcmds -> 'a
+val user_err_loc : loc * string * std_ppcmds -> 'a
+val invalid_arg_loc : loc * string -> 'a
+
(*s Strings. *)
val explode : string -> string list
@@ -63,6 +69,8 @@ val list_map_append : ('a -> 'b list) -> 'a list -> 'b list
(* raises [Invalid_argument] if the two lists don't have the same length *)
val list_map_append2 : ('a -> 'b -> 'c list) -> 'a list -> 'b list -> 'c list
val list_share_tails : 'a list -> 'a list -> 'a list * 'a list * 'a list
+val list_except_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
+
(*s Arrays. *)