Overview
MiniC compiles a subset of C, with integers, arrays, functions, loops and recursion, straight to x86-64 assembly that runs on Linux.
Pipeline
- A hand-written lexer and a recursive-descent parser build an abstract syntax tree.
- A semantic pass checks types and scopes and reports errors with the exact line and column.
- The code generator walks the tree and emits assembly, using the stack for locals and registers for expressions.
Results
MiniC compiles and runs programs such as quicksort, the Sieve of Eratosthenes and recursive Fibonacci, and is covered by a regression suite of more than 150 test programs.
What I learned
Writing every stage by hand showed me how much a language's design shapes its compiler, and gave me a real appreciation for the tools I use every day.