Skip to content

Phase snapshots

These directories are standalone compiler checkpoints for following compilerbook on native macOS arm64.

Each language phase builds a real compiler:

  1. tokenize input
  2. parse it into an AST
  3. emit AArch64 assembly for Mach-O
  4. assemble and link with Apple clang
  5. execute the generated program in the test

The compiler must not evaluate the input program in the compiler process and print a constant result. Later syntax is intentionally rejected in earlier phases.

Current phases:

  • phase-01-int: integer literal
  • phase-02-add-sub: + and -
  • phase-03-tokenizer: tokenizer and whitespace handling
  • phase-04-errors: source-location errors
  • phase-05-mul-div-parens: precedence, *, /, parentheses
  • phase-06-unary: unary + and -
  • phase-07-comparisons: comparison operators
  • phase-08-file-split: split compiler source files
  • phase-09-single-letter-locals: one-letter local variables
  • phase-10-multiletter-locals: multi-letter local variables
  • phase-11-return: return
  • phase-12-control-flow: if, else, while, for
  • phase-13-blocks: blocks
  • phase-14-function-calls: function calls
  • phase-15-function-definitions: function definitions

Run all phase snapshots:

sh
make phase-test