Classroom Public page

Lab Pack 9: Compiler I (Week 10)

172 words

Tokenizer and parser. Four worksheets in worksheets/ch9/ build the recursive-descent compiler frontend.


Anchors the week

Week 10: Compiler I. The first time the toolchain takes high-level-language source as input. Tokenization is mechanical; parsing is recursive; the parse tree is the contract to next week's backend.

Concept the lab embodies

Recursive structure mirrors recursive grammar. Each grammar rule becomes a parser function; functions call each other to match nested constructs.

The four worksheets

Worksheet Time Purpose
lab-9.1-tokenizer.md ~90 min Source → typed tokens
lab-9.2-recursive-descent-expression-parser.md ~120 min The expression parser; the heart of the frontend
lab-9.3-full-parser.md ~120 min Extend to all statements and declarations
lab-9.4-round-trip-parse-emit-reparse.md ~90 min Structural verification

Grading rubric

Per-worksheet rubrics. Week-level: parser handles full Jack-equivalent grammar; round-trip parse-emit-reparse produces identical parse tree.

What's next

Lab pack 10: Compiler II. The toolchain closes.