Source code locations (ranges of positions), used in parsetree.
type t = {
loc_start : Stdlib .Lexing.position;
loc_end : Stdlib .Lexing.position;
loc_ghost : bool;
}
Note on the use of Lexing.position in this module. If pos_fname = ""
, then use !input_name
instead. If pos_lnum = -1
, then pos_bol = 0
. Use pos_cnum
and re-parse the file to get the line and character numbers. Else all fields are correct.
An arbitrary value of type t
; describes an empty ghost range.
val in_file : string -> t
Return an empty ghost range located in a given file.
val init : Stdlib .Lexing.lexbuf -> string -> unit
Set the file name and line number of the lexbuf
to be the start of the named file.
val curr : Stdlib .Lexing.lexbuf -> t
Get the location of the current token from the lexbuf
.
val symbol_rloc : unit -> t
val symbol_gloc : unit -> t
rhs_loc n
returns the location of the symbol at position n
, starting at 1, in the current parser rule.
val get_pos_info : Stdlib .Lexing.position -> string * int * int
val print_loc : Stdlib .Format.formatter -> t -> unit
val print_error : Stdlib .Format.formatter -> t -> unit
val print_error_cur_file : Stdlib .Format.formatter -> unit -> unit
val print_warning : t -> Stdlib .Format.formatter -> Warnings.t -> unit
val echo_eof : unit -> unit
val warning_printer :
(t -> Stdlib .Format.formatter -> Warnings.t -> unit) Stdlib .ref
Hook for intercepting warnings.
val default_warning_printer :
t ->
Stdlib .Format.formatter ->
Warnings.t ->
unit
Original warning printer for use in hooks.
val highlight_locations : Stdlib .Format.formatter -> t list -> bool
type 'a loc = {
txt : 'a ;
loc : t ;
}
val mknoloc : 'a -> 'a loc
val mkloc : 'a -> t -> 'a loc
val print : Stdlib .Format.formatter -> t -> unit
val print_compact : Stdlib .Format.formatter -> t -> unit
val print_filename : Stdlib .Format.formatter -> string -> unit
val absolute_path : string -> string
val show_filename : string -> string
In -absname mode, return the absolute path for this filename. Otherwise, returns the filename unchanged.
val absname : bool Stdlib .ref
type error = {
loc : t ;
msg : string;
sub : error list ;
if_highlight : string;
}
val print_error_prefix : Stdlib .Format.formatter -> unit -> unit
val error :
?loc :t ->
?sub :error list ->
?if_highlight :string ->
string ->
error
val errorf :
?loc :t ->
?sub :error list ->
?if_highlight :string ->
('a , Stdlib .Format.formatter, unit, error ) Stdlib .format4 ->
'a
val raise_errorf :
?loc :t ->
?sub :error list ->
?if_highlight :string ->
('a , Stdlib .Format.formatter, unit, 'b ) Stdlib .format4 ->
'a
val error_of_printer :
t ->
(Stdlib .Format.formatter -> 'a -> unit) ->
'a ->
error
val error_of_printer_file :
(Stdlib .Format.formatter -> 'a -> unit) ->
'a ->
error
val error_of_exn : exn -> error option
val register_error_of_exn : (exn -> error option ) -> unit
val report_error : Stdlib .Format.formatter -> error -> unit
val error_reporter : (Stdlib .Format.formatter -> error -> unit) Stdlib .ref
Hook for intercepting error reports.
val default_error_reporter : Stdlib .Format.formatter -> error -> unit
Original error reporter for use in hooks.
val report_exception : Stdlib .Format.formatter -> exn -> unit