thegreatercurve / okapi

A lightweight performant JavaScript parser for Rust and WebAssembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Okapi JS Parser

Note

This is a parser is still a work-in-progress and should not be used in production.

A lightweight but production-grade JavaScript parser for Rust and WebAssembly.

The library fully supports ECMAScript 2024 and it outputs it's Abstract Syntax Tree (AST) as either normal ESTree compliant structs or as JSON using serde_json.

ESTree is a community-maintained and widely-used standard for ASTs, and is the same output as most other JavaScript parsers.

Below are listed some of the aims and achievements of this project:

Usage

use okapi_js_parser::Parser;

let source_str: &str = ...

let mut parser = Parser::new(source_str);

match parser.parse_script() {
    Ok(program) => ...,
    Err(err) => ...,
}

Tests

To run the local parser and lexer tests:

cargo test

To run the tests for Test262:

cargo run -p okapi_test262

Playground

The local web playground to test the parser functionality can be found in ./playground.

Instructions on how to set-up the playground can be found in the associated README.md.

About

A lightweight performant JavaScript parser for Rust and WebAssembly

License:MIT License


Languages

Language:JavaScript 84.7%Language:Rust 15.1%Language:TypeScript 0.2%Language:CSS 0.0%Language:HTML 0.0%