Thanks for your interest! This is an educational compiler project, and contributions of all kinds — code, docs, bug reports, teaching materials — are very welcome.
git clone https://github.com/kinsomwang/ScratchV
cd ScratchV
pip install -e . # install in editable mode
pip install tinyfive # optional: assembly verification
pytest tests/ -v # run all tests- Python version: 3.8+ compatible (no
|union syntax in annotations unless guarded byfrom __future__ import annotations; nodataclass(slots=True)). - Type hints: annotate all public functions and methods.
- Docstrings: Google or NumPy style is fine — keep them short but useful.
- No
__pycache__: they're gitignored; just don't commit them.
- Open an issue first to discuss the change you'd like to make.
- Make your changes on a feature branch (
git checkout -b feat/my-thing). - Add or update tests in
tests/. - Run
pytest tests/— all tests must pass. - Run
make checkif available (lint + test). - Open a PR with a clear title and description.
- Add the opcode to
scratchv/ir/types.py→OpCodeenum. - (Optional) Add a builder method in
scratchv/ir/builder.py. - Add a selection handler in
scratchv/backend/instruction_select.py. - Add an LLVM codegen handler in
scratchv/backend/llvm_codegen.py. - Add a test case in
tests/. - Run
pytestto verify.
- Create
scratchv/optimizer/my_pass.py. - Implement a class with a
run(program) → intmethod (returns number of transformations applied). - Register it in
scratchv/main.py→run_optimizer(). - Add test cases (positive: should transform; negative: should not).
- Run
pytestto verify.
- User-facing docs go in
docs/. - Inline code comments are for why not what.
- The README is the single source of truth for project-wide docs.
Be respectful, assume good faith, and remember that this is a learning project. Help others level up.