lib/ww,wcc: consolidate frontend into one syntax package (Go-compiler model, #74)

The ww compiler frontend was split across packages lex (lex+tok), ww
(ast+sym+typ), and parse — mirroring Hare's ref/hare/hare/{ast,lex,parse}.
That split's only payoff is third-party reuse, which ww has zero of: the
frontend is consumed by exactly one client, the wcc backend. The split's
cost is a wide cross-package export surface — every fn over a sibling
package's type must export it, and under separate compilation that
re-triggers check_exported_type, plus a phantom `import tok;` (tok lives
in package lex). Consolidate into ONE package lib/ww/syntax/, modelled on
Go's cmd/compile/internal/syntax. The 9 files move in (package syntax);
the intra-frontend mutual references become same-package; wcc and the
tool mains import syntax. No cstage C change (the C frontend mangles from
the source package clause). Internal data shapes (AST kinds, token model,
lexer/parser state) still mirror ref/hare/hare per rule 6/12 — only the
module decomposition collapses; the stdlib is untouched.

USER-approved (#74); spec .ai/rob-frontend-reorg.md (drew2 fidelity-
confirmed). Rule-6 carve-out documented in CLAUDE.md. Dissolves the tok
phantom import; collapses the intra-frontend export sprawl. Byte-id
rebaseline (lex.X/parse.X/ww.X -> syntax.X); cs==ww held. The residual
syntax->wcc export surface (10 types) + the unqualified-ref question are
separate follow-ups (#72/#75).
This commit is contained in:
2026-06-16 19:56:34 +09:00
parent 10d005ef58
commit 7a8acfb952
31 changed files with 3647 additions and 3747 deletions

View File

@@ -150,10 +150,10 @@ static const struct ent ents[] = {
{ .fixture = "lib/os/stattest.ww",
.mode = M_DIVERGE, .cite = "#59.9" },
/* #59.10 stoftest graduated to M_ID above (#62 fix) */
{ .fixture = "lib/ww/lex/toktest.ww",
{ .fixture = "lib/ww/syntax/toktest.ww", .inc = "lib/ww",
.mode = M_ID, .cite = "#59.11 graduated by #146 str==" },
/* asttest resolves `import tok` via -I lib/ww/lex, cf 905 */
{ .fixture = "lib/ww/asttest.ww", .inc = "lib/ww/lex",
/* toktest/asttest resolve `import syntax` via -I lib/ww, cf 905 */
{ .fixture = "lib/ww/syntax/asttest.ww", .inc = "lib/ww",
.mode = M_ID, .cite = "#59.12 graduated by #146 str==" },
/* -------- wwstage front-end gaps (task #59) -------------- */
{ .fixture = "lib/crypto/sha256/sha256_test.ww",
@@ -373,7 +373,7 @@ out:
* and the corpus rots silently as lib/ grows. */
static const char *covered[] = {
/* selfhost-embedded: byte-id'd by the 990-997 gates */
"lib/io", "lib/math", "lib/rt", "lib/types", "lib/ww/parse",
"lib/io", "lib/math", "lib/rt", "lib/types",
/* module body dragged into the lib/strconv/test fixtures */
"lib/strconv",
/* #17: the @test runner is AUTO-BUNDLED into every -T combined, so