ecma-parse-cat 0.1.0

ECMAScript parser consuming ecma-lex-cat tokens and producing ecma-syntax-cat Program ASTs. Comprehensive ES2024 surface (classes, modules, destructuring, async/await, optional chaining, templates). Recursive-descent with precedence climbing.
docs.rs failed to build ecma-parse-cat-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

ecma-parse-cat

ECMAScript parser consuming ecma-lex-cat tokens and producing ecma-syntax-cat Program ASTs.

The third layer of a multi-crate comp-cat-rs reformulation of a JavaScript engine targeting Tauri integration.

Coverage

  • All statement forms (block, if, switch, for / for-in / for-of / for-await, while, do-while, return, throw, try/catch/finally, break, continue, labeled, expression, empty, debugger).
  • All declaration forms (var/let/const, function, class).
  • Classes: constructor, methods, getters, setters, public fields, private fields, static blocks.
  • Modules: default/named/namespace imports, named/default/declaration/re-export-all exports.
  • All expression operators with proper precedence climbing.
  • Arrow functions via paren lookahead (x => x, (x) => x, (x, y) => x + y, ({ a, b }) => a).
  • Destructuring patterns (array, object, rest, default).
  • Template literals with interpolation.
  • Optional chaining (?.) and nullish coalescing (??).
  • async/await/yield (not context-checked v0).

ASI is partial: semicolons are optional before } and EOF; required elsewhere. Full newline-based ASI is a v0.2 TODO.

Usage

# fn main() -> Result<(), ecma_parse_cat::error::Error> {
use ecma_parse_cat::parse_script;

let program = parse_script("let x = 1 + 2;")?;
println!("{program}");
# 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.