Skip to content
/ js Public

JavaScript Parser implemented in Rust

nilsmartel/js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust JavaScript Parser

All Structures and Parser can be found in src/parse/* the Parser itself isn't complete, but in a wide variety of cases it already works.

Further testing will make it work better

Exampels can be found in results files.

A small example of the Parser in action:

let sayHello = () => {
    console.log("Hello, World")
}

This small JavaScript code will yield this enormous AST:

        FunctionBody {
            scope: [
                Variable {
                    identifier: Identifier(
                        "sayHello",
                    ),
                    assign: Some(
                        Value(
                            Closure {
                                args: [],
                                body: FunctionBody {
                                    scope: [],
                                    functions: [],
                                    instructions: [
                                        Expression(
                                            Identifier {
                                                path: [
                                                    Identifier(
                                                        "console",
                                                    ),
                                                    Identifier(
                                                        "log",
                                                    ),
                                                ],
                                                action: Some(
                                                    Call {
                                                        arguments: [
                                                            Value(
                                                                String(
                                                                    StringTemplate {
                                                                        start: "Hello, World",
                                                                        end: [],
                                                                    },
                                                                ),
                                                            ),
                                                        ],
                                                    },
                                                ),
                                            },
                                        ),
                                    ],
                                },
                            },
                        ),
                    ),
                },
            ],
            functions: [],
            instructions: [],
        }

Current Task

  • Implement Bytecode compilation
  • Implement VM

TODO

  • Better Tests

About

JavaScript Parser implemented in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages