1
- (* open Misc
2
- open Asttypes
3
- open Parsetree
4
- open Types
5
- open Typedtree
6
- open Btype
7
- open Ctype *)
8
1
9
- open Format
10
- (* open Printtyp *)
11
2
12
- open Location
3
+ let fprintf = Format. fprintf
4
+
5
+
13
6
14
7
let file_lines filePath =
15
- (* open_in_bin works on windows, as opposed to open_in, afaik? *)
16
8
let chan = open_in_bin filePath in
17
9
let lines = ref [] in
18
10
try
@@ -37,11 +29,11 @@ let print_filename ppf file =
37
29
| "" -> Format. fprintf ppf " (No file name)"
38
30
| real_file -> Format. fprintf ppf " %s" (Location. show_filename real_file)
39
31
40
- let print_loc ~normalizedRange ppf loc =
32
+ let print_loc ~normalizedRange ppf ( loc : Location.t ) =
41
33
setup_colors () ;
42
34
let (file, _, _) = Location. get_pos_info loc.loc_start in
43
35
if file = " //toplevel//" then begin
44
- if highlight_locations ppf [loc] then () else
36
+ if Location. highlight_locations ppf [loc] then () else
45
37
fprintf ppf " Characters %i-%i"
46
38
loc.loc_start.pos_cnum loc.loc_end.pos_cnum
47
39
end else
@@ -59,9 +51,9 @@ let print_loc ~normalizedRange ppf loc =
59
51
fprintf ppf " @{<filename>%a@}%a" print_filename file dim_loc normalizedRange
60
52
;;
61
53
62
- let print ~message_kind intro ppf loc =
54
+ let print ~message_kind intro ppf ( loc : Location.t ) =
63
55
if loc.loc_start.pos_fname = " //toplevel//"
64
- && highlight_locations ppf [loc] then ()
56
+ && Location. highlight_locations ppf [loc] then ()
65
57
else
66
58
begin match message_kind with
67
59
| `warning -> fprintf ppf " @[@{<info>%s@}@]@," intro
@@ -155,17 +147,17 @@ let print_phanton_error_prefix ppf =
155
147
(see super_error_reporter above) *)
156
148
Format. pp_print_as ppf 2 " "
157
149
158
- let errorf ?(loc = none) ?(sub = [] ) ?(if_highlight = " " ) fmt =
150
+ let errorf ?(loc = Location. none) ?(sub = [] ) ?(if_highlight = " " ) fmt =
159
151
Location. pp_ksprintf
160
152
~before: print_phanton_error_prefix
161
- (fun msg -> {loc; msg; sub; if_highlight})
153
+ (fun msg -> Location. {loc; msg; sub; if_highlight})
162
154
fmt
163
155
164
156
let error_of_printer loc print x =
165
157
errorf ~loc " %a@?" print x
166
158
167
159
let error_of_printer_file print x =
168
- error_of_printer (in_file ! input_name) print x
160
+ error_of_printer (Location. in_file ! Location. input_name) print x
169
161
170
162
(* This will be called in super_main. This is how you override the default error and warning printers *)
171
163
let setup () =
0 commit comments