module Ast = Spice_syntax.Ast module Code = Spice_runtime.Code module Value = Spice_runtime.Value 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 Spice_syntax.Parser.modl Spice_syntax.Lexer.read lexbuf with | Spice_syntax.Parser.Error -> failf "syntax error" | Spice_syntax.Lexer.Error msg -> failf "syntax error: %s" msg let compile ast = Spice_compile.Bcc.compile ast let run prog = try Spice_runtime.Interp.run_program prog with Spice_runtime.Interp.Runtime_error msg -> failf "runtime error: %s" msg