spooky/lib/spooky.ml

39 lines
1.0 KiB
OCaml

module Ast = Ast
module Lexer = Lexer
module Parser = Parser
module Typechecker = Typechecker
module Generator_json = Generator_json
module Generator_c = Generator_c
module Module_system = Module_system
type program = Ast.program
let parse_string = Parser.parse_string
let string_of_program = Ast.string_of_program
let type_check = Typechecker.type_check
let load_source_with_imports = Module_system.load_source_with_imports
let parse_file path =
match load_source_with_imports path with
| Error e -> Error e
| Ok src -> parse_string src
let parse_and_type_check src =
match parse_string src with
| Error e -> Error e
| Ok prog ->
(match type_check prog with
| Ok annotated -> Ok annotated
| Error e -> Error ("type error: " ^ e))
let parse_and_type_check_file path =
match parse_file path with
| Error e -> Error e
| Ok prog ->
(match type_check prog with
| Ok annotated -> Ok annotated
| Error e -> Error ("type error: " ^ e))
let generate_json = Generator_json.generate
let generate_c = Generator_c.generate