Compilers

Compilers

Notes on compiler construction

Notes on compiler construction, based on Carson Gross's lectures building a compiler for CatScript. These chapters cover language design, lexical analysis, regular expressions, parsing, and a full tour of the compiler pipeline.

  1. Smuggling Generic Types into the Runtime How type tokens use anonymous subclasses and reflection to recover erased generic types
  2. CatScript Overview A small statically-typed programming language
  3. CatScript Compiler - A Tour Based on Crafting Interpreters and work by Carson Gross
  4. Tokenization Turning source code into tokens
  5. Regular Expressions A primer on regex for compiler construction
  6. Parse Trees and Context-Free Grammars From tokens to tree structures
  7. Parse Trees & Abstract Syntax Trees Visitor pattern, expression problem, and AST design
  8. Recursive Descent Parsing Turning a list of tokens into a parse tree
  9. Actual Parsing Left associativity, the loop trick, and unary expressions
  10. Parsing Expressions Primary expressions, list literals, ambiguity, and index expressions
  11. Parsing Statements Print, var, for, while, if, and assignment statements
  12. Parsing Functions & Type Literals Function calls, return statements, function declarations, and type expressions
  13. Semantic Analysis Moving beyond syntax to meaning - error phases, control flow, and optimization
  14. Symbol Tables Stacks of maps - managing scope, variables, and functions
  15. Type Systems Static vs. dynamic typing, assignability, covariance, boxing, and top/bottom types
  16. Semantic Analysis of Expressions Type checking additive, comparison, function call, and list literal expressions
  17. Semantic Analysis of Statements Validating variable, assignment, if, for, return, and function definition statements
  18. Java Generics Type parameters, type erasure, wildcards, and generic methods
Start Reading