In this unit, our languages will be extended with basic imperative control structures, namely conditional if/else statements (or expressions), and loops.
We introduce the abstract syntax tree (AST) as capturing the semantics of a program, devoid of syntax. As our languages become more complex, using an automatic parser generator, and explicitly generating an AST, will be helpful in writing reliable and maintainable implementations of PLs.
In terms of compilation, control structures introduce some unique challenges in an SSA language like LLVM IR. We will learn about basic blocks and the control flow graph (CFG) as a useful way to talk about this, and phi nodes as one solution to the problem.
As we think about the semantics of memory management in our languages, we will see some examples from the programming language Rust as one interesting modern approach.
Classes
- Class 3.1: Abstract Syntax Trees (Thursday 09 October)
- Class 3.2: Introduction to Rust (Wednesday 15 October)
- Class 3.3: Rust compile-time memory management: ownership and borrowing (Monday 20 October)
- Class 3.4: Memory management in LLVM with alloca/load/store and malloc/free (Wednesday 22 October)
- Class 3.5: LLVM basic blocks and branching (Monday 27 October)
Homeworks
- HW 3.1 (due before class on Wednesday 15 October)
- HW 3.2 (due before class on Monday 20 October)
- HW 3.3 (due before class on Wednesday 05 November)
Labs
- Lab 3.1: Spec and Interpreter for an Iffy Language (due 23:59 on Tuesday 28 October)
- Lab 3.2: Compiler for Iffy language (due 23:59 on Wednesday 05 November)