Module Grace.Byte_indexSource

Sourcetype t = private int

The type of indexes. An integer with the invariant that an index t satisfies t >= 0.

include Sexplib0.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
include Grace_std.Comparable.S with type t := t
Sourceval (>=) : t -> t -> bool
Sourceval (<=) : t -> t -> bool
Sourceval (>) : t -> t -> bool
Sourceval (<) : t -> t -> bool
Sourceval (=) : t -> t -> bool
Sourceval (<>) : t -> t -> bool
Sourceval compare : t -> t -> int
Sourceval equal : t -> t -> bool
Sourceval min : t -> t -> t
Sourceval max : t -> t -> t
include Grace_std.Pretty_printer.S with type t := t
Sourceval pp : t Fmt.t
Sourceval to_string : t -> string
Sourceval of_int : int -> t

of_int n creates the index n.

Sourceval initial : t

initial is the initial index, namely 0.

Sourceval add : t -> int -> t

add t off adds the offset off to the index t.

Sourceval sub : t -> int -> t

sub t off subtracts the offset off from the index t.

Sourceval diff : t -> t -> int

diff t1 t2 returns the (potentially negative) difference between t1 and t2.

Support for Lexing

Sourceval of_lex : Lexing.position -> t

of_lex lex_pos returns the byte index from the lexing position lex_pos. It is equivalent to create (lex_pos.pos_cnum).