Library
Module
Module type
Parameter
Class
Class type
type pos = {
}
Type of a position, corresponding to a continuous range of characters in a (utf8-encoded) source.
val cmp : pos Lplib.Base.cmp
Total comparison function on pos.
type popt = pos option
Convenient short name for an optional position.
type 'a loc = {
elt : 'a; | (* The element that is being localised. *) |
pos : popt; | (* Position of the element in the source code. *) |
}
Type constructor extending a type (e.g. a piece of abstract syntax) with a a source code position.
type strloc = string loc
Localised string type (widely used).
val none : 'a -> 'a loc
none elt
wraps elt
in a 'a loc
structure without any specific source code position.
val to_string : ?print_fname:bool -> pos -> string
to_string ?print_fname pos
transforms pos
into a readable string. If print_fname
is true
(the default), the filename contained in pos
is printed.
val pp : popt Lplib.Base.pp
pp ppf pos
prints the optional position pos
on ppf
.
val short : popt Lplib.Base.pp
short ppf pos
prints the optional position pos
on ppf
.
map f loc
applies function f
on the value of loc
and keeps the position unchanged.
val locate : ?fname:string -> (Lexing.position * Lexing.position) -> pos
locate ?fname loc
converts the pair of position loc
and filename fname
of the Lexing library into a pos
.
val make_pos : (Lexing.position * Lexing.position) -> 'a -> 'a loc
make_pos lps elt
creates a located element from the lexing positions lps
and the element elt
.