CS4200: Compiler Construction
- Master Computer Science
- Common Core Software Technology
- Specialization Programming Languages
- Credits: 2 x 5 ECTS
- Lectures: Thursday 10:45 - 12:45
- Lab Q1: Tuesday 10:45 - 12:45, 13:45 - 15:45
- Lab Q2: Friday 13:45 - 17:45
- Shared Study Lab on Wednesday

- Lecturer: Eelco Visser (e.visser@tudelft.nl)
- TA: Paul van der Stel
- TA: Wesley Baartman
- TA: Alexander Sterk
Compiler Construction
Compilers translate the source code of programs in a high-level programming language into executable (virtual) machine code. Nowadays, compilers are typically integrated into development environments providing features like syntax highlighting, content assistance, live error reporting, and continuous target code generation.
This course studies the architecture of compilers and interactive programming environments and the concepts and techniques underlying the components of that architecture. For each of the components of a compiler we study the formal theory underlying the language aspect that it covers, declarative specification languages to define compiler components, and the techniques for their implementation. The concepts and techniques are illustrated by application to small languages or language fragments.
The compiler construction program consists of two courses of 5 ECTS each.
CS4200-A: Front-End (Q1)
In the first course we study the front-end of the compiler that parses and type checks programs. We study meta-languages for the definition of the syntax and static semantics of programming languages. [Study guide]
CS4200-B: Back-End (Q2)
In the second course we study the back-end of the compiler that performs static analysis, optimization, and code generation. [Study guide]Spoofax Language Workbench

ChocoPy: Project Language
In the course project students implement a compiler for ChocoPy, a subset of Python3 with static types. The back-end of the compiler generates RISC-V code, which can be run with a simulator running on the JVM. The language comes with a fully specified using formal grammar, typing rules, and operational semantics. ChocoPy was developed at UC Berkeley for their compiler course.WebLab: Homework Assignments and Exams

Lecture Schedule CS4200-A/Q1
Lectures are on Thursdays 10:45 - 12:45 and take place online. The venue will be announced on Brightspace.
- Sep 3: What is a compiler?
- Sep 4: Declarative Syntax Definition
- Sep 8: Setting up a Language Project
- Sep 8: Testing Language Definitions
- Sep 10: Disambiguation and Layout Sensitive Syntax
- Sep 17: Type Constraints
- Sep 24: Name Binding Constraints
- Oct 1: Constraint Resolution
- Oct 8: Parsing
- Oct 15: More Parsing
- Oct 22: Exam Preparation
- Thu Oct 29, 13:30-16:30: Exam Q1
Tentative Lecture Schedule CS4200-B/Q2
Lectures are on Thursdays 10:45 - 12:45 and take place online. The venue will be announced on Brightspace.
- Nov 12: Transformation with Rewrite Rules
- Nov 19: Composing Transformations with Stratgey Combinators
- Nov 26: Instruction Sets and Code Generation
- Dec 3: Functions, Calling Conventions, and Code Generation Mechanics
- Dec 10: Nested Functions & Memory Management
- Dec 17: Representing Objects & Register Allocation
- Jan 7: Data-Flow Analysis
- Jan 14: Beyond Compiler Construction
- Fri Jan 29, 13:30-16:30: Exam Q2