Topic 1 · Week 1

Topic 1 — Compiler Design Phases

What the six phases are, and the first one built for real.

1. Lexicalchars → tokensscanner.l2. Syntaxtokens → ASTparser.y3. SemanticAST → checked ASTsemantic.c4. IRAST → TACtac.c5. OptimizeTAC → better TACtac.c6. CodeGenTAC → MIPScodegen.c

Week 1  ·  Sep 8 – Sep 13, 2026  ·  What the six phases are, and the first one built for real.

Start here

Lecture notes →

Why a compiler is built as a sequence of phases, what each one is responsible for, and the automata theory that makes the first phase a solved problem.

The full theory for this topic, with diagrams, worked examples and Dragon Book references. This page you are on is only an index.

Your starter code

The lexer you are extending this topic, with every TODO spelled out.
student/topic-1-lexical-analysis/

Assignment: Project 1 · Lexical Analyzer

Full requirements and submission checklist. Due Sep 13, 2026.

Stuck on the tools rather than the theory? The toolchain tutorials cover make, Git and GitHub, flex and bison.

Class activities

One per class meeting. Ungraded — they exist so that the assignment is not the first time you meet the idea.

Activity 1 — Tokenize by Hand, Then by Machine

Write the token stream yourself, then find out where you and the automaton disagree — and which rule explains each difference.

Activity 2 — Break the Scanner on Purpose

Five experiments that each break the scanner in one specific way. Predict first, then run, then explain it with the theory.