The Compiler
verify-all-tests

Verify all previous interpreter tests still pass. The compiler changes should not have broken the interpreter -- they're separate code paths. Run all 29 interpreter tests plus the global variable tests from Part 9. All ok.

What we have now: a compiler that reads the same source text as the interpreter and emits WAT instructions. It handles arithmetic with precedence, typed variables, if/else, while loops, typed functions, global variables, and memory access. The parser structure is identical to the interpreter -- we just swapped computation for emission.

What we need next: a way to run the WAT without leaving Zig. We can't rely on wat2wasm and Node.js for our test suite -- we need to verify the compiler's output automatically, in the same process. That means building a VM.

## Part 7: The VM

We have two things: an interpreter that computes answers from source text, and a compiler that produces WAT from the same source text. What we don't have is proof that the compiler is correct. The interpreter says fib(10) = 89. The compiler produces 30 lines of WAT. Do those 30 lines, when executed, also give 89?

We need a machine that runs WAT. Not a full WebAssembly runtime -- just enough to execute the instructions our compiler emits. We know exactly which instructions those are because we wrote the compiler. No surprises.

The machine is simple: a stack, some local variables, a program counter, and a handful of rules. Let's build it.