mconca / jsparagus

Parser generators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust

jsparagus - A JavaScript parser written in Rust

jsparagus is intended to replace the JavaScript parser in Firefox.

Current status:

Join us on Discord: https://discord.gg/tUFFk9Y

Getting started

Part of jsparagus is generated by a Python script, so start by setting up your Python environment, make sure cargo-fmt is installed, then use make all to build the parser:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

cargo install cargo-fmt

git config core.hooksPath .githooks

make all

(Note: This takes about 3 minutes to run on my laptop. The Python script is slow. We're working on it!)

When it's done, you can:

  • Run make check to make sure things are working.

  • cd rust && cargo run to test the JS parser and bytecode emitter.

Limitations

It's all limitations, but I'll try to list the ones that are relevant to parsing JS.

  • Lookahead assertions are limited to one token. (The JS grammar contains an occasional [lookahead != `let [`] and even [lookahead != `async [no LineTerminator here] function`].)

  • Restricted productions ("[no LineTerminator here]") are not implemented yet.

  • Error messages are poor.

  • No table compaction or table optimization. There's plenty of low-hanging fruit there.

About

Parser generators


Languages

Language:Rust 62.2%Language:Python 37.2%Language:Makefile 0.3%Language:Shell 0.2%