package grace

  1. Overview
  2. Docs
type t = {
  1. idx : Grace.Line_index.t;
  2. range : Grace.Range.t;
}

The type of a line.

include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
val of_line_index : Source_descr.t -> Grace.Line_index.t -> t

of_line_index sd idx returns the line at index idx in source sd.

val of_byte_index : Source_descr.t -> Grace.Byte_index.t -> t

of_byte_index sd idx returns the line containing idx in source sd.

val start : t -> Grace.Byte_index.t

start t returns the byte index of the (inclusive) start position of the line.

val stop : t -> Grace.Byte_index.t

stop t returns the byte index of the (exclusive) stop position of the line.

split t returns the pair of byte indices of the line t.

val last : Source_descr.t -> t

last sd returns the last line in the source sd.

val slice : t -> sd:Source_descr.t -> string

slice t ~sd reads the slice of bytes defined by the line's range.

  • raises Invalid_argment

    if the source descriptor's underlying source is not equal to the line range's source.

OCaml

Innovation. Community. Security.