module Location:sig..end
Warning: this module is unstable and part of compiler-libs.
typet =Warnings.loc= {
|
loc_start : |
|
loc_end : |
|
loc_ghost : |
}
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.
val none : tAn arbitrary value of type t; describes an empty ghost range.
val in_file : string -> tReturn an empty ghost range located in a given file.
val init : Lexing.lexbuf -> string -> unitSet the file name and line number of the lexbuf to be the start
of the named file.
val curr : Lexing.lexbuf -> tGet the location of the current token from the lexbuf.
val symbol_rloc : unit -> t
val symbol_gloc : unit -> t
val rhs_loc : int -> trhs_loc n returns the location of the symbol at position n, starting
at 1, in the current parser rule.
val rhs_interval : int -> int -> t
val get_pos_info : Lexing.position -> string * int * intfile, line, char
type 'a loc = {
|
txt : |
|
loc : |
}
val mknoloc : 'a -> 'a loc
val mkloc : 'a -> t -> 'a locval input_name : string ref
val input_lexbuf : Lexing.lexbuf option ref
val input_phrase_buffer : Buffer.t option refval echo_eof : unit -> unit
val reset : unit -> unitval rewrite_absolute_path : string -> stringrewrite absolute path to honor the BUILD_PATH_PREFIX_MAP variable (https://reproducible-builds.org/specs/build-path-prefix-map/) if it is set.
val absolute_path : string -> string
val show_filename : string -> stringIn -absname mode, return the absolute path for this filename. Otherwise, returns the filename unchanged.
val print_filename : Format.formatter -> string -> unit
val print_loc : Format.formatter -> t -> unit
val print_locs : Format.formatter -> t list -> unitval highlight_terminfo : Lexing.lexbuf -> Format.formatter -> t list -> unittypemsg =(Format.formatter -> unit) loc
val msg : ?loc:t ->
('a, Format.formatter, unit, msg) format4 -> 'a
type report_kind =
| |
Report_error |
| |
Report_warning of |
| |
Report_warning_as_error of |
| |
Report_alert of |
| |
Report_alert_as_error of |
type report = {
|
kind : |
|
main : |
|
sub : |
}
type report_printer = {
|
pp : |
|
pp_report_kind : |
|
pp_main_loc : |
|
pp_main_txt : |
|
pp_submsgs : |
|
pp_submsg : |
|
pp_submsg_loc : |
|
pp_submsg_txt : |
}
A printer for reports, defined using open-recursion.
The goal is to make it easy to define new printers by re-using code from
existing ones.
val batch_mode_printer : report_printer
val terminfo_toplevel_printer : Lexing.lexbuf -> report_printer
val best_toplevel_printer : unit -> report_printerDetects the terminal capabilities and selects an adequate printer
reportval print_report : Format.formatter -> report -> unitDisplay an error or warning report.
val report_printer : (unit -> report_printer) refHook for redefining the printer of reports.
The hook is a unit -> report_printer and not simply a report_printer:
this is useful so that it can detect the type of the output (a file, a
terminal, ...) and select a printer accordingly.
val default_report_printer : unit -> report_printerOriginal report printer for use in hooks.
Warnings.t into a reportval report_warning : t -> Warnings.t -> report optionreport_warning loc w produces a report for the given warning w, or
None if the warning is not to be printed.
val warning_reporter : (t -> Warnings.t -> report option) refHook for intercepting warnings.
val default_warning_reporter : t -> Warnings.t -> report optionOriginal warning reporter for use in hooks.
val formatter_for_warnings : Format.formatter ref
val print_warning : t -> Format.formatter -> Warnings.t -> unitPrints a warning. This is simply the composition of report_warning and
print_report.
val prerr_warning : t -> Warnings.t -> unitSame as print_warning, but uses !formatter_for_warnings as output
formatter.
Alert.t into a reportval report_alert : t -> Warnings.alert -> report optionreport_alert loc w produces a report for the given alert w, or
None if the alert is not to be printed.
val alert_reporter : (t -> Warnings.alert -> report option) refHook for intercepting alerts.
val default_alert_reporter : t -> Warnings.alert -> report optionOriginal alert reporter for use in hooks.
val print_alert : t -> Format.formatter -> Warnings.alert -> unitPrints an alert. This is simply the composition of report_alert and
print_report.
val prerr_alert : t -> Warnings.alert -> unitSame as print_alert, but uses !formatter_for_warnings as output
formatter.
val deprecated : ?def:t -> ?use:t -> t -> string -> unitPrints a deprecation alert.
val alert : ?def:t ->
?use:t -> kind:string -> t -> string -> unitPrints an arbitrary alert.
typeerror =report
An error is a report which report_kind must be Report_error.
val error : ?loc:t -> ?sub:msg list -> string -> error
val errorf : ?loc:t ->
?sub:msg list ->
('a, Format.formatter, unit, error) format4 -> 'a
val error_of_printer : ?loc:t ->
?sub:msg list ->
(Format.formatter -> 'a -> unit) -> 'a -> error
val error_of_printer_file : (Format.formatter -> 'a -> unit) -> 'a -> errorval register_error_of_exn : (exn -> error option) -> unitEach compiler module which defines a custom type of exception
which can surface as a user-visible error should register
a "printer" for this exception using register_error_of_exn.
The result of the printer is an error value containing
a location, a message, and optionally sub-messages (each of them
being located as well).
val error_of_exn : exn -> [ `Already_displayed | `Ok of error ] option
exception Error of error
Raising Error e signals an error e; the exception will be caught and the
error will be printed.
exception Already_displayed_error
Raising Already_displayed_error signals an error which has already been
printed. The exception will be caught, but nothing will be printed
val raise_errorf : ?loc:t ->
?sub:msg list ->
('a, Format.formatter, unit, 'b) format4 -> 'a
val report_exception : Format.formatter -> exn -> unitReraise the exception if it is unknown.