Jsont.TextlocText locations.
A text location identifies a text span in a given UTF-8 encoded file by an inclusive range of absolute byte positions and the line positions on which those occur.
val file_none : fpathfile_none is "-". A file path to use when there is none.
The type for zero-based, absolute, byte positions in text. If the text has n bytes, 0 is the first position and n-1 is the last position.
val byte_pos_none : byte_posbyte_pos_none is -1. A position to use when there is none.
The type for one-based, line numbers in the text. Lines increment after a newline which is either 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>).
val line_num_none : line_numline_num_none is -1. A line number to use when there is none.
The type for line positions. This identifies a line by its line number and the absolute byte position following its newline (or the start of text for the first line). That byte position:
val line_pos_first : line_posline_pos_first is 1, 0. Note that this is the only line position of the empty text.
val line_pos_none : line_posline_pos_none is (line_pos_none, pos_pos_none).
The type for text locations. A text location identifies a text span in an UTF-8 encoded file by an inclusive range of absolute byte positions and the line positions on which they occur.
If the first byte equals the last byte the range contains exactly that byte. If the first byte is greater than the last byte this represents an insertion point before the first byte. In this case information about the last position should be ignored: it can contain anything.
val none : tnone is a position to use when there is none.
val make :
file:fpath ->
first_byte:byte_pos ->
last_byte:byte_pos ->
first_line:line_pos ->
last_line:line_pos ->
tv ~file ~first_byte ~last_byte ~first_line ~last_line is a text location with the given arguments, see corresponding accessors for the semantics. If you don't have a file use file_none.
first_line l is the line position on which first_byte l lies. Irrelevant if is_none is true.
val is_none : t -> boolis_none t is true iff first_byte < 0.
val is_empty : t -> boolis_empty t is true iff first_byte t > last_byte t.
equal t0 t1 is true iff t0 and t1 are equal. This checks that file, first_byte and last_byte are equal. Line information is ignored.
compare t0 t1 orders t0 and t1. The order is compatible with equal. Comparison starts with file, follows with first_byte and ends, if needed, with last_byte. Line information is ignored.
set_first l ~first_byte ~first_line sets the the first position of l to given values.
set_last l ~last_byte ~last_line sets the last position of l to given values.
to_first l has both first and last positions set to l's first position. The range spans first_byte. See also before.
before t is the empty text location starting at first_byte.
after t is the empty empty location starting at last_byte t + 1; note that at the end of input this may be an invalid byte index. The first_line and last_line of the result is last_line t.
span l0 l1 is the span from the smallest byte position of l0 and l1 to the largest byte position of l0 and l1. The file path is taken from the greatest byte position.
reloc ~first ~last uses the first position of first, the last position of last and the file of last.
val pp_ocaml : Stdlib.Format.formatter -> t -> unitpp_ocaml formats text locations like the OCaml compiler.
val pp_gnu : Stdlib.Format.formatter -> t -> unitpp_gnu formats text locations according to the GNU convention.
val pp_dump : Stdlib.Format.formatter -> t -> unitpp_dump formats raw data for debugging.