2016-02-18 07:11:59 -08:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1997 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. This file is distributed under the terms of *)
|
|
|
|
(* the GNU Lesser General Public License version 2.1, with the *)
|
|
|
|
(* special exception on linking described in the file LICENSE. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
1997-08-22 01:55:41 -07:00
|
|
|
|
|
|
|
(* Auxiliary type for reporting syntax errors *)
|
|
|
|
|
|
|
|
type error =
|
|
|
|
Unclosed of Location.t * string * Location.t * string
|
2012-10-16 07:04:33 -07:00
|
|
|
| Expecting of Location.t * string
|
2013-04-11 06:52:06 -07:00
|
|
|
| Not_expecting of Location.t * string
|
2009-07-15 07:06:37 -07:00
|
|
|
| Applicative_path of Location.t
|
2012-03-22 19:20:24 -07:00
|
|
|
| Variable_in_scope of Location.t * string
|
1997-08-22 01:55:41 -07:00
|
|
|
| Other of Location.t
|
2014-08-22 06:45:02 -07:00
|
|
|
| Ill_formed_ast of Location.t * string
|
2016-01-05 04:10:25 -08:00
|
|
|
| Invalid_package_type of Location.t * string
|
1997-08-22 01:55:41 -07:00
|
|
|
|
|
|
|
exception Error of error
|
1997-11-12 04:32:53 -08:00
|
|
|
exception Escape_error
|
1997-08-22 01:55:41 -07:00
|
|
|
|
2012-10-16 07:04:33 -07:00
|
|
|
let location_of_error = function
|
|
|
|
| Unclosed(l,_,_,_)
|
|
|
|
| Applicative_path l
|
|
|
|
| Variable_in_scope(l,_)
|
|
|
|
| Other l
|
2013-04-11 06:52:06 -07:00
|
|
|
| Not_expecting (l, _)
|
2014-08-22 06:45:02 -07:00
|
|
|
| Ill_formed_ast (l, _)
|
2016-01-05 04:10:25 -08:00
|
|
|
| Invalid_package_type (l, _)
|
2012-10-16 07:04:33 -07:00
|
|
|
| Expecting (l, _) -> l
|
2014-08-22 06:45:02 -07:00
|
|
|
|
|
|
|
|
|
|
|
let ill_formed_ast loc s =
|
|
|
|
raise (Error (Ill_formed_ast (loc, s)))
|