pub mod aot;
pub mod ast;
pub mod banner;
pub mod builtins;
pub mod cache;
pub mod cli;
pub mod compiler;
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> {
compiler::compile(&parser::parse(src)?)
}
pub fn eval_str(src: &str) -> Result<Value, String> {
host::reset_host();
run_compiled(compile(src)?)
}
pub fn eval_quiet(src: &str) -> Result<Value, String> {
host::reset_host();
host::with_host(|h| h.echo = false);
run_compiled(compile(src)?)
}
pub fn run_compiled(prog: compiler::Program) -> Result<Value, String> {
host::with_host(|h| h.load_closures(prog.closures));
host::run_main(prog.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_quiet(src)?;
Ok(builtins::format_value(&v).join("\n").trim_end().to_string())
}