Execution — fw-06-compilers

Steps extracted from CONCEPTS.md. Read the concepts first; this file is the doing.

Record results in observation.md; tick checkpoints in verification.md.


3. Build order

  1. Lexer for a small template language: text, interpolation {{ }}, elements, attributes, directives.
  2. Parser → AST, with source locations on every node.
  3. Transforms: interpolation, attribute binding, event binding, conditionals, loops.
  4. Codegen → a render function returning your fw-05 VNodes.
  5. Static hoisting: detect fully-static subtrees; emit them once.
  6. Patch flags: annotate dynamic bindings; make your renderer honour them.
  7. Error reporting with source locations — a caret-and-line message, not a stack trace.
  8. Then: a JSX-to-createElement transform over real JS, using an existing JS parser.

4. Failure Lab

  1. Drop source locations. Produce a compile error and try to act on it. This is why step 2 says every node.
  2. Hoist a subtree that is not actually static (it reads a variable). Show the stale render.
  3. Emit a wrong patch flag — mark a dynamic node static. Show the missed update. This is the central risk of compiler optimisation: a wrong annotation is a silent correctness bug, not a slow one.
  4. Codegen that breaks on a legal input (nested quotes, unicode, an expression containing }}).