1997-08-22 01:55:41 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Objective Caml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1997 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1997-08-22 01:55:41 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* Auxiliary type for reporting syntax errors *)
|
|
|
|
|
1999-11-08 09:06:33 -08:00
|
|
|
open Formatmsg
|
1997-08-22 01:55:41 -07:00
|
|
|
|
|
|
|
type error =
|
|
|
|
Unclosed of Location.t * string * Location.t * string
|
|
|
|
| Other of Location.t
|
|
|
|
|
|
|
|
exception Error of error
|
1997-11-12 04:32:53 -08:00
|
|
|
exception Escape_error
|
1997-08-22 01:55:41 -07:00
|
|
|
|
|
|
|
let report_error = function
|
|
|
|
Unclosed(opening_loc, opening, closing_loc, closing) ->
|
1997-11-12 04:32:53 -08:00
|
|
|
if String.length !Location.input_name = 0
|
|
|
|
&& Location.highlight_locations opening_loc closing_loc
|
2000-02-08 12:00:06 -08:00
|
|
|
then printf "Syntax error: '%s' expected, \
|
|
|
|
the highlighted '%s' might be unmatched" closing opening
|
|
|
|
else begin
|
1997-11-12 04:32:53 -08:00
|
|
|
Location.print closing_loc;
|
2000-02-08 12:00:06 -08:00
|
|
|
printf "Syntax error: '%s' expected@?" closing;
|
1997-08-22 01:55:41 -07:00
|
|
|
Location.print opening_loc;
|
2000-02-08 12:00:06 -08:00
|
|
|
printf "This '%s' might be unmatched" opening
|
1997-08-22 01:55:41 -07:00
|
|
|
end
|
|
|
|
| Other loc ->
|
|
|
|
Location.print loc;
|
|
|
|
print_string "Syntax error"
|
|
|
|
|
|
|
|
|