Module Loc
Basic types
type source
=
|
InFile of
{
dirpath : string option;
file : string;
}
|
ToplevelInput
type t
=
{
fname : source;
filename or toplevel input
line_nb : int;
start line number
bol_pos : int;
position of the beginning of start line
line_nb_last : int;
end line number
bol_pos_last : int;
position of the beginning of end line
bp : int;
start position
ep : int;
end position
}
Location manipulation
val create : source -> int -> int -> int -> int -> t
Create a location from a filename, a line number, a position of the beginning of the line, a start and end position
val unloc : t -> int * int
Return the start and end position of a location
val make_loc : (int * int) -> t
Make a location out of its start and end position
val merge : t -> t -> t
val merge_opt : t option -> t option -> t option
Merge locations, usually generating the largest possible span
val sub : t -> int -> int -> t
sub loc sh len
is the locationloc
shifted withsh
characters and with lengthlen
. The previous ending position of the location is lost.
val after : t -> int -> int -> t
after loc sh len
is the location just after loc (starting at the end position ofloc
) shifted withsh
characters and of lengthlen
.
Located exceptions
val add_loc : Exninfo.info -> t -> Exninfo.info
Adding location to an exception
val get_loc : Exninfo.info -> t option
Retrieving the optional location of an exception
val raise : ?loc:t -> exn -> 'a
raise loc e
is the same asPervasives.raise (add_loc e loc)
.
Objects with location information
type 'a located
= t option * 'a