1Location(3)                      OCaml library                     Location(3)
2
3
4

NAME

6       Location  - Source code locations (ranges of positions), used in parse‐
7       tree.
8

Module

10       Module   Location
11

Documentation

13       Module Location
14        : sig end
15
16
17       Source code locations (ranges of positions), used in parsetree.
18
19
20
21
22
23       type t = Warnings.loc = {
24        loc_start : Lexing.position ;
25        loc_end : Lexing.position ;
26        loc_ghost : bool ;
27        }
28
29
30
31
32
33
34       === Note on the use of Lexing.position in this module.  If pos_fname  =
35       ,  then  use  !input_name instead.  If pos_lnum = -1, then pos_bol = 0.
36       Use pos_cnum and re-parse the file to get the line and  character  num‐
37       bers.  Else all fields are correct. ===
38
39
40       val none : t
41
42       An arbitrary value of type t ; describes an empty ghost range.
43
44
45
46       val in_file : string -> t
47
48       Return an empty ghost range located in a given file.
49
50
51
52       val init : Lexing.lexbuf -> string -> unit
53
54       Set  the file name and line number of the lexbuf to be the start of the
55       named file.
56
57
58
59       val curr : Lexing.lexbuf -> t
60
61       Get the location of the current token from the lexbuf .
62
63
64
65       val symbol_rloc : unit -> t
66
67
68
69
70       val symbol_gloc : unit -> t
71
72
73
74
75       val rhs_loc : int -> t
76
77
78       rhs_loc n returns the location of the symbol at position n  ,  starting
79       at 1, in the current parser rule.
80
81
82
83       val input_name : string Pervasives.ref
84
85
86
87
88       val input_lexbuf : Lexing.lexbuf option Pervasives.ref
89
90
91
92
93       val get_pos_info : Lexing.position -> string * int * int
94
95
96
97
98       val print_loc : Format.formatter -> t -> unit
99
100
101
102
103       val print_error_prefix : Format.formatter -> unit
104
105
106
107
108       val print_error : Format.formatter -> t -> unit
109
110
111
112
113       val print_error_cur_file : Format.formatter -> unit -> unit
114
115
116
117
118       val print_warning : t -> Format.formatter -> Warnings.t -> unit
119
120
121
122
123       val formatter_for_warnings : Format.formatter Pervasives.ref
124
125
126
127
128       val prerr_warning : t -> Warnings.t -> unit
129
130
131
132
133       val echo_eof : unit -> unit
134
135
136
137
138       val reset : unit -> unit
139
140
141
142
143       val default_printer : Format.formatter -> t -> unit
144
145
146
147
148       val printer : (Format.formatter -> t -> unit) Pervasives.ref
149
150
151
152
153       val  warning_printer  :  (t  -> Format.formatter -> Warnings.t -> unit)
154       Pervasives.ref
155
156       Hook for intercepting warnings.
157
158
159
160       val default_warning_printer : t -> Format.formatter  ->  Warnings.t  ->
161       unit
162
163       Original warning printer for use in hooks.
164
165
166
167       val highlight_locations : Format.formatter -> t list -> bool
168
169
170
171
172       val  show_code_at_location  : Format.formatter -> Lexing.lexbuf -> t ->
173       unit
174
175
176
177       type 'a loc = {
178        txt : 'a ;
179        loc : t ;
180        }
181
182
183
184
185
186       val mknoloc : 'a -> 'a loc
187
188
189
190
191       val mkloc : 'a -> t -> 'a loc
192
193
194
195
196       val print : Format.formatter -> t -> unit
197
198
199
200
201       val print_compact : Format.formatter -> t -> unit
202
203
204
205
206       val print_filename : Format.formatter -> string -> unit
207
208
209
210
211       val rewrite_absolute_path : string -> string
212
213       rewrite absolute  path  to  honor  the  BUILD_PATH_PREFIX_MAP  variable
214       (https://reproducible-builds.org/specs/build-path-prefix-map/) if it is
215       set.
216
217
218
219       val absolute_path : string -> string
220
221
222
223
224       val show_filename : string -> string
225
226       In -absname mode, return the absolute path for this  filename.   Other‐
227       wise, returns the filename unchanged.
228
229
230
231       val absname : bool Pervasives.ref
232
233
234
235
236
237       === Support for located errors ===
238
239
240       type error = {
241        loc : t ;
242        msg : string ;
243        sub : error list ;
244        if_highlight : string ;
245        }
246
247
248
249
250
251       exception Already_displayed_error
252
253
254
255
256
257       exception Error of error
258
259
260
261
262
263       val error : ?loc:t -> ?sub:error list -> ?if_highlight:string -> string
264       -> error
265
266
267
268
269       val errorf : ?loc:t -> ?sub:error list -> ?if_highlight:string ->  ('a,
270       Format.formatter, unit, error) Pervasives.format4 -> 'a
271
272
273
274
275       val raise_errorf : ?loc:t -> ?sub:error list -> ?if_highlight:string ->
276       ('a, Format.formatter, unit, 'b) Pervasives.format4 -> 'a
277
278
279
280
281       val error_of_printer : t -> (Format.formatter -> 'a -> unit) ->  'a  ->
282       error
283
284
285
286
287       val  error_of_printer_file  : (Format.formatter -> 'a -> unit) -> 'a ->
288       error
289
290
291
292
293       val error_of_exn : exn -> [ `Already_displayed | `Ok of error ] option
294
295
296
297
298       val register_error_of_exn : (exn -> error option) -> unit
299
300       Each compiler module which defines a custom type of exception which can
301       surface  as  a  user-visible error should register a "printer" for this
302       exception using register_error_of_exn .  The result of the  printer  is
303       an  error  value  containing  a  location,  a  message,  and optionally
304       sub-messages (each of them being located as well).
305
306
307
308       val report_error : Format.formatter -> error -> unit
309
310
311
312
313       val error_reporter : (Format.formatter -> error -> unit) Pervasives.ref
314
315       Hook for intercepting error reports.
316
317
318
319       val default_error_reporter : Format.formatter -> error -> unit
320
321       Original error reporter for use in hooks.
322
323
324
325       val report_exception : Format.formatter -> exn -> unit
326
327       Reraise the exception if it is unknown.
328
329
330
331       val deprecated : ?def:t -> ?use:t -> t -> string -> unit
332
333
334
335
336
337
338OCamldoc                          2019-02-02                       Location(3)
Impressum