pub mod aot;
pub mod ast;
pub mod banner;
pub mod builtins;
pub mod cache;
pub mod cli;
pub mod compiler;
pub mod dap;
pub mod host;
pub mod intercepts;
pub mod lexer;
pub mod lsp;
pub mod parser;
pub mod repl;
pub use fusevm::Value;
pub fn compile(src: &str) -> Result<compiler::Program, String> {
let stmts = parser::parse(src)?;
compiler::compile(&stmts)
}
pub fn eval_str(src: &str) -> Result<Value, String> {
host::reset_host();
run_compiled(compile(src)?)
}
pub fn run_compiled(prog: compiler::Program) -> Result<Value, String> {
let compiler::Program {
main,
methods,
classes,
begins,
procs,
} = prog;
host::with_host(|h| h.load_program(methods, classes, begins, procs));
host::run_main(main)
}
pub fn eval_file(path: &str) -> Result<Value, String> {
let src = std::fs::read_to_string(path).map_err(|e| format!("cannot read {path}: {e}"))?;
eval_str(&src)
}
pub fn eval_to_string(src: &str) -> Result<String, String> {
let v = eval_str(src)?;
Ok(host::with_host(|h| h.inspect(&v)))
}