2023-11-24 04:06:13 +00:00
|
|
|
module Syn = Syn
|
2023-11-29 18:43:14 +00:00
|
|
|
module Ir = Ir
|
|
|
|
|
|
|
|
exception Error of string
|
|
|
|
|
|
|
|
let failf f = Fmt.kstr (fun s -> raise (Error s)) f
|
2023-11-24 04:06:13 +00:00
|
|
|
|
|
|
|
let parse input =
|
|
|
|
let lexbuf = Lexing.from_string input ~with_positions:true in
|
2023-11-29 18:43:14 +00:00
|
|
|
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
|