Library
Module
Module type
Parameter
Class
Class type
When the symbol you want to decorate is not already an argument in a record, it may be convenient to use this type as a standard way to decorate a symbol with a position.
Using Loc.t
or 'a Loc.Txt.t
are two different styles to decorate a symbol, you may choose one depending on the context.
An example using Loc.t
:
type t =
| T of { loc : Loc.t ; a : A.t; b : B.t; ... }
An example using 'a Loc.Txt.t
:
type t = A.t Loc.Txt.t list
type loc := t
It is possible to ignore the locations by setting Loc.equal_ignores_locs
to true
.
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
By default locations are not shown. To include the locations set Loc.include_sexp_of_locs
to true
.
val create : (Lexing.position * Lexing.position) -> 'a -> 'a t
To be called in the right hand side of a Menhir rule, using the $loc
special keyword provided by Menhir. For example:
ident:
| ident=IDENT { Loc.Txt.create $loc ident }
;
Build a new node where the symbol has been mapped, keeping the original location.
val no_loc : 'a -> 'a t
Build a t
where t.loc = Loc.none
.
val txt : 'a t -> 'a