1997-08-22 01:55:41 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1997-08-22 01:55:41 -07:00
|
|
|
(* *)
|
|
|
|
(* 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
|
2009-07-15 07:06:37 -07:00
|
|
|
| Applicative_path of Location.t
|
1997-08-22 01:55:41 -07:00
|
|
|
| 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) ->
|
2011-08-04 07:59:13 -07:00
|
|
|
if !Location.input_name = "//toplevel//"
|
|
|
|
&& 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@."
|
2007-12-04 05:38:58 -08:00
|
|
|
Location.print_error closing_loc closing;
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "%aThis '%s' might be unmatched"
|
2007-12-04 05:38:58 -08:00
|
|
|
Location.print_error opening_loc opening
|
1997-08-22 01:55:41 -07:00
|
|
|
end
|
2009-07-15 07:06:37 -07:00
|
|
|
| Applicative_path loc ->
|
|
|
|
fprintf ppf "%aSyntax error: applicative paths of the form F(X).t are not supported when the option -no-app-func is set."
|
|
|
|
Location.print_error loc
|
1997-08-22 01:55:41 -07:00
|
|
|
| Other loc ->
|
2007-12-04 05:38:58 -08:00
|
|
|
fprintf ppf "%aSyntax error" Location.print_error loc
|