https://github.com/progval/python-rust-parser
[WIP] A Rust parser written in Python
https://github.com/progval/python-rust-parser
Last synced: 3 months ago
JSON representation
[WIP] A Rust parser written in Python
- Host: GitHub
- URL: https://github.com/progval/python-rust-parser
- Owner: progval
- License: gpl-3.0
- Created: 2020-09-09T15:37:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-10T18:34:36.000Z (over 4 years ago)
- Last Synced: 2025-02-12T05:38:55.146Z (4 months ago)
- Language: Python
- Homepage:
- Size: 178 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-rust-parser
A Rust parser written in PythonNot to be confused with [rust-python-parser](https://github.com/ProgVal/rust-python-parser/),
which is a Python parser written in Rust (ie. the opposite of this).## The plan
1. Basic reimplementation of [GLL](https://github.com/rust-lang/gll)
2. Use it to generate a parser and a CST from [the Rust grammar](https://github.com/rust-lang/wg-grammar)
3. Rewrite the CST into an AST## Motivation
I want to write a Rust interpreter in Python, to bootstrap Rust, as
an alternative to [mrustc](https://github.com/thepowersgang/mrustc/) that
may be easier (or not) to maintain.Either way, it's a fun exercise.
## How to use
Don't
## How to run tests
1. Install Python from https://github.com/brandtbucher/cpython/tree/patma , for example:
1. `cd ~`
2. `git clone https://github.com/brandtbucher/cpython.git cpython-patma`
3. `cd cpython-patma`
4. `git checkout 19af7d547e094006bfdc40a358385ad49503c597`
5. `./configure --prefix=$HOME/.local/`
6. `make -j 4`
7. `make install`
2. Clone this repo: `git clone https://github.com/ProgVal/python-rust-parser.git; cd python-rust-parser`
3. Fetch submodules (to get [the rust grammar](https://github.com/rust-lang/wg-grammar/tree/master/grammar)): `git submodule update --init` (don't use `--recursive` or it will fetch all rustc's git repo!)
4. Install dependencies:
1. `~/.local/bin/python -m ensurepip`
2. `~/.local/bin/python -m pip install pytest tatsu`
5. Run pytest: `~/.local/bin/python -m pytest`