-
Notifications
You must be signed in to change notification settings - Fork 455
/
Copy pathlocation.mli
117 lines (86 loc) · 3.96 KB
/
location.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(** Source code locations (ranges of positions), used in parsetree. *)
open Format
type t = Warnings.loc = {
loc_start: Lexing.position;
loc_end: 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.
*)
val none : t
(** 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 input_name : string ref
val set_input_name : string -> unit
val get_pos_info : Lexing.position -> string * int * int (* file, line, char *)
val print_loc : formatter -> t -> unit
val prerr_warning : t -> Warnings.t -> unit
val warning_printer : (t -> formatter -> Warnings.t -> unit) ref
(** Hook for intercepting warnings. *)
val formatter_for_warnings : formatter ref
val default_warning_printer : t -> formatter -> Warnings.t -> unit
(** Original warning printer for use in hooks. *)
type 'a loc = {txt: 'a; loc: t}
val mknoloc : 'a -> 'a loc
val mkloc : 'a -> t -> 'a loc
val print_filename : formatter -> string -> unit
val show_filename : string -> string
(** Support for located errors *)
type error = {
loc: t;
msg: string;
sub: error list;
if_highlight: string; (* alternative message if locations are highlighted *)
}
exception Already_displayed_error
exception Error of error
val error : ?loc:t -> ?sub:error list -> ?if_highlight:string -> string -> error
val errorf :
?loc:t ->
?sub:error list ->
?if_highlight:string ->
('a, Format.formatter, unit, error) format4 ->
'a
val raise_errorf :
?loc:t ->
?sub:error list ->
?if_highlight:string ->
('a, Format.formatter, unit, 'b) format4 ->
'a
val error_of_printer : t -> (formatter -> 'a -> unit) -> 'a -> error
val error_of_printer_file : (formatter -> 'a -> unit) -> 'a -> error
val error_of_exn : exn -> [`Ok of error | `Already_displayed] option
val register_error_of_exn : (exn -> error option) -> unit
(** Each 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 report_error : ?src:string option -> formatter -> error -> unit
val error_reporter : (?src:string option -> formatter -> error -> unit) ref
(** Hook for intercepting error reports. *)
val default_error_reporter : ?src:string option -> formatter -> error -> unit
(** Original error reporter for use in hooks. *)
val report_exception : formatter -> exn -> unit
(** Reraise the exception if it is unknown. *)
val deprecated : ?def:t -> ?use:t -> t -> string -> unit