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
  • Coverage
  • 100%
    398 out of 398 items documented1 out of 100 items with examples
  • Size
  • Source code size: 120.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.55 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MavenRain

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 is the foundation crate of a multi-crate comp-cat-rs reformulation of a JavaScript engine targeting Tauri integration. Five preceding falsification spikes (lambda-cat, lambda-ref-cat, lambda-obj-cat, lambda-throw-cat, lambda-async-cat) confirmed the idioms scale to every JS-distinctive runtime concern; this crate is the construction-phase artifact that defines the AST contract downstream crates build against.

Shape

  • Every AST node carries source-span information via Spanned<T>.
  • Recursive positions use Box<T> for indirection; collections use Vec<T>.
  • Variants follow ESTree naming, shortened to their core noun when used as enum variants.
  • Operators are factored into separate enums (BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator, AssignmentOperator) rather than expanded into the expression variants.

Coverage

ES2024 surface: literals (number, string, boolean, null, BigInt, regex, template), identifiers, all expression and statement forms, classes (including private fields, static blocks, getters/setters), modules (import/export), async/await, generators, destructuring, optional chaining, nullish coalescing, dynamic import, meta-property.

Excluded: TypeScript syntax, JSX, stage-3 proposals (decorators, pipeline operator) that have not yet finalized.

Usage

# 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 plus = Expression::new(
    ExpressionKind::Binary {
        operator: BinaryOperator::Add,
        left: Box::new(x),
        right: Box::new(one),
    },
    span,
);
println!("{plus}");
# Ok(())
# }

Building

cargo build
cargo test
RUSTFLAGS="-D warnings" cargo clippy --all-targets

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.