“Good compilers take years to mature.”
Thankfully, this implementation arrived only 3 years after the original 'Rinha de Compilers'.
Jokes aside, this is my implementation for the Rinha de Compilers using Rust with a Tree-Walking Interpreter architecture.
This project was built to explore:
- parsing and AST construction;
- expression evaluation;
- scopes handling;
- functions and closures;
- runtime/value representation in Rust;
- future optimizations and some experimentation.
- Rust and Cargo version 1.96 (the one I used during implementation)
cargo build --release
cargo run --release <path_to_program_ast.json># Build the Docker image
docker build -t rinha-compilers .
# Run with
docker run --rm -it \
-v <path_to_some_input_file.json>:/var/rinha/source.rinha.json \
rinha-compilers- Better specified errors (with the
locationinformation on the AST) - Some optimizations (do some profilling first):
- Unnecessary
.clone()(useRc<..>) - Ensure
envis getting passed through reference everywhere strinstead ofString- Memoization/caching
- Unnecessary
Feel free to open issues or submit pull requests if you'd like to contribute to this project.
This project is licensed under the MIT License.