writeonce/docs/stories/language-runtime-database/done/03-compiler-front.md
shoney.arickathil 57b4b56eae docs: stories foldered by state — done/ and refine/
- done/ (11): 1, 2, 3, 4, 6, 7, 7b, 9, 9b, 15, 16 — landed iterations
  (9/9b remainders live in the post-12 drain list, not in the files)
- refine/ (8): 9c, 9d, 9e, 9f, 9g, 11, 13, 14 — everything marked
  "no spec yet / brainstorm before planning"
- root keeps: 00-story (index), 05 (partial, plan 8 open), 8/10/12
  (specs or plans exist), 17 (parked, spec+plan approved), 18 (next)
- every cross-reference re-pathed and VERIFIED resolving: board, specs,
  plans, employee-list README, story table, intra-story links (moved
  files' relative links deepened one level; done/7b's 9e pointer now
  crosses to refine/)
- pre-existing dead link noted, not touched: refine/11-fibers.md points
  at docs/plan/exploration/fibers/00-fibers.md which does not exist
  (predates the move)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 04:33:24 +02:00

54 lines
2.1 KiB
Markdown

# Iteration 3 — compiler front (`woc`)
> Format: fiberloom `product/story-iteration-template`. Part of
> [Story — one language, one runtime, one database, one binary](../00-story.md).
## Goals
- An OCaml, stdlib-only compiler front end: `.wo` source becomes a typed
AST with ownership annotations, or plain, precise diagnostics — the
half of the language the developer converses with.
- Ownership errors read like sentences naming both sites ("moved at
pricing.wo:14, used at pricing.wo:17") — the ergonomics bet that makes
MVS beat Rust for this audience.
## Acceptance Criteria
- What to achieve?
- **Given** the pricing-demo classes,
- **when** `woc` runs its front pipeline (lex → parse → typecheck →
ownership),
- **then** `--dump-ast` output matches the golden file and zero
diagnostics are emitted.
- What to achieve?
- **Given** a file violating ownership rules (move-after-use, borrow
escape, double exclusive borrow),
- **when** it compiles,
- **then** each violation reports a stable `WO-E###` code with both
source sites, and one bad declaration does not stop diagnosis of the
rest of the file.
- What to achieve?
- **Given** a class that satisfies an interface structurally,
- **when** typechecking runs,
- **then** satisfaction is recognized with no `implements` declaration,
and per-method `self` mutability is inferred (reads shared, writes
exclusive).
## Out Of Scope
- Bytecode emission and running anything (iteration 4).
- The Haxe-parity adoptions (iteration 5) — milestone grammar only.
## Info
- Newline-significant lexing and the identifier gotchas mirror
`crates/rt`'s lexer — grammar parity is a stated contract.
- Architecture map: `docs/plan/compiler/architecture.md` (pipeline, module
contracts, study references).
## Proposed Solution
- Execute the existing plan: `docs/plan/compiler/2026-08-01-woc-compiler-front.md`
(diagnostics module, lexer, declaration/statement/expression parsers with
skip-on-block, typechecker with field-kind derivation, MVS ownership pass
producing the four emitter tables, driver + error catalog).