ecma-syntax-cat 0.1.0

ECMAScript abstract syntax tree as comp-cat-rs-idiomatic Rust types. ESTree-shaped, ES2024-complete, no panics, no Rc, no interior mutability. Foundation crate for boa-cat and related downstream tooling.
Documentation
//! # ecma-syntax-cat
//!
//! ECMAScript abstract syntax tree as comp-cat-rs-idiomatic Rust types.
//! ESTree-shaped, ES2024-complete, no panics, no `Rc`/`Arc`/`RefCell`, no
//! interior mutability, no `unsafe`.
//!
//! This crate is the foundation layer of a multi-crate reformulation of a
//! JavaScript engine targeting Tauri integration.  It deliberately has no
//! runtime dependencies so that every downstream layer (lexer, parser,
//! interpreter, type checker, source-map generator) can adopt it without
//! inheriting our framework choices.
//!
//! ## Shape
//!
//! Every AST node is a [`Spanned<T>`] value: a kind enum paired with a
//! [`Span`] denoting the source range it was parsed from.  Recursive
//! positions are `Box<T>`; collections are `Vec<T>`.  Variant fields are
//! named on the variant rather than in per-variant structs except where
//! the variant has enough non-trivial fields to warrant its own type
//! (`Function`, `ArrowFunction`, `Class`, `VariableDeclaration`).
//!
//! ## Quick start
//!
//! ```
//! # fn main() -> Result<(), ecma_syntax_cat::error::Error> {
//! use ecma_syntax_cat::expression::{Expression, ExpressionKind};
//! use ecma_syntax_cat::identifier::Identifier;
//! use ecma_syntax_cat::literal::Literal;
//! use ecma_syntax_cat::operator::BinaryOperator;
//! use ecma_syntax_cat::span::Span;
//!
//! let span = Span::synthetic();
//! let x = Expression::new(
//!     ExpressionKind::Identifier(Identifier::new("x")?),
//!     span,
//! );
//! let one = Expression::new(
//!     ExpressionKind::Literal(Literal::number(1.0)),
//!     span,
//! );
//! let sum = Expression::new(
//!     ExpressionKind::Binary {
//!         operator: BinaryOperator::Add,
//!         left: Box::new(x),
//!         right: Box::new(one),
//!     },
//!     span,
//! );
//! assert_eq!(format!("{sum}"), "(x + 1)");
//! # Ok(())
//! # }
//! ```
//!
//! [`Spanned<T>`]: crate::span::Spanned
//! [`Span`]: crate::span::Span

pub mod class;
pub mod declaration;
pub mod error;
pub mod expression;
pub mod function;
pub mod identifier;
pub mod literal;
pub mod module;
pub mod operator;
pub mod pattern;
pub mod program;
pub mod span;
pub mod statement;