Learn hands-on how a self-compiling compiler in a non-trivial subset of C along with a MIPS emulator as target works and how you can extend it. The course is based on the Selfie Project and loosely follows the textbook Compiler Construction by Niklaus Wirth.
The course provides an undergraduate-level introduction to compiler construction, covering fundamental topics of compiler construction: scanning, parsing, type checking, error handling, register allocation, code generation, bootstrapping, separate compilation, and basic code optimization; considering fundamental programming language constructs and concepts: assignment, arithmetic and boolean expressions, arrays, records, pointers, conditionals, loops, modules, and procedures with parameters, return values, and local variables. At the end of the course you will be able to appreciate principled engineering of compilers but also know how to actually construct one and, as a consequence, through insights in programming language semantics that only a compiler can offer, become a fundamentally better programmer and computer scientist.
Teams of 2-3 students will be asked to extend the C compiler and MIPS emulator of selfie. The extension includes support of bitwise operators, constant folding, characters, arrays, and records, and Boolean expressions with lazy evaluation. The extended version of selfie, in particular the compiler must be able to compile itself in a live demo at the end of the semester. There will also be a final exam at the end of the semester.