blob: 6b87819b0552f3b2d3e8702928688d522b97436e (
plain)
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
|
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1997 Institut National de Recherche en Informatique et *)
(* Automatique. Distributed only by permission. *)
(* *)
(***********************************************************************)
(* $Id$ *)
(* Auxiliary type for reporting syntax errors *)
open Format
type error =
Unclosed of Location.t * string * Location.t * string
| Other of Location.t
exception Error of error
let report_error = function
Unclosed(opening_loc, opening, closing_loc, closing) ->
if String.length !Location.input_name > 0 then begin
Location.print closing_loc;
print_string "Syntax error: missing '";
print_string closing;
print_string "'"; force_newline();
Location.print opening_loc;
print_string "This is the location of the unmatched '";
print_string opening;
print_string "'"
end else begin
Location.print opening_loc;
print_string "Syntax error: this '";
print_string opening;
print_string "' has no matching '";
print_string closing;
print_string "'"
end
| Other loc ->
Location.print loc;
print_string "Syntax error"
|