Classroom Public page

Lab Pack 10: Compiler II (Week 11)

217 words

Code generation. Five worksheets in worksheets/ch10/ complete the compiler. By end of week your toolchain takes Jack-equivalent source all the way to running code on your silicon. Eight layers, all yours.


Anchors the week

Week 11: Compiler II. The toolchain closes. Source → tokens → parse tree → VM bytecode → assembly → object file → linked binary → silicon. Every layer written by you in CSA-101.

Concept the lab embodies

Tree-walking codegen. The parse tree from week 10 gets walked; each node type has an emit function; the emit functions call each other recursively; the output is VM bytecode.

The five worksheets

Worksheet Time Purpose
lab-10.1-symbol-table-builder.md ~90 min Scope-aware name resolution
lab-10.2-codegen-expressions-and-statements.md ~120 min Post-order tree walk emits VM ops
lab-10.3-codegen-subroutines-constructors-methods.md ~120 min Function-call protocol for compiled output
lab-10.4-end-to-end-on-silicon-toolchain-closes.md ~120 min Source compiles to silicon-runnable binary
lab-10.5-ghidra-on-your-own-compiler-output.md ~90 min Reverse-engineer your compiler's output

Grading rubric

Per-worksheet rubrics. Week-level: compiler handles full Jack-equivalent language; output runs on silicon; the toolchain produces correct results for a 3-file test program.

What's next

Lab pack 11: Compiler III. OS-aware compilation.