//! AST types and walkers generated from the single Endor.asdl schema. //! Runtime objects remain in the objects crate. mod generated; pub mod visitor; mod wire; pub use generated::*; pub use wire::AstError; use crate::{SourceLocation, Span}; /// A syntax node's half-open byte range in its original UTF-8 source. pub trait Spanned { fn span(&self) -> Span; fn source_text<'a>(&self, source: &'a str) -> Option<&'a str> { self.span().slice(source) } fn location(&self, source: &str) -> Option { self.span().location(source) } } impl Program { /// Iterate the currently supported top-level function declarations. pub fn functions(&self) -> impl Iterator { self.declarations.iter().map(|declaration| { let DeclKind::Function(function) = &declaration.kind; function }) } }