Compiler Design: final assessment

This covers the whole course. Take it after the last module.

Final quiz

1. Which phase comes first in a compiler?
2. What does a recursive-descent parser have for each grammar rule?
3. What does an abstract syntax tree leave out?
4. Which data structure models nested scopes?
5. What is a temporary in three-address code?
6. How is 8 − 3 − 2 grouped by a parser that uses a loop for −?
7. Why does FOLLOW(T) contain + in E → T E', E' → + T E' | ε?
8. Which parser handles left-recursive rules without rewriting them?
9. What does the type checker report for (+ 1 "a") in a language without string-number addition?
10. c = x + 8 and later d = x + 8, with no change to x. What does common subexpression elimination produce?
11. Which instructions start basic blocks?
12. A forward jump is emitted before its target is known. What fills in the address?
13. Liveness analysis repeats its equations until what happens?
14. Why can't dead code elimination remove print x even if nothing reads its result?
15. Values x (0,3] and c (3,4] are both in the code. Can they share a register?
16. In graph-colouring register allocation, what does an edge mean?

Practical assessment: Compile a small language to stack code

Without using hints, write a compiler for a language with integer variables, + − * /, comparisons, if/else, while and print, that compiles each program to stack-machine code and runs it.

Final project

A compiler for a small language: Build a compiler for a small language with variables, arithmetic, comparisons, if/else, while and print, that compiles to stack-machine code and runs it on your own virtual machine.

How it is evaluated

To complete this course