Day 06 of 30 · Compiler foundations

Check meaning before generating code

Time
About 150 minutes: 40 reading, 80 lab, 20 testing, 10 notes.
Prerequisites
Day 05: Write a recursive descent parser

Toolchain: your host C++ compiler

Today’s lab is the toy expression frontend. Any working C++ compiler builds it; no LLVM libraries are needed yet. Setup guide

Learn

  • Symbol tables, name resolution, scopes and semantic errors.

Read Reading

Reading budgets cover selected sections, not whole chapters. Link to the book; this site does not reproduce it.

Build Build or investigate

  1. Resolve names in a single scope.
  2. Reject unknown names and duplicate let declarations.
  3. Evaluate valid integer ASTs in a small interpreter.
  4. Define the toy integer domain as unsigned 32-bit values with wraparound; omit division for now.

Done when

Separate lexer, parser and semantic failures, with one example of each; 2 + 3 * 4 evaluates to 14.

Recall question

Why can x + 1 be syntactically correct but semantically invalid?

Completion checks

Progress tracking needs JavaScript. The lesson above is complete without it.

Required to complete day 06

Notes

Saved only in this browser. Keep it short enough to finish in ten minutes; none of the prompts are required. All notes, export and import