File: Location.html

package info (click to toggle)
ocaml-doc 4.11-2
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 20,580 kB
  • sloc: sh: 37; makefile: 11
file content (503 lines) | stat: -rw-r--r-- 31,743 bytes parent folder | download
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Load_path.html">
<link rel="next" href="Longident.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg_helper" rel="Chapter" href="Arg_helper.html">
<link title="Ast_helper" rel="Chapter" href="Ast_helper.html">
<link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html">
<link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html">
<link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html">
<link title="Asttypes" rel="Chapter" href="Asttypes.html">
<link title="Attr_helper" rel="Chapter" href="Attr_helper.html">
<link title="Build_path_prefix_map" rel="Chapter" href="Build_path_prefix_map.html">
<link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html">
<link title="CamlinternalMenhirLib" rel="Chapter" href="CamlinternalMenhirLib.html">
<link title="Ccomp" rel="Chapter" href="Ccomp.html">
<link title="Clflags" rel="Chapter" href="Clflags.html">
<link title="Compiler_libs" rel="Chapter" href="Compiler_libs.html">
<link title="Config" rel="Chapter" href="Config.html">
<link title="Consistbl" rel="Chapter" href="Consistbl.html">
<link title="Depend" rel="Chapter" href="Depend.html">
<link title="Docstrings" rel="Chapter" href="Docstrings.html">
<link title="Domainstate" rel="Chapter" href="Domainstate.html">
<link title="Identifiable" rel="Chapter" href="Identifiable.html">
<link title="Int_replace_polymorphic_compare" rel="Chapter" href="Int_replace_polymorphic_compare.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Load_path" rel="Chapter" href="Load_path.html">
<link title="Location" rel="Chapter" href="Location.html">
<link title="Longident" rel="Chapter" href="Longident.html">
<link title="Misc" rel="Chapter" href="Misc.html">
<link title="Numbers" rel="Chapter" href="Numbers.html">
<link title="Parse" rel="Chapter" href="Parse.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Parsetree" rel="Chapter" href="Parsetree.html">
<link title="Pparse" rel="Chapter" href="Pparse.html">
<link title="Pprintast" rel="Chapter" href="Pprintast.html">
<link title="Printast" rel="Chapter" href="Printast.html">
<link title="Profile" rel="Chapter" href="Profile.html">
<link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html">
<link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html">
<link title="Targetint" rel="Chapter" href="Targetint.html">
<link title="Terminfo" rel="Chapter" href="Terminfo.html">
<link title="Warnings" rel="Chapter" href="Warnings.html"><link title="Input info" rel="Section" href="#1_Inputinfo">
<link title="Toplevel-specific functions" rel="Section" href="#1_Toplevelspecificfunctions">
<link title="Printing locations" rel="Section" href="#1_Printinglocations">
<link title="Toplevel-specific location highlighting" rel="Section" href="#1_Toplevelspecificlocationhighlighting">
<link title="Reporting errors and warnings" rel="Section" href="#1_Reportingerrorsandwarnings">
<link title="Reporting warnings" rel="Section" href="#1_Reportingwarnings">
<link title="Reporting alerts" rel="Section" href="#1_Reportingalerts">
<link title="Reporting errors" rel="Section" href="#1_Reportingerrors">
<link title="Automatically reporting errors for raised exceptions" rel="Section" href="#1_Automaticallyreportingerrorsforraisedexceptions">
<link title="The type of reports and report printers" rel="Subsection" href="#2_Thetypeofreportsandreportprinters">
<link title="Report printers used in the compiler" rel="Subsection" href="#2_Reportprintersusedinthecompiler">
<link title="Printing a report" rel="Subsection" href="#2_Printingareport">
<link title="Converting a Warnings.t into a report" rel="Subsection" href="#2_ConvertingaWarningstintoareport">
<link title="Printing warnings" rel="Subsection" href="#2_Printingwarnings">
<link title="Converting an Alert.t into a report" rel="Subsection" href="#2_ConvertinganAlerttintoareport">
<link title="Printing alerts" rel="Subsection" href="#2_Printingalerts">
<title>Location</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Load_path.html" title="Load_path">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="Longident.html" title="Longident">Next</a>
</div>
<h1>Module <a href="type_Location.html">Location</a></h1>

<pre><span id="MODULELocation"><span class="keyword">module</span> Location</span>: <code class="code"><span class="keyword">sig</span></code> <a href="Location.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
<div class="info-desc">
<h2 id="1_Sourcecodelocationsrangesofpositionsusedinparsetree">Source code locations (ranges of positions), used in parsetree</h2>
<p><b>Warning:</b> this module is unstable and part of
  <a href="Compiler_libs.html">compiler-libs</a>.</p>
</div>
</div>
<hr width="100%">

<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = <code class="type"><a href="Warnings.html#TYPEloc">Warnings.loc</a></code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTt.loc_start">loc_start</span>&nbsp;: <code class="type">Lexing.position</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTt.loc_end">loc_end</span>&nbsp;: <code class="type">Lexing.position</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTt.loc_ghost">loc_ghost</span>&nbsp;: <code class="type">bool</code>;</code></td>

</tr></table>
<code>}</code>


<p>Note on the use of Lexing.position in this module.
   If <code class="code">pos_fname&nbsp;=&nbsp;<span class="string">""</span></code>, then use <code class="code">!input_name</code> instead.
   If <code class="code">pos_lnum&nbsp;=&nbsp;-1</code>, then <code class="code">pos_bol&nbsp;=&nbsp;0</code>. Use <code class="code">pos_cnum</code> and
     re-parse the file to get the line and character numbers.
   Else all fields are correct.</p>

<pre><span id="VALnone"><span class="keyword">val</span> none</span> : <code class="type"><a href="Location.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p>An arbitrary value of type <code class="code">t</code>; describes an empty ghost range.</p>
</div>
</div>

<pre><span id="VALis_none"><span class="keyword">val</span> is_none</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
<div class="info-desc">
<p>True for <code class="code"><span class="constructor">Location</span>.none</code>, false any other location</p>
</div>
</div>

<pre><span id="VALin_file"><span class="keyword">val</span> in_file</span> : <code class="type">string -> <a href="Location.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Return an empty ghost range located in a given file.</p>
</div>
</div>

<pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type">Lexing.lexbuf -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Set the file name and line number of the <code class="code">lexbuf</code> to be the start
    of the named file.</p>
</div>
</div>

<pre><span id="VALcurr"><span class="keyword">val</span> curr</span> : <code class="type">Lexing.lexbuf -> <a href="Location.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Get the location of the current token from the <code class="code">lexbuf</code>.</p>
</div>
</div>

<pre><span id="VALsymbol_rloc"><span class="keyword">val</span> symbol_rloc</span> : <code class="type">unit -> <a href="Location.html#TYPEt">t</a></code></pre>
<pre><span id="VALsymbol_gloc"><span class="keyword">val</span> symbol_gloc</span> : <code class="type">unit -> <a href="Location.html#TYPEt">t</a></code></pre>
<pre><span id="VALrhs_loc"><span class="keyword">val</span> rhs_loc</span> : <code class="type">int -> <a href="Location.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">rhs_loc&nbsp;n</code> returns the location of the symbol at position <code class="code">n</code>, starting
  at 1, in the current parser rule.</p>
</div>
</div>

<pre><span id="VALrhs_interval"><span class="keyword">val</span> rhs_interval</span> : <code class="type">int -> int -> <a href="Location.html#TYPEt">t</a></code></pre>
<pre><span id="VALget_pos_info"><span class="keyword">val</span> get_pos_info</span> : <code class="type">Lexing.position -> string * int * int</code></pre><div class="info ">
<div class="info-desc">
<p>file, line, char</p>
</div>
</div>

<pre><code><span id="TYPEloc"><span class="keyword">type</span> <code class="type">'a</code> loc</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTloc.txt">txt</span>&nbsp;: <code class="type">'a</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTloc.loc">loc</span>&nbsp;: <code class="type"><a href="Location.html#TYPEt">t</a></code>;</code></td>

</tr></table>
<code>}</code>



<pre><span id="VALmknoloc"><span class="keyword">val</span> mknoloc</span> : <code class="type">'a -> 'a <a href="Location.html#TYPEloc">loc</a></code></pre>
<pre><span id="VALmkloc"><span class="keyword">val</span> mkloc</span> : <code class="type">'a -> <a href="Location.html#TYPEt">t</a> -> 'a <a href="Location.html#TYPEloc">loc</a></code></pre><h2 id="1_Inputinfo">Input info</h2>
<pre><span id="VALinput_name"><span class="keyword">val</span> input_name</span> : <code class="type">string ref</code></pre>
<pre><span id="VALinput_lexbuf"><span class="keyword">val</span> input_lexbuf</span> : <code class="type">Lexing.lexbuf option ref</code></pre>
<pre><span id="VALinput_phrase_buffer"><span class="keyword">val</span> input_phrase_buffer</span> : <code class="type">Buffer.t option ref</code></pre><h2 id="1_Toplevelspecificfunctions">Toplevel-specific functions</h2>
<pre><span id="VALecho_eof"><span class="keyword">val</span> echo_eof</span> : <code class="type">unit -> unit</code></pre>
<pre><span id="VALreset"><span class="keyword">val</span> reset</span> : <code class="type">unit -> unit</code></pre><h2 id="1_Printinglocations">Printing locations</h2>
<pre><span id="VALrewrite_absolute_path"><span class="keyword">val</span> rewrite_absolute_path</span> : <code class="type">string -> string</code></pre><div class="info ">
<div class="info-desc">
<p>rewrite absolute path to honor the BUILD_PATH_PREFIX_MAP
        variable (https://reproducible-builds.org/specs/build-path-prefix-map/)
        if it is set.</p>
</div>
</div>

<pre><span id="VALabsolute_path"><span class="keyword">val</span> absolute_path</span> : <code class="type">string -> string</code></pre>
<pre><span id="VALshow_filename"><span class="keyword">val</span> show_filename</span> : <code class="type">string -> string</code></pre><div class="info ">
<div class="info-desc">
<p>In -absname mode, return the absolute path for this filename.
        Otherwise, returns the filename unchanged.</p>
</div>
</div>

<pre><span id="VALprint_filename"><span class="keyword">val</span> print_filename</span> : <code class="type">Format.formatter -> string -> unit</code></pre>
<pre><span id="VALprint_loc"><span class="keyword">val</span> print_loc</span> : <code class="type">Format.formatter -> <a href="Location.html#TYPEt">t</a> -> unit</code></pre>
<pre><span id="VALprint_locs"><span class="keyword">val</span> print_locs</span> : <code class="type">Format.formatter -> <a href="Location.html#TYPEt">t</a> list -> unit</code></pre><h2 id="1_Toplevelspecificlocationhighlighting">Toplevel-specific location highlighting</h2>
<pre><span id="VALhighlight_terminfo"><span class="keyword">val</span> highlight_terminfo</span> : <code class="type">Lexing.lexbuf -> Format.formatter -> <a href="Location.html#TYPEt">t</a> list -> unit</code></pre><h2 id="1_Reportingerrorsandwarnings">Reporting errors and warnings</h2><h3 id="2_Thetypeofreportsandreportprinters">The type of reports and report printers</h3>
<pre><span id="TYPEmsg"><span class="keyword">type</span> <code class="type"></code>msg</span> = <code class="type">(Format.formatter -> unit) <a href="Location.html#TYPEloc">loc</a></code> </pre>


<pre><span id="VALmsg"><span class="keyword">val</span> msg</span> : <code class="type">?loc:<a href="Location.html#TYPEt">t</a> -><br>       ('a, Format.formatter, unit, <a href="Location.html#TYPEmsg">msg</a>) format4 -> 'a</code></pre>
<pre><code><span id="TYPEreport_kind"><span class="keyword">type</span> <code class="type"></code>report_kind</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_kind.Report_error"><span class="constructor">Report_error</span></span></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_kind.Report_warning"><span class="constructor">Report_warning</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_kind.Report_warning_as_error"><span class="constructor">Report_warning_as_error</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_kind.Report_alert"><span class="constructor">Report_alert</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_kind.Report_alert_as_error"><span class="constructor">Report_alert_as_error</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td>

</tr></table>



<pre><code><span id="TYPEreport"><span class="keyword">type</span> <code class="type"></code>report</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport.kind">kind</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_kind">report_kind</a></code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport.main">main</span>&nbsp;: <code class="type"><a href="Location.html#TYPEmsg">msg</a></code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport.sub">sub</span>&nbsp;: <code class="type"><a href="Location.html#TYPEmsg">msg</a> list</code>;</code></td>

</tr></table>
<code>}</code>



<pre><code><span id="TYPEreport_printer"><span class="keyword">type</span> <code class="type"></code>report_printer</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp">pp</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -> Format.formatter -> <a href="Location.html#TYPEreport">report</a> -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_report_kind">pp_report_kind</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -> Format.formatter -> <a href="Location.html#TYPEreport_kind">report_kind</a> -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_main_loc">pp_main_loc</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -> Format.formatter -> <a href="Location.html#TYPEt">t</a> -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_main_txt">pp_main_txt</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -><br>       Format.formatter -> (Format.formatter -> unit) -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_submsgs">pp_submsgs</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -> Format.formatter -> <a href="Location.html#TYPEmsg">msg</a> list -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_submsg">pp_submsg</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -> Format.formatter -> <a href="Location.html#TYPEmsg">msg</a> -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_submsg_loc">pp_submsg_loc</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -> Format.formatter -> <a href="Location.html#TYPEt">t</a> -> unit</code>;</code></td>

</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTreport_printer.pp_submsg_txt">pp_submsg_txt</span>&nbsp;: <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a> -><br>       <a href="Location.html#TYPEreport">report</a> -><br>       Format.formatter -> (Format.formatter -> unit) -> unit</code>;</code></td>

</tr></table>
<code>}</code>

<div class="info ">
<div class="info-desc">
<p>A printer for <code class="code">report</code>s, defined using open-recursion.
    The goal is to make it easy to define new printers by re-using code from
    existing ones.</p>
</div>
</div>

<h3 id="2_Reportprintersusedinthecompiler">Report printers used in the compiler</h3>
<pre><span id="VALbatch_mode_printer"><span class="keyword">val</span> batch_mode_printer</span> : <code class="type"><a href="Location.html#TYPEreport_printer">report_printer</a></code></pre>
<pre><span id="VALterminfo_toplevel_printer"><span class="keyword">val</span> terminfo_toplevel_printer</span> : <code class="type">Lexing.lexbuf -> <a href="Location.html#TYPEreport_printer">report_printer</a></code></pre>
<pre><span id="VALbest_toplevel_printer"><span class="keyword">val</span> best_toplevel_printer</span> : <code class="type">unit -> <a href="Location.html#TYPEreport_printer">report_printer</a></code></pre><div class="info ">
<div class="info-desc">
<p>Detects the terminal capabilities and selects an adequate printer</p>
</div>
</div>
<h3 id="2_Printingareport">Printing a <code class="code">report</code></h3>
<pre><span id="VALprint_report"><span class="keyword">val</span> print_report</span> : <code class="type">Format.formatter -> <a href="Location.html#TYPEreport">report</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Display an error or warning report.</p>
</div>
</div>

<pre><span id="VALreport_printer"><span class="keyword">val</span> report_printer</span> : <code class="type">(unit -> <a href="Location.html#TYPEreport_printer">report_printer</a>) ref</code></pre><div class="info ">
<div class="info-desc">
<p>Hook for redefining the printer of reports.</p>

<p>The hook is a <code class="code">unit&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;report_printer</code> and not simply a <code class="code">report_printer</code>:
    this is useful so that it can detect the type of the output (a file, a
    terminal, ...) and select a printer accordingly.</p>
</div>
</div>

<pre><span id="VALdefault_report_printer"><span class="keyword">val</span> default_report_printer</span> : <code class="type">unit -> <a href="Location.html#TYPEreport_printer">report_printer</a></code></pre><div class="info ">
<div class="info-desc">
<p>Original report printer for use in hooks.</p>
</div>
</div>
<h2 id="1_Reportingwarnings">Reporting warnings</h2><h3 id="2_ConvertingaWarningstintoareport">Converting a <code class="code"><span class="constructor">Warnings</span>.t</code> into a <code class="code">report</code></h3>
<pre><span id="VALreport_warning"><span class="keyword">val</span> report_warning</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEt">Warnings.t</a> -> <a href="Location.html#TYPEreport">report</a> option</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">report_warning&nbsp;loc&nbsp;w</code> produces a report for the given warning <code class="code">w</code>, or
   <code class="code"><span class="constructor">None</span></code> if the warning is not to be printed.</p>
</div>
</div>

<pre><span id="VALwarning_reporter"><span class="keyword">val</span> warning_reporter</span> : <code class="type">(<a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEt">Warnings.t</a> -> <a href="Location.html#TYPEreport">report</a> option) ref</code></pre><div class="info ">
<div class="info-desc">
<p>Hook for intercepting warnings.</p>
</div>
</div>

<pre><span id="VALdefault_warning_reporter"><span class="keyword">val</span> default_warning_reporter</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEt">Warnings.t</a> -> <a href="Location.html#TYPEreport">report</a> option</code></pre><div class="info ">
<div class="info-desc">
<p>Original warning reporter for use in hooks.</p>
</div>
</div>
<h3 id="2_Printingwarnings">Printing warnings</h3>
<pre><span id="VALformatter_for_warnings"><span class="keyword">val</span> formatter_for_warnings</span> : <code class="type">Format.formatter ref</code></pre>
<pre><span id="VALprint_warning"><span class="keyword">val</span> print_warning</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> Format.formatter -> <a href="Warnings.html#TYPEt">Warnings.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Prints a warning. This is simply the composition of <code class="code">report_warning</code> and
   <code class="code">print_report</code>.</p>
</div>
</div>

<pre><span id="VALprerr_warning"><span class="keyword">val</span> prerr_warning</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEt">Warnings.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <code class="code">print_warning</code>, but uses <code class="code">!formatter_for_warnings</code> as output
   formatter.</p>
</div>
</div>
<h2 id="1_Reportingalerts">Reporting alerts</h2><h3 id="2_ConvertinganAlerttintoareport">Converting an <code class="code"><span class="constructor">Alert</span>.t</code> into a <code class="code">report</code></h3>
<pre><span id="VALreport_alert"><span class="keyword">val</span> report_alert</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEalert">Warnings.alert</a> -> <a href="Location.html#TYPEreport">report</a> option</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">report_alert&nbsp;loc&nbsp;w</code> produces a report for the given alert <code class="code">w</code>, or
   <code class="code"><span class="constructor">None</span></code> if the alert is not to be printed.</p>
</div>
</div>

<pre><span id="VALalert_reporter"><span class="keyword">val</span> alert_reporter</span> : <code class="type">(<a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEalert">Warnings.alert</a> -> <a href="Location.html#TYPEreport">report</a> option) ref</code></pre><div class="info ">
<div class="info-desc">
<p>Hook for intercepting alerts.</p>
</div>
</div>

<pre><span id="VALdefault_alert_reporter"><span class="keyword">val</span> default_alert_reporter</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEalert">Warnings.alert</a> -> <a href="Location.html#TYPEreport">report</a> option</code></pre><div class="info ">
<div class="info-desc">
<p>Original alert reporter for use in hooks.</p>
</div>
</div>
<h3 id="2_Printingalerts">Printing alerts</h3>
<pre><span id="VALprint_alert"><span class="keyword">val</span> print_alert</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> Format.formatter -> <a href="Warnings.html#TYPEalert">Warnings.alert</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Prints an alert. This is simply the composition of <code class="code">report_alert</code> and
   <code class="code">print_report</code>.</p>
</div>
</div>

<pre><span id="VALprerr_alert"><span class="keyword">val</span> prerr_alert</span> : <code class="type"><a href="Location.html#TYPEt">t</a> -> <a href="Warnings.html#TYPEalert">Warnings.alert</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Same as <code class="code">print_alert</code>, but uses <code class="code">!formatter_for_warnings</code> as output
   formatter.</p>
</div>
</div>

<pre><span id="VALdeprecated"><span class="keyword">val</span> deprecated</span> : <code class="type">?def:<a href="Location.html#TYPEt">t</a> -> ?use:<a href="Location.html#TYPEt">t</a> -> <a href="Location.html#TYPEt">t</a> -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Prints a deprecation alert.</p>
</div>
</div>

<pre><span id="VALalert"><span class="keyword">val</span> alert</span> : <code class="type">?def:<a href="Location.html#TYPEt">t</a> -><br>       ?use:<a href="Location.html#TYPEt">t</a> -> kind:string -> <a href="Location.html#TYPEt">t</a> -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Prints an arbitrary alert.</p>
</div>
</div>
<h2 id="1_Reportingerrors">Reporting errors</h2>
<pre><span id="TYPEerror"><span class="keyword">type</span> <code class="type"></code>error</span> = <code class="type"><a href="Location.html#TYPEreport">report</a></code> </pre>
<div class="info ">
<div class="info-desc">
<p>An <code class="code">error</code> is a <code class="code">report</code> which <code class="code">report_kind</code> must be <code class="code"><span class="constructor">Report_error</span></code>.</p>
</div>
</div>


<pre><span id="VALerror"><span class="keyword">val</span> error</span> : <code class="type">?loc:<a href="Location.html#TYPEt">t</a> -> ?sub:<a href="Location.html#TYPEmsg">msg</a> list -> string -> <a href="Location.html#TYPEerror">error</a></code></pre>
<pre><span id="VALerrorf"><span class="keyword">val</span> errorf</span> : <code class="type">?loc:<a href="Location.html#TYPEt">t</a> -><br>       ?sub:<a href="Location.html#TYPEmsg">msg</a> list -><br>       ('a, Format.formatter, unit, <a href="Location.html#TYPEerror">error</a>) format4 -> 'a</code></pre>
<pre><span id="VALerror_of_printer"><span class="keyword">val</span> error_of_printer</span> : <code class="type">?loc:<a href="Location.html#TYPEt">t</a> -><br>       ?sub:<a href="Location.html#TYPEmsg">msg</a> list -><br>       (Format.formatter -> 'a -> unit) -> 'a -> <a href="Location.html#TYPEerror">error</a></code></pre>
<pre><span id="VALerror_of_printer_file"><span class="keyword">val</span> error_of_printer_file</span> : <code class="type">(Format.formatter -> 'a -> unit) -> 'a -> <a href="Location.html#TYPEerror">error</a></code></pre><h2 id="1_Automaticallyreportingerrorsforraisedexceptions">Automatically reporting errors for raised exceptions</h2>
<pre><span id="VALregister_error_of_exn"><span class="keyword">val</span> register_error_of_exn</span> : <code class="type">(exn -> <a href="Location.html#TYPEerror">error</a> option) -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>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 <code class="code">register_error_of_exn</code>.
    The result of the printer is an <code class="code">error</code> value containing
    a location, a message, and optionally sub-messages (each of them
    being located as well).</p>
</div>
</div>

<pre><span id="VALerror_of_exn"><span class="keyword">val</span> error_of_exn</span> : <code class="type">exn -> [ `Already_displayed | `Ok of <a href="Location.html#TYPEerror">error</a> ] option</code></pre>
<pre><span id="EXCEPTIONError"><span class="keyword">exception</span> Error</span> <span class="keyword">of</span> <code class="type"><a href="Location.html#TYPEerror">error</a></code></pre>
<div class="info ">
<div class="info-desc">
<p>Raising <code class="code"><span class="constructor">Error</span>&nbsp;e</code> signals an error <code class="code">e</code>; the exception will be caught and the
   error will be printed.</p>
</div>
</div>

<pre><span id="EXCEPTIONAlready_displayed_error"><span class="keyword">exception</span> Already_displayed_error</span></pre>
<div class="info ">
<div class="info-desc">
<p>Raising <code class="code"><span class="constructor">Already_displayed_error</span></code> signals an error which has already been
   printed. The exception will be caught, but nothing will be printed</p>
</div>
</div>

<pre><span id="VALraise_errorf"><span class="keyword">val</span> raise_errorf</span> : <code class="type">?loc:<a href="Location.html#TYPEt">t</a> -><br>       ?sub:<a href="Location.html#TYPEmsg">msg</a> list -><br>       ('a, Format.formatter, unit, 'b) format4 -> 'a</code></pre>
<pre><span id="VALreport_exception"><span class="keyword">val</span> report_exception</span> : <code class="type">Format.formatter -> exn -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Reraise the exception if it is unknown.</p>
</div>
</div>
</body></html>