A Rust parser written in Python
Not to be confused with rust-python-parser, which is a Python parser written in Rust (ie. the opposite of this).
- Basic reimplementation of GLL
- Use it to generate a parser and a CST from the Rust grammar
- Rewrite the CST into an AST
I want to write a Rust interpreter in Python, to bootstrap Rust, as an alternative to mrustc that may be easier (or not) to maintain.
Either way, it's a fun exercise.
Don't
- Install Python from https://github.com/brandtbucher/cpython/tree/patma , for example:
cd ~git clone https://github.com/brandtbucher/cpython.git cpython-patmacd cpython-patmagit checkout 19af7d547e094006bfdc40a358385ad49503c597./configure --prefix=$HOME/.local/make -j 4make install
- Clone this repo:
git clone https://github.com/ProgVal/python-rust-parser.git; cd python-rust-parser - Fetch submodules (to get the rust grammar):
git submodule update --init(don't use--recursiveor it will fetch all rustc's git repo!) - Install dependencies:
~/.local/bin/python -m ensurepip~/.local/bin/python -m pip install pytest tatsu
- Run pytest:
~/.local/bin/python -m pytest