Module Loc

module Loc: sig .. end

Source locations


Lexing locations

val current_offset : int Stdlib.ref
val reloc : Stdlib.Lexing.position -> Stdlib.Lexing.position
val set_file : string -> Stdlib.Lexing.lexbuf -> unit
val transfer_loc : Stdlib.Lexing.lexbuf -> Stdlib.Lexing.lexbuf -> unit

locations in files

type position 
val extract : Stdlib.Lexing.position * Stdlib.Lexing.position -> position
val join : position -> position -> position
val dummy_position : position
val user_position : string -> int -> int -> int -> position
val get : position -> string * int * int * int
val compare : position -> position -> int
val equal : position -> position -> bool
val hash : position -> int
val gen_report_position : Stdlib.Format.formatter -> position -> unit
val report_position : Stdlib.Format.formatter -> position -> unit

located exceptions

exception Located of position * exn
val try1 : ?loc:position -> ('a -> 'b) -> 'a -> 'b
val try2 : ?loc:position -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c
val try3 : ?loc:position -> ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd
val try4 : ?loc:position ->
('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e
val try5 : ?loc:position ->
('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> 'a -> 'b -> 'c -> 'd -> 'e -> 'f
val try6 : ?loc:position ->
('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) ->
'a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g
val try7 : ?loc:position ->
('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h) ->
'a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h
val error : ?loc:position -> exn -> 'a

located error messages

exception Message of string
val errorm : ?loc:position ->
('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'a
val with_location : (Stdlib.Lexing.lexbuf -> 'a) -> Stdlib.Lexing.lexbuf -> 'a
val get_multiline : position -> string * (int * int) * (int * int)

Returns filename, (bline, bcol), (eline, ecol) of a position.

Currently, this function re-reads the file to determine the line and column of the end of multiline positions. Subsequent calls for positions in the same file will not require re-reading the file. The function fails if the file does not exist.