Module B0_tlex.Tloc

Text locations.

Text locations

val no_file : B0_std.Fpath.t

no_file is Fpath.t "-", a path used when no file is specified.

type pos = int

The type for zero-based, absolute, byte positions in text.

type line = int

The type for one-based, line numbers in the text. Usually lines increment after a line feed '\n' (U+000A), a carriage return '\r' (U+000D) or a carriage return and a line feed "\r\n" (<U+000D,U+000A>).

type t

The type for text locations. A text location is a range of byte positions and the lines on which they occur in the UTF-8 encoded text of a particular file.

val v : file:B0_std.Fpath.t -> byte_s:pos -> byte_e:pos -> line_s:(pos * line) -> line_e:(pos * line) -> t

v ~file ~byte_s ~byte_e ~line_s ~line_e is a contructor for text locations. See corresponding accessors for the semantics. If you don't have a file use no_file.

val file : t -> B0_std.Fpath.t

file l is l's file.

val byte_s : t -> pos

byte_s l is l's start position.

val byte_e : t -> pos

byte_e l is l's end position.

val line_s : t -> pos * line

line_s l is the line's position on which byte_s l lies and the one-based line number.

val line_e : t -> pos * line

line_e l is the line's position on which byte_e l lies and the one-based line number.

val nil : t

loc_nil is an invalid location.

val merge : t -> t -> t

merge l0 l1 merges the location l0 and l1 to the smallest location that spans both location. The file path is l0's.

val to_start : t -> t

to_start l has both start and end positions at l's start.

val to_end : t -> t

to_end l has both start and end positions at l's end.

val with_start : t -> t -> t

with_start s l is l with the start position of s.

val pp : t B0_std.Fmt.t

pp_loc formats locations using the GNU convention.