Module Middle.Location

Storing locations in the original source

type t = {
  1. filename : string;
  2. line_num : int;
  3. col_num : int;
  4. included_from : t option;
}

Source code locations

val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
val hash_fold_t : Ppx_hash_lib.Std.Hash.state -> t -> Ppx_hash_lib.Std.Hash.state
val hash : t -> Ppx_hash_lib.Std.Hash.hash_value
val pp_context_list : Stdlib.Format.formatter -> (string list * t) -> unit
val context_to_string : (unit -> string list) -> t -> string option

Turn the given location into a string holding the code of that location. Code is retrieved by calling context_cb, which may do IO. Exceptions in the callback or in the creation of the string (possible if the context is incorrectly too short for the given location) return None

val empty : t
val to_string : ?printed_filename:string -> ?print_file:bool -> ?print_line:bool -> t -> string

Format the location for error messaging.

If printed_filename is passed, it replaces the highest-level name and leaves the filenames of included files intact.

val compare : t -> t -> int