aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nix/nix.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nix/nix.ml')
-rw-r--r--lib/nix/nix.ml20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/nix/nix.ml b/lib/nix/nix.ml
new file mode 100644
index 0000000..39dc94c
--- /dev/null
+++ b/lib/nix/nix.ml
@@ -0,0 +1,20 @@
1open Core
2module Ast = Types
3module Printer = Printer
4
5exception ParseError of string
6
7let parse ~filename (data : string) =
8 let lexbuf = Lexer.set_filename filename (Lexing.from_string data)
9 and q, s = (Stdlib.Queue.create (), ref []) in
10 try Parser.main (Lexer.next_token q s) lexbuf with
11 | Lexer.Error msg ->
12 let msg' = String.rstrip msg in
13 raise (ParseError (sprintf "Lexing error: %s" msg'))
14 | Parser.Error ->
15 let msg = sprintf "Parse error at %s" (Lexer.print_position lexbuf) in
16 raise (ParseError msg)
17
18let elaborate = Elaborator.process
19
20exception ElaborateError = Elaborator.ElaborateError