Syncom.LocationCharacter position ranges in source files.
A parser is typically responsible for constructing locations using positions generated by the lexer.
val ghost : tghost is the null location used for AST nodes having no correspondence to a source file.
val initial : string -> tinitial filename is the location at the beginning of the file with name filename.
val make :
filename:string ->
start_position:Position.t ->
stop_position:Position.t ->
tmake ~filename ~start_position ~stop_position is the non-ghost location starting at the character position start_position inclusively and ending at the character position stop_position exclusively in the file at filename.
join l1 l2 is the smallest location that contains l1 and l2.
It is assumed that filename l1 = filename l2.
Ghost locations are left and right identities of join, meaning that:
is_ghost l1, then join l1 l2 = l2.is_ghost l2, then join l1 l2 = l1.val join_all : t -> t Support.List.t -> tjoin_all init ls is each location in ls joined together, additionally with init.
val join_all_contramap : ('a -> t) -> t -> 'a Support.List.t -> tjoin_all_contramap f init xs is each location contramapped by f from xs. joined together, additionally with init.
If xs = [x1; x2; ...; xn], then join_all_contramap f init xs = join_all init [f x1; f x2; ...; f xn].
val join_all1 : t Support.List1.t -> tval join_all1_contramap : ('a -> t) -> 'a Support.List1.t -> tval join_all2_contramap : ('a -> t) -> 'a Support.List2.t -> tval set_start : Position.t -> t -> tval set_stop : Position.t -> t -> tset_start_line line location is location with its start line set to line. The start position's beginning of line and offset are not modified, so the output location may be invalid. This should only be used with locations that do not point to files, like ghost locations.
set_stop_line line location is like set_start_line line location but for the location's stop position.
val filename : t -> stringval start_position : t -> Position.tval stop_position : t -> Position.tval start_offset : t -> intval stop_offset : t -> intval start_bol : t -> intval stop_bol : t -> intval start_line : t -> intval stop_line : t -> intval start_column : t -> intval stop_column : t -> intval spanned_offsets : t -> intspanned_offsets location is stop_offset location - start_offset location.
val is_ghost : t -> boolmodule Ord_by_start : Support.Ord.ORD with type t = tmodule Ord_by_stop : Support.Ord.ORD with type t = tval print : Support.Format.formatter -> t -> unitPrints `<filename>, line <n>, column <n>'. Suitable for proper errors.
val pp : Support.Format.formatter -> t -> unitval print_short : Support.Format.formatter -> t -> unitPrints `line <n>, column <n>'. More suitable for debug prints.
val print_span_short : Support.Format.formatter -> t -> unitPrints `<n>.<n> - <n>.<n>' indicating start and stop positions.
val make_from_lexing_positions :
filename:string ->
start_position:Stdlib.Lexing.position ->
stop_position:Stdlib.Lexing.position ->
tval start_to_lexing_position : t -> Stdlib.Lexing.positionval stop_to_lexing_position : t -> Stdlib.Lexing.positionval to_lexing_positions : t -> Stdlib.Lexing.position * Stdlib.Lexing.positionStructural equality instance.
include Support.Eq.EQ with type t := tLexicographical ordering instance by filename, start position and stop position in that sequence.
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 = true