aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/compat.ml43
-rw-r--r--lib/util.ml9
-rw-r--r--lib/util.mli7
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/compat.ml4 b/lib/compat.ml4
index 5ed8d7a546..c377581527 100644
--- a/lib/compat.ml4
+++ b/lib/compat.ml4
@@ -17,8 +17,7 @@ let unloc loc = Stdpp.first_pos loc, Stdpp.last_pos loc
let join_loc loc1 loc2 =
if loc1 = dummy_loc or loc2 = dummy_loc then dummy_loc
else Stdpp.encl_loc loc1 loc2
-type token = string*string
-type lexer = token Token.glexer
+type lexer = Tok.t Token.glexer
ELSE (* official camlp4 of ocaml >= 3.10 *)
diff --git a/lib/util.ml b/lib/util.ml
index a70278d575..d08727d27e 100644
--- a/lib/util.ml
+++ b/lib/util.ml
@@ -1115,6 +1115,15 @@ let array_rev_to_list a =
if i >= Array.length a then res else tolist (i+1) (a.(i) :: res) in
tolist 0 []
+(* Stream *)
+
+let stream_nth n st =
+ try List.nth (Stream.npeek (n+1) st) n
+ with Failure _ -> raise Stream.Failure
+
+let stream_njunk n st =
+ for i = 1 to n do Stream.junk st done
+
(* Matrices *)
let matrix_transpose mat =
diff --git a/lib/util.mli b/lib/util.mli
index f7f40b8056..9cef982fb3 100644
--- a/lib/util.mli
+++ b/lib/util.mli
@@ -269,7 +269,12 @@ val array_distinct : 'a array -> bool
val array_union_map : ('a -> 'b -> 'b) -> 'a array -> 'b -> 'b
val array_rev_to_list : 'a array -> 'a list
-(** {6 Matrices } *)
+(** {6 Streams. } *)
+
+val stream_nth : int -> 'a Stream.t -> 'a
+val stream_njunk : int -> 'a Stream.t -> unit
+
+(** {6 Matrices. } *)
val matrix_transpose : 'a list list -> 'a list list