16 lines
425 B
OCaml
16 lines
425 B
OCaml
module Syn = Syn
|
|
module Ir = Ir
|
|
|
|
exception Error of string
|
|
|
|
let failf f = Fmt.kstr (fun s -> raise (Error s)) f
|
|
|
|
let parse input =
|
|
let lexbuf = Lexing.from_string input ~with_positions:true in
|
|
try Parser.modl Lexer.read lexbuf with
|
|
| Parser.Error -> failf "syntax error"
|
|
| Lexer.Error msg -> failf "syntax error: %s" msg
|
|
|
|
let compile syn =
|
|
try Anf_pass.anf syn with Failure msg -> failf "compilation error: %s" msg
|