Syncom.PositionCharacter positions in source files.
The definition for a character position depends on the source file's encoding. A lexer is typically responsible for constructing positions.
val make : line:int -> beginning_of_line:int -> offset:int -> tmake ~line ~beginning_of_line ~offset is the source code position at a character distance offset from the initial position of a file. line is the number of the line (starting at 1) in which the character occurs. beginning_of_line is the character distance from the initial position of the file and the beginning of the line.
The character distances have to be computed with respect to the file's encoding. UTF-8, the default encoding for Beluga signatures, is a variable-width encoding, so it is incorrect to always count a byte as a character.
val initial : tinitial is the initial position of a character in a source file, with line initial = 1, beginning_of_line initial = 0 and offset initial = 0.
val line : t -> intline position is the line of position. The line count starts at 1.
val column : t -> intcolumn position is the column of position, computed from its beginning of line and actual offsets. The column count starts at 1.
val beginning_of_line : t -> intval offset : t -> intEquality of positions by their offsets.
include Support.Eq.EQ with type t := tTotal ordering of positions by their offsets.
include Support.Ord.ORD with type t := tcompare a b compares a and b for ordering.
compare a b < 0 if a precedes b (denoted a < b),compare a b = 0 if a is equal to b (denoted a = b),compare a b > 0 if a succeeds b (denoted a > b).This should satisfy the following properties:
(compare a b <= 0 || compare b a >= 0) = true,(compare a b <= 0) = true and (compare b c <= 0) = true, then (compare a c <= 0) = true,(compare a a = 0) = true,(compare a b <= 0) = true and (compare a b >= 0) = true then (compare a b = 0) = true.include Support.Eq.EQ with type t := tequal a b is true if and only if a and b are equal. This should satisfy the following properties:
equal a a = trueequal a b is equivalent to equal b aequal a b = true and equal b c = true, then equal a c = trueval make_from_lexing_position : Stdlib.Lexing.position -> tmake_from_lexing_position lexing_position is the character position derived from lexing_position using its pos_lnum, pos_bol and pos_cnum.
val to_lexing_position : ?filename:string -> t -> Stdlib.Lexing.positionto_lexing_position ?filename position is the lexing position derived from position with filename as pos_fname if it is defined, and "" otherwise.