Compiler design

  1. Lexical analysis: A maximal-munch lexer DFA turns characters into tokens and fills the symbol table.
  2. Left recursion & factoring: Remove direct and indirect left recursion, then left factor, rule by rule.
  3. FIRST & FOLLOW: Compute FIRST and FOLLOW sets pass by pass, with the reason for every symbol.
  4. LL(1) parsing: Predictive parsing table, conflicts, and a stack trace that grows the parse tree.
  5. LR parsing: LR(0), SLR, LALR and CLR: item sets, tables, conflicts and bottom-up parses.
  6. Operator-precedence parsing: LEADING and TRAILING, the ⋖ ≐ ⋗ table, precedence functions and shift-reduce parses.
  7. Syntax-directed translation: Annotated parse trees: synthesised and inherited attributes evaluated in dependency order.
  8. Three-address code & DAG: Syntax tree to TAC, DAG with common subexpressions, quadruples and triples.
  9. Code optimisation: Leaders, basic blocks and the flow graph, then folding, propagation, CSE and dead code, one rewrite at a time.
  10. Register allocation: Liveness to a fixed point, the interference graph, then Chaitin's simplify, spill and select with k registers.