pub mod aot;
pub mod aot_runtime;
pub mod banner;
pub mod bundle;
pub mod catcode;
pub mod cli;
pub mod compiler;
pub mod corpus;
pub mod dap;
pub mod docs;
pub mod document;
pub mod dvi;
pub mod expand;
pub mod format;
pub mod geturl;
pub mod intercepts;
pub mod io;
pub mod ir;
pub mod lexer;
pub mod lower;
pub mod lsp;
pub mod parallel;
pub mod repl;
pub mod runtime;
pub mod rust_ffi;
pub mod script_cache;
pub mod status;
pub mod tiers;
pub mod token;
pub use expand::{Engine, TexError};
pub fn run_messages_list(src: &str) -> Result<Vec<String>, TexError> {
let chunk = compile(src)?;
crate::runtime::run(chunk).map_err(TexError)
}
pub fn run_messages(src: &str) -> Result<String, TexError> {
let chunk = compile(src)?;
let msgs = crate::runtime::run(chunk).map_err(TexError)?;
Ok(msgs.join(" "))
}
pub fn run_messages_cached(path: &std::path::Path, src: &str) -> Result<String, TexError> {
let chunk = compile_cached(path, src)?;
let msgs = crate::runtime::run(chunk).map_err(TexError)?;
Ok(msgs.join(" "))
}
pub fn compile_cached(path: &std::path::Path, src: &str) -> Result<fusevm::Chunk, TexError> {
if let Some(chunk) = crate::script_cache::try_load(path) {
return Ok(chunk);
}
let chunk = compile(src)?;
crate::script_cache::store(path, &chunk);
Ok(chunk)
}
pub fn compile(src: &str) -> Result<fusevm::Chunk, TexError> {
let src = crate::rust_ffi::desugar(src);
let cmds = crate::lower::Lowerer::new().lower(&src)?;
Ok(crate::compiler::Compiler::new().compile(&cmds))
}
pub fn source_ends_run(src: &str) -> bool {
let src = crate::rust_ffi::desugar(src);
let mut lowerer = crate::lower::Lowerer::new();
let _ = lowerer.lower(&src);
lowerer.ended
}
pub fn compile_located(src: &str) -> Result<fusevm::Chunk, (TexError, u32)> {
let src = crate::rust_ffi::desugar(src);
let cmds = crate::lower::Lowerer::new().lower_located(&src)?;
Ok(crate::compiler::Compiler::new().compile(&cmds))
}
pub fn compile_debug(src: &str) -> Result<fusevm::Chunk, TexError> {
let src = crate::rust_ffi::desugar(src);
let cmds = crate::lower::Lowerer::new().lower(&src)?;
Ok(crate::compiler::Compiler::new_debug().compile(&cmds))
}
pub fn run_messages_debug(src: &str) -> Result<String, TexError> {
let chunk = compile_debug(src)?;
let msgs = crate::runtime::run_debug(chunk, crate::dap::on_debug_line).map_err(TexError)?;
Ok(msgs.join(" "))
}