Build a Compiler in Five Projects
13 hours ago
- #racket
- #compiler-design
- #x86-64
- CIS531 is a masters-level class on compiler design using the Racket programming language.
- The class follows Prof. Jeremy Siek’s book 'Essentials of Compilation' and includes five projects building a compiler for increasingly complex languages.
- Projects cover straight-line arithmetic, booleans and branching, vectors and loops, and functions and lambdas, culminating in a compiler for a functional and imperative language subset.
- The compiler targets x86-64 assembly and includes features like variables, arithmetic, booleans, branching, heap allocation, mutation, loops, and closures.
- The course emphasizes practical implementation with comprehensive test suites and intermediate language interpreters for debugging.
- The final language includes functions, recursion, and lambdas, demonstrated with a Sudoku solver example.
- The compiler structure is modular, with passes transforming intermediate representations (IRs), each with an interpreter for semantic clarity and testing.
- The course is unique for its incremental design, testability across passes, and practical focus on building a real compiler.
- Students are encouraged to extend the compiler with features like type checking, classes, or pattern matching after completing the projects.
- The course is supported by the NSF and inspired by Prof. Siek’s work and collaborations with Thomas Gilray.