Compiler Construction
Lectures will be delivered live following the timetable. Lecture recordings will be made available following the last lecture. Students who are unable to attend a particular lecture are invited to email the lecturer to request access to the recording.
Lecture slides
Last year's slides are still available, and largely current; there won't be substantial changes to the course material this year.
- Lecture 1 (2026-01-23): introduction
- Lecture 2 (2026-01-26) (without transitions): lexing
- Lecture 3 (2026-01-28) (without transitions): context-free grammars
- Lecture 4 (2026-01-30) (without transitions): LL parsing
- Lecture 5 (2026-02-01) (without transitions): Foundations of LR parsing
- Lecture 6 (2026-02-03): (without transitions): SLR(1) and LR(1)
- Lecture 7 (2026-02-05): (without transitions): translation
- Lecture 8 (2026-02-09): (without transitions): CPS & defunctionalization
- Lecture 9 (2026-02-11): (without transitions): Deriving interpreter 2
- Lecture 10 (2026-02-13): (without transitions): Interpreter 3
- Lecture 11 (2026-02-16): (without transitions): The Jargon VM
- Lecture 12 (2026-02-18): (without transitions): Garbage Collection
- Lecture 13 (2026-02-20): (without transitions): Exceptions
- Lecture 14 (2026-02-23): (without transitions): Optimisation
- Lecture 15 (2026-02-25): (without transitions): Linking
- Lecture 16 (2026-02-27, updated shortly after lecture): (without transitions): Bootstrapping
Additional material
- Lecture 1 (introduction)
- Compiler explorer: examine the output of compilers for C, Java, OCaml, Python, Rust, ...
- Lecture 2 (lexing)
- Lecture 4 (LL parsing)
- LL(1) parser visualization
- JFLAP can also generate LL(1) parse tables
- Lectures 7-11 (The slang compiler)
- Slang implementation
- Online slang explorer
- Defunctionalization: everybody does it, nobody talks about it (SIGPLAN blog)
- Suggestions for Slang improvements (from Prof Timothy Griffin)
- Rocq proof that
fib_cps m k = k (fib m) - Lecture 13 (Exception handling)
- Lecture 14 (Optimisation)
- What is contification?
- Secrets of the Glasgow Haskell Compiler inliner
- Whole-Program Compilation in MLton
- Lecture 15 (Linking)
- Linkers and Loaders (John Levine)
- Advanced Programming in the UNIX Environment (W. Richard Stevens and Stephen A. Rago)
- Lecture 16 (Bootstrapping)
- Chapter 13 (Bootstrapping a compiler) of Basics of Compiler Design (Torben Ægidius Mogensen)
- A formalism for translator interactions (Jay Earley and Howard Sturgis, 1970)
- CakeML: A Verified Implementation of ML (Ramana Kumar, Magnus Myreen, Michael Norrish, Scott Owens, 2014)
- Reflections on Trusting Trust (Ken Thompson's 1984 Turing Award lecture about a "Trojan horse" bug related to bootstrapping)
- Debootstrapping without Archeology: Stacked Implementations in Camlboot (N. Courant, J. Lepiller, G. Scherer, 2022)
Past exam questions
- Lecture 2 (lexing): P4Q1 2025, P4Q1 2024 (part), P4Q3 2018 (part)
- Lecture 3 (context-free grammars): P4Q4 2021 (part), P4Q1 2023 (part), P4Q4 2018 (part), P4Q4 2020 (part), P4Q1 2024 (part)
- Lecture 4 (LL parsing): P4Q4 2020 (part), P4Q1 2022, P4Q1 2024 (part)
- Lecture 5 (Foundations of LR parsing): P3Q4 2015 (part), P4Q4 2021 (part)
- Lecture 6 (SLR(1) and LR(1)): P3Q3 2015 (part), P4Q1 2023 (part), P4Q4 2020 (part), P4Q4 2021 (part)
- Lecture 7 (translation): P3Q3 2016 (part), P4Q3 2020 (part), P4Q3 2021 (part)
- Lectures 8-9 (CPS & defunctionalization, deriving interpreter 2): P3′Q4 2017, P4Q2 2022, P4Q2 2023, P3Q3 2016 (part), P4Q4 2018 (part)
- Lecture 11 (Jargon VM, virtual machines): P4Q2 2025 (part) P4Q3 2020 (part) P3Q4 2016 (part) P4Q3 2018 P4Q3 2019
- Lecture 12 (Garbage collection): P3'Q3 2017 (part) P4Q4 2018 (part) P4Q2 2024 (part)
- Lecture 13 (Exceptions): P4Q4 2019 (part)
- Lecture 14 (Optimisation): P3 Q4 2016 (part) P3 Q3' 2017 (part) P4 Q4 2018 (part) P4 Q4 2019 (part) P4 Q3 2021 (part) P4 Q1 2023 (part) P4 Q2 2025 (part)
- Lecture 15 (Linking): P4 Q2 2024 (part)
- Lecture 15 (Bootstrapping): P4 Q2 2024 (part)