diff options
Diffstat (limited to 'lib/nix/nix.ml')
-rw-r--r-- | lib/nix/nix.ml | 20 |
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 @@ | |||
1 | open Core | ||
2 | module Ast = Types | ||
3 | module Printer = Printer | ||
4 | |||
5 | exception ParseError of string | ||
6 | |||
7 | let 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 | |||
18 | let elaborate = Elaborator.process | ||
19 | |||
20 | exception ElaborateError = Elaborator.ElaborateError | ||