pub mod analyzer; pub mod binder; pub mod call_hooks; pub mod module_loader; pub mod captures; pub mod dumper; pub mod emitter; pub mod lambda_collector; pub mod macros; pub mod optimizer; pub mod specializer; pub mod lowering; pub mod type_checker; pub use crate::ast::nodes::*; pub use binder::*; pub use captures::*; pub use dumper::*; pub use macros::*; pub use optimizer::*; pub use specializer::*; pub use lowering::*; pub use type_checker::*; use crate::ast::diagnostics::Diagnostics; /// The result of a compilation pass: either a typed AST or a set of diagnostics. pub struct CompilationResult { pub ast: Option, pub diagnostics: Diagnostics, } impl CompilationResult { pub fn success(ast: TypedNode) -> Self { Self { ast: Some(ast), diagnostics: Diagnostics::new(), } } pub fn error(msg: impl Into) -> Self { let mut diag = Diagnostics::new(); diag.push_error(msg, None); Self { ast: None, diagnostics: diag, } } pub fn into_result(self) -> Result { if self.diagnostics.has_errors() { Err(self.diagnostics.format_errors()) } else if let Some(ast) = self.ast { Ok(ast) } else { Err("Compilation failed without diagnostics".to_string()) } } }