From ba61dfd69504ec6263a9dee9931d93adeb6f3142 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 7 Jul 2025 21:52:08 +0200 Subject: Initialize repository --- lib/nix/nix.ml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/nix/nix.ml (limited to 'lib/nix/nix.ml') 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 @@ +open Core +module Ast = Types +module Printer = Printer + +exception ParseError of string + +let parse ~filename (data : string) = + let lexbuf = Lexer.set_filename filename (Lexing.from_string data) + and q, s = (Stdlib.Queue.create (), ref []) in + try Parser.main (Lexer.next_token q s) lexbuf with + | Lexer.Error msg -> + let msg' = String.rstrip msg in + raise (ParseError (sprintf "Lexing error: %s" msg')) + | Parser.Error -> + let msg = sprintf "Parse error at %s" (Lexer.print_position lexbuf) in + raise (ParseError msg) + +let elaborate = Elaborator.process + +exception ElaborateError = Elaborator.ElaborateError -- cgit v1.2.3