aboutsummaryrefslogtreecommitdiffstats
path: root/lib/icl/parser.ml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/icl/parser.ml5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/icl/parser.ml b/lib/icl/parser.ml
index a7981c0..28f8b6c 100644
--- a/lib/icl/parser.ml
+++ b/lib/icl/parser.ml
@@ -1,5 +1,10 @@
type error = ParseError of string
+let of_sexp sexp =
+ match Ast.statement_of_sexp sexp with
+ | stmt -> Ok stmt
+ | exception exn -> Error (ParseError (Printexc.to_string exn))
+
let of_string s =
match Sexplib.Sexp.of_string s |> Ast.statement_of_sexp with
| stmt -> Ok stmt