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