aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ddl/parser.ml9
-rw-r--r--lib/dml/parser.ml9
-rw-r--r--lib/drl/parser.ml9
-rw-r--r--lib/icl/parser.ml9
-rw-r--r--lib/prl/parser.ml7
-rw-r--r--lib/scl/parser.ml11
6 files changed, 36 insertions, 18 deletions
diff --git a/lib/ddl/parser.ml b/lib/ddl/parser.ml
index 5678b47..49fa7e0 100644
--- a/lib/ddl/parser.ml
+++ b/lib/ddl/parser.ml
@@ -1,13 +1,16 @@
-type error = ParseError of string
+module Error = struct
+ open Condition
+ let parse_error msg = condition "parse-error" ("message" |=| (of_string msg))
+end
let of_sexp sexp =
match Ast.statement_of_sexp sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let of_string s =
match Sexplib.Sexp.of_string s |> Ast.statement_of_sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum
diff --git a/lib/dml/parser.ml b/lib/dml/parser.ml
index 5678b47..49fa7e0 100644
--- a/lib/dml/parser.ml
+++ b/lib/dml/parser.ml
@@ -1,13 +1,16 @@
-type error = ParseError of string
+module Error = struct
+ open Condition
+ let parse_error msg = condition "parse-error" ("message" |=| (of_string msg))
+end
let of_sexp sexp =
match Ast.statement_of_sexp sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let of_string s =
match Sexplib.Sexp.of_string s |> Ast.statement_of_sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum
diff --git a/lib/drl/parser.ml b/lib/drl/parser.ml
index 76d4b4e..df8e485 100644
--- a/lib/drl/parser.ml
+++ b/lib/drl/parser.ml
@@ -1,13 +1,16 @@
-type error = ParseError of string
+module Error = struct
+ open Condition
+ let parse_error msg = condition "parse-error" ("message" |=| (of_string msg))
+end
let of_sexp sexp =
match Ast.query_of_sexp sexp with
| q -> Ok q
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let of_string s =
match Sexplib.Sexp.of_string s |> Ast.query_of_sexp with
| q -> Ok q
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let to_string q = Ast.sexp_of_query q |> Sexplib.Sexp.to_string_hum
diff --git a/lib/icl/parser.ml b/lib/icl/parser.ml
index 5678b47..49fa7e0 100644
--- a/lib/icl/parser.ml
+++ b/lib/icl/parser.ml
@@ -1,13 +1,16 @@
-type error = ParseError of string
+module Error = struct
+ open Condition
+ let parse_error msg = condition "parse-error" ("message" |=| (of_string msg))
+end
let of_sexp sexp =
match Ast.statement_of_sexp sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let of_string s =
match Sexplib.Sexp.of_string s |> Ast.statement_of_sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum
diff --git a/lib/prl/parser.ml b/lib/prl/parser.ml
index 17102a4..59cbceb 100644
--- a/lib/prl/parser.ml
+++ b/lib/prl/parser.ml
@@ -1,4 +1,7 @@
-type error = ParseError of string
+module Error = struct
+ open Condition
+ let parse_error msg = condition "parse-error" ("message" |=| (of_string msg))
+end
let of_sexp sexp =
let sexp =
@@ -6,7 +9,7 @@ let of_sexp sexp =
in
match Ast.statement_of_sexp sexp with
| stmt -> Ok stmt
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
let of_string s = of_sexp (Sexplib.Sexp.of_string s)
let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum
diff --git a/lib/scl/parser.ml b/lib/scl/parser.ml
index 3e9c4ed..86c3f99 100644
--- a/lib/scl/parser.ml
+++ b/lib/scl/parser.ml
@@ -1,19 +1,22 @@
-type error = ParseError of string
+module Error = struct
+ open Condition
+ let parse_error msg = condition "parse-error" ("message" |=| (of_string msg))
+end
let validate = function
| (Ast.Begin { limit = Some limit; _ } | Ast.Fetch { limit = Some limit; _ })
when limit <= 0 ->
- Error (ParseError "The provision of `limit` is expected to be positive.")
+ Error (Error.parse_error "The provision of `limit` is expected to be positive.")
| stmt -> Ok stmt
let of_sexp sexp =
match Ast.statement_of_sexp sexp with
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
| stmt -> validate stmt
let of_string s =
match Sexplib.Sexp.of_string s |> Ast.statement_of_sexp with
- | exception exn -> Error (ParseError (Printexc.to_string exn))
+ | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
| stmt -> validate stmt
let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum