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 (Monday 05 October)
- Class 3.2: Introduction to Rust (Wednesday 07 October)
- Class 3.3: Rust compile-time memory management: ownership and borrowing (Wednesday 14 October)
- Class 3.4: Memory management in LLVM with alloca/load/store and malloc/free (Monday 19 October)
Homeworks
Labs
- Lab 3.1: Spec and Interpreter for an Iffy Language (due 23:59 on Wednesday 21 October)