Files
endorphin-aster-vm/crates/frontend/src/ast.rs
T
codex-bot f5268d2e09
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 7m55s
feat: generate unified AST and editor contracts from ASDL
2026-10-19 14:31:28 +08:00

35 lines
899 B
Rust

//! 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<SourceLocation> {
self.span().location(source)
}
}
impl Program {
/// Iterate the currently supported top-level function declarations.
pub fn functions(&self) -> impl Iterator<Item = &Function> {
self.declarations.iter().map(|declaration| {
let DeclKind::Function(function) = &declaration.kind;
function
})
}
}