Skip to content
Rusty EcmaScript Syntax Analyzer
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
benches Next (#29) Jul 5, 2019
examples Next (#29) Jul 5, 2019
src Next (#29) Jul 5, 2019
tests/all Next (#29) Jul 5, 2019
.gitignore partially through spider_monkey bugs Jan 16, 2019
.travis.yml ? Feb 23, 2019 update docs Mar 4, 2019
Cargo.toml Next (#29) Jul 5, 2019 fix: readme examples (#31) Jul 10, 2019
license.txt add gh files Jul 19, 2018 Next (#29) Jul 5, 2019 Next (#29) Jul 5, 2019
package.json adjust testing Oct 15, 2018

travis last commit master


Rust EcmaScript Syntax Analyzer

This project is part of a series of crates designed to enable developers to create JavaScript development tools using the Rust programming language. Rusty ECMA Details

The two major pieces that users will interact with are the Parser struct and the enums defined by resast


The parser struct will be the main way to convert text into an AST. Conveniently Parser implements Iterator over Result<ProgramPart, Error>, this means that you can evaluate your JS in pieces from top to bottom. These pieces will be discussed in more detail in the node section.

Iterator Example

use ressa::Parser;
use resast::ref_tree::prelude::*;

fn main() {
    let js = "function helloWorld() { alert('Hello world'); }";
    let p = Parser::new(&js).unwrap();

    let f = ProgramPart::Decl(
            Function {
                id: Some("helloWorld"),
                params: vec![],
                body: vec![
                            Expr::Call(CallExpr {
                                callee: Box::new(Expr::Ident("alert")),
                                arguments: vec![Expr::Literal(Literal::String("'Hello world'"))],
                generator: false,
                is_async: false,
    for part in p {
        assert_eq!(part.unwrap(), f);

Another way to interact with a Parser would be to utilize the parse method. This method will iterate over all of the found ProgramParts and collect them into a Program,

Parse Example

use ressa::{
use resast::ref_tree::prelude::*;
fn main() {
    let js = "
function Thing() {
    return 'stuff';
    let mut parser = Parser::new(js).expect("Failed to create parser");
    let program = parser.parse().expect("Unable to parse text");
    match program {
        Program::Script(parts) => println!("found a script"),
        Program::Mod(parts) => println!("found an es6 module"),

Once you get to the inner parts of a Program you have a Vec<ProgramPart> which will operate the same as the iterator example

Rusty ECMA Details

The Rust ECMA Crates

Why So Many?

While much of what each crate provides is closely coupled with the other crates, the main goal is to provide the largest amount of customizability. For example, someone writing a fuzzer would only need the RESAST and RESW, it seems silly to require that they also pull in RESS and RESSA needlessly.

You can’t perform that action at this time.