1515
1616open Lexing
1717
18- let absname = ref false
19- (* This reference should be in Clflags, but it would create an additional
20- dependency and make bootstrapping Camlp4 more difficult. *)
21-
2218type t = Warnings .loc = {
2319 loc_start : position ;
2420 loc_end : position ;
@@ -31,72 +27,18 @@ let in_file name =
3127
3228let none = in_file " _none_"
3329
34- let curr lexbuf =
35- {
36- loc_start = lexbuf.lex_start_p;
37- loc_end = lexbuf.lex_curr_p;
38- loc_ghost = false ;
39- }
40-
41- let init lexbuf fname =
42- lexbuf.lex_curr_p < -
43- {pos_fname = fname; pos_lnum = 1 ; pos_bol = 0 ; pos_cnum = 0 }
44-
45- let symbol_rloc () =
46- {
47- loc_start = Parsing. symbol_start_pos () ;
48- loc_end = Parsing. symbol_end_pos () ;
49- loc_ghost = false ;
50- }
51-
52- let symbol_gloc () =
53- {
54- loc_start = Parsing. symbol_start_pos () ;
55- loc_end = Parsing. symbol_end_pos () ;
56- loc_ghost = true ;
57- }
58-
59- let rhs_loc n =
60- {
61- loc_start = Parsing. rhs_start_pos n;
62- loc_end = Parsing. rhs_end_pos n;
63- loc_ghost = false ;
64- }
65-
6630let input_name = ref " _none_"
67- let input_lexbuf = ref (None : lexbuf option )
6831let set_input_name name = if name <> " " then input_name := name
6932(* Terminal info *)
7033
71- let num_loc_lines = ref 0 (* number of lines already printed after input *)
72-
7334(* Print the location in some way or another *)
7435
7536open Format
7637
77- let absolute_path s =
78- (* This function could go into Filename *)
79- let open Filename in
80- let s = if is_relative s then concat (Sys. getcwd () ) s else s in
81- (* Now simplify . and .. components *)
82- let rec aux s =
83- let base = basename s in
84- let dir = dirname s in
85- if dir = s then dir
86- else if base = current_dir_name then aux dir
87- else if base = parent_dir_name then dirname (aux dir)
88- else concat (aux dir) base
89- in
90- aux s
91-
92- let show_filename file =
93- let file = if file = " _none_" then ! input_name else file in
94- if ! absname then absolute_path file else file
38+ let show_filename file = if file = " _none_" then ! input_name else file
9539
9640let print_filename ppf file = Format. fprintf ppf " %s" (show_filename file)
9741
98- let reset () = num_loc_lines := 0
99-
10042(* return file, line, char from the given position *)
10143let get_pos_info pos = (pos.pos_fname, pos.pos_lnum, pos.pos_cnum - pos.pos_bol)
10244
@@ -206,21 +148,6 @@ let print ?(src = None) ~message_kind intro ppf (loc : t) =
206148 | Sys_error _ ->
207149 () )
208150
209- let error_prefix = " Error"
210-
211- let print_error_prefix ppf =
212- setup_colors () ;
213- fprintf ppf " @{<error>%s@}" error_prefix
214-
215- let print_compact ppf loc =
216- let file, line, startchar = get_pos_info loc.loc_start in
217- let endchar = loc.loc_end.pos_cnum - loc.loc_start.pos_cnum + startchar in
218- fprintf ppf " %a:%i" print_filename file line;
219- if startchar > = 0 then fprintf ppf " ,%i--%i" startchar endchar
220-
221- let print_error intro ppf loc =
222- fprintf ppf " %a%t:" (print ~message_kind: `error intro) loc print_error_prefix
223-
224151let default_warning_printer loc ppf w =
225152 match Warnings. report w with
226153 | `Inactive -> ()
@@ -241,10 +168,6 @@ let print_warning loc ppf w = !warning_printer loc ppf w
241168let formatter_for_warnings = ref err_formatter
242169let prerr_warning loc w = print_warning loc ! formatter_for_warnings w
243170
244- let echo_eof () =
245- print_newline () ;
246- incr num_loc_lines
247-
248171type 'a loc = {txt : 'a ; loc : t }
249172
250173let mkloc txt loc = {txt; loc}
0 commit comments