Debian Codegraph @

gramlib/lStream.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** Extending streams with a (non-canonical) location function *)
12
13 type ('e,'a) t
14 val from : ?loc:Loc.t -> ('e -> ('a * Loc.t) option) -> ('e,'a) t
15
16 (** Returning the loc of the last consumed element or the initial loc
17 if no element is consumed *)
18 val current_loc : ('e,'a) t -> Loc.t
19
20 (** Returning the loc of the max visited element or the initial loc
21 if no element is consumed *)
22 val max_peek_loc : ('e,'a) t -> Loc.t
23
24 (** [interval_loc bp ep strm] returns the loc starting after element
25 [bp] (counting from 0) and spanning up to already peeked element
26 at position [ep], under the assumption that [bp] <= [ep]; returns
27 an empty interval if [bp] = [ep]; returns the empty initial
28 interval if additionally [bp] = 0; fails if the elements have not
29 been peeked yet *)
30 val interval_loc : int -> int -> ('e,'a) t -> Loc.t
31
32 (** Return location of an already peeked element at some position counting from 0;
33 fails if the element has not been peeked yet *)
34 val get_loc : int -> ('e,'a) t -> Loc.t
35
36 (** Lifted usual function on streams *)
37
38 val count : ('e,'a) t -> int
39
40 val peek : 'e -> ('e,'a) t -> 'a option
41
42 val npeek : 'e -> int -> ('e,'a) t -> 'a list
43
44 val junk : 'e -> ('e,'a) t -> unit
45 (** consumes the next element if there is one *)
46
47 val njunk : 'e -> int -> ('e,'a) t -> unit
48 (** [njunk e n strm] consumes [n] elements from [strm] *)
49
50 val next : 'e -> ('e,'a) t -> 'a option
51 (** [next e strm] returns and consumes the next element;
52 [None] if the stream is empty *)
53
54 (** Other functions *)
55
56 val peek_nth : 'e -> int -> ('e,'a) t -> 'a option
57 (** [peek_nth e n strm] returns the nth element counting from 0 without
58 consuming the stream; [None] if not enough elements *)