A compact compiler toolchain for the MiniC language (a small C subset). Implemented for the MIF08 compiler lab at Université Claude Bernard Lyon 1.
Mohamed Hamed MOHAMED AHMED
- ANTLR4-generated lexer and parser for MiniC.
- A static type checker that validates MiniC programs.
- An interpreter that evaluates MiniC programs.
- Partial backend that can emit RISC‑V assembly for codegen experiments.
- A comprehensive test-suite used for grading and development.
The repository is designed to run reproducibly inside the provided Docker image.
Run a development shell:
docker pull mmoy/riscv-latex-python:dev
docker run --rm -ti -v "$PWD":/home/compil --user $(id -u):$(id -g) -w /home/compil mmoy/riscv-latex-python:devInside the container you can run the test-suite or the interpreter directly:
# Run all tests
make test
# Run the interpreter on a file
python3 MiniCC.py --mode eval TypingAndInterpret/tests/arit/multiplicative/modulo.c
# Run a subset of tests
make test FILTER='TypingAndInterpret/tests/**/*division*.c'- test_eval: runs the project interpreter and compares output to expected annotations.
- test_expect: compiles with GCC and checks that the annotated expected results are correct.
Some tests intentionally differ between GCC and the interpreter (e.g. undefined behaviour). In such cases the test can be marked in-source with // SKIP TEST EXPECTED so only the interpreter check runs.
This project can emit RISC‑V assembly for a subset of MiniC. RISC‑V was chosen because it is an open, modern ISA well suited for teaching compiler construction and experimentation.
This repository was developed as part of the MIF08 labwork. Relevant lab documents:
- Lab 2 — Interpreters and Types: https://matthieu-moy.fr/cours/mif08/tp2.pdf
- Lab 4 — (codegen / RISC‑V and further exercises): https://matthieu-moy.fr/cours/mif08/tp4.pdf
- Lab 5 — (advanced topics and testing): https://matthieu-moy.fr/cours/mif08/tp5.pdf
These PDFs describe the assignment specifications and test expectations used during development.
MiniC/— lexer/parser, interpreter, typechecker, tests, and codegen helpers.TypingAndInterpret/— typing rules and interpreter tests.CodeGen/— RISC‑V emission utilities and allocators.CC1/&TP*— smaller exercises and examples used in the course.
Refer to the repository tree for details.
Issues, suggestions or improvements are welcome. Please open an issue or send a patch.
Use and distribution details are in the repository. If none are present, contact the author for licensing terms.