spooky/lib/spooky.ml

24 lines
609 B
OCaml
Raw Normal View History

2026-04-29 15:50:03 +00:00
module Ast = Ast
module Lexer = Lexer
module Parser = Parser
module Typechecker = Typechecker
module Generator_json = Generator_json
module Generator_c = Generator_c
2026-04-29 15:25:15 +00:00
2026-04-29 15:50:03 +00:00
type program = Ast.program
2026-04-29 15:25:15 +00:00
2026-04-29 15:50:03 +00:00
let parse_string = Parser.parse_string
let string_of_program = Ast.string_of_program
let type_check = Typechecker.type_check
2026-04-29 15:25:15 +00:00
let parse_and_type_check src =
match parse_string src with
2026-04-29 15:50:03 +00:00
| Error e -> Error e
2026-04-29 15:25:15 +00:00
| Ok prog ->
(match type_check prog with
2026-04-29 15:50:03 +00:00
| Ok () -> Ok prog
| Error e -> Error ("type error: " ^ e))
let generate_json = Generator_json.generate
let generate_c = Generator_c.generate