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 *)
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
open Format
|
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
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let report_error ppf = function
|
|
|
|
| Unclosed(opening_loc, opening, closing_loc, closing) ->
|
1997-11-12 04:32:53 -08:00
|
|
|
if String.length !Location.input_name = 0
|
2002-04-18 01:50:43 -07:00
|
|
|
&& Location.highlight_locations ppf opening_loc closing_loc
|
2000-03-06 14:12:09 -08:00
|
|
|
then fprintf ppf "Syntax error: '%s' expected, \
|
2000-02-08 12:00:06 -08:00
|
|
|
the highlighted '%s' might be unmatched" closing opening
|
|
|
|
else begin
|
2000-04-12 02:54:53 -07:00
|
|
|
fprintf ppf "%aSyntax error: '%s' expected@."
|
2000-03-06 14:12:09 -08:00
|
|
|
Location.print closing_loc closing;
|
|
|
|
fprintf ppf "%aThis '%s' might be unmatched"
|
|
|
|
Location.print opening_loc opening
|
1997-08-22 01:55:41 -07:00
|
|
|
end
|
|
|
|
| Other loc ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "%aSyntax error" Location.print loc
|
1997-08-22 01:55:41 -07:00
|
|
|
|
|
|
|
|