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:
@@ -3,7 +3,7 @@
|
||||
3. cmd/ is the C bootstrap toolchain (wcc frontend lib, w6c/w6a/w6l per-arch, ww driver); selfhost/ is the ww reimplementation
|
||||
4. All C code must strictly align with plan 9 coding style
|
||||
5. lib/ is the standard library; follow Hare APIs (signatures, layout, error idioms) — consult ref/hare/ before designing new modules. Package declaration form is Go-style explicit `package foo;` and imports use `import foo;` (executables declare `package main;`) per language design (rob-pike + plan-9 sensibility); lib/ API surface still mirrors Hare.
|
||||
6. ref/hare and ref/plan9front are read-only references — consult before inventing data shapes or syntax
|
||||
6. ref/hare and ref/plan9front are read-only references — consult before inventing data shapes or syntax. Carve-out: the ww compiler frontend is ONE package `lib/ww/syntax/` (tok+lex+ast+sym+typ+parse), a deliberate Go-over-Hare departure modelled on Go's `cmd/compile/internal/syntax` rather than ref/hare/hare's `{ast,lex,parse}` split. Rationale: the split's only payoff is third-party reuse (an IDE wanting `ast` without the parser), which ww has zero of — its frontend is consumed by exactly one client, the `wcc` backend. Consolidating dissolves the cross-package export sprawl (a fn over an unexported sibling type re-triggers sep-build's check_exported_type). Rule 6/12 still bind the internal data shapes (AST kinds, token model, lexer/parser state mirror ref/hare/hare); only the module DECOMPOSITION collapses. The surviving export surface is `syntax`'s public API consumed by `wcc` (a small Hare-faithful set). Ref: USER-approved #74; spec .ai/rob-frontend-reorg.md (rob, drew2 fidelity-confirmed).
|
||||
7. No workarounds. If a bug forces a workaround, STOP and report with a precise repro. Document any retained divergence at the site with a pointer to the filed task. Never silent.
|
||||
8. Comments are WHY-only. Never narrate WHAT the code does — names carry the WHAT. Comment only non-obvious WHY: a constraint, a divergence from a reference, a citation to a filed task.
|
||||
9. Hare-fidelity over convenience. No ad-hoc extensions, renames, or convenience wrappers in lib/. Cite ref/hare/<module>/<file> for every signature ported. Carve-out: the Hare `_unsafe` suffix convention is dropped wholesale (ww is C/Plan-9-lineage, an unmanaged systems language — no GC, no "safe" baseline to be unsafe relative to). bytes→str is a pure reinterpret (`strings.frombytes`, renamed from Hare's `fromutf8_unsafe`); validation is opt-in via `utf8.validate(b)?` at the IO source, never wrapped per-construction. Rationale: ref/hare/strings/utf8.ha:10,22 — the suffix flags Hare's managed-bytes-safety axis, which ww doesn't have. The honest name (`frombytes`) reserves `fromutf8` for a future true validating helper. Carve-out: lib/ tests use Go's external-test-package idiom (`package <mod>_test;` + `import <mod>;`), a sanctioned Go-over-Hare departure — ww hard-rejects self-import (full Go), and Hare's same-package `@test` colocation now has a ww analogue: in-package white-box `@test` files (`package <mod>;`, colocated) are sanctioned alongside the external black-box `package <mod>_test;` split — Go's `foo`/`foo_test` model — now that the non-T `@test` drop landed (#6, harec check.c:3941, 08a76cf; #5 closed). Rule 5/9 binds lib/ *API* surface, not test-authoring style. Ref: Go `foo_test` convention; task #16.
|
||||
|
||||
24
Makefile
24
Makefile
@@ -117,13 +117,13 @@ $(OBJ)/w6l/%.o: cmd/w6l/%.c cmd/w6l/l.h | $(OBJ)/w6l
|
||||
$(CC) $(CFLAGS) -Icmd/w6l -c -o $@ $<
|
||||
|
||||
# ---- ww-side wwdump (the lexer port, exercised by 990_selfhost) --------
|
||||
# Built via the user-facing ww driver. The introspection ports (lex,
|
||||
# tok, ast, parse, typ, sym) live in lib/ww/; the compiler-only bits
|
||||
# (check, cgen*) stay in selfhost/cmd/wcc/. Output named wwdump_ww
|
||||
# Built via the user-facing ww driver. The frontend (lex, tok, ast,
|
||||
# parse, typ, sym) is the `syntax` package in lib/ww/syntax/; the
|
||||
# compiler-only bits (check, cgen*) stay in selfhost/cmd/wcc/. Output named wwdump_ww
|
||||
# to avoid colliding with the C-side wwdump in $(BIN).
|
||||
$(BIN)/wwdump_ww: selfhost/cmd/wwdump/main.ww \
|
||||
lib/ww/lex/lex.ww lib/ww/lex/tok.ww lib/ww/ast.ww \
|
||||
lib/ww/parse/parse.ww lib/ww/parse/expr.ww lib/ww/parse/stmt.ww lib/ww/parse/decl.ww lib/ww/typ.ww lib/ww/sym.ww \
|
||||
lib/ww/syntax/lex.ww lib/ww/syntax/tok.ww lib/ww/syntax/ast.ww \
|
||||
lib/ww/syntax/parse.ww lib/ww/syntax/expr.ww lib/ww/syntax/stmt.ww lib/ww/syntax/decl.ww lib/ww/syntax/typ.ww lib/ww/syntax/sym.ww \
|
||||
selfhost/cmd/wcc/check.ww \
|
||||
selfhost/cmd/wcc/cgen.ww selfhost/cmd/wcc/cgenexpr.ww \
|
||||
selfhost/cmd/wcc/cgenstmt.ww selfhost/cmd/wcc/cgenutil.ww \
|
||||
@@ -134,18 +134,16 @@ $(BIN)/wwdump_ww: selfhost/cmd/wwdump/main.ww \
|
||||
@mkdir -p $(BIN)/wwdump_ww.d
|
||||
cd $(BIN)/wwdump_ww.d && $(CURDIR)/$(BIN)/ww build \
|
||||
-I $(CURDIR)/lib/ww \
|
||||
-I $(CURDIR)/lib/ww/lex \
|
||||
-I $(CURDIR)/lib/ww/parse \
|
||||
-I $(CURDIR)/selfhost/cmd/wcc \
|
||||
$(CURDIR)/selfhost/cmd/wwdump/main.ww
|
||||
mv $(BIN)/wwdump_ww.d/main $@
|
||||
|
||||
# ---- ww-side w6c (compiler port, exercised by 994_w6c_ww) -------------
|
||||
# Thin driver: parse + cgen. The frontend (lex/parse/ast/...) lives in
|
||||
# lib/ww/; cgen + check live in selfhost/cmd/wcc/.
|
||||
# Thin driver: parse + cgen. The frontend (lex/parse/ast/...) is the
|
||||
# `syntax` package in lib/ww/syntax/; cgen + check live in selfhost/cmd/wcc/.
|
||||
$(BIN)/w6c_ww: selfhost/cmd/w6c/main.ww \
|
||||
lib/ww/lex/lex.ww lib/ww/lex/tok.ww lib/ww/ast.ww \
|
||||
lib/ww/parse/parse.ww lib/ww/parse/expr.ww lib/ww/parse/stmt.ww lib/ww/parse/decl.ww lib/ww/typ.ww lib/ww/sym.ww \
|
||||
lib/ww/syntax/lex.ww lib/ww/syntax/tok.ww lib/ww/syntax/ast.ww \
|
||||
lib/ww/syntax/parse.ww lib/ww/syntax/expr.ww lib/ww/syntax/stmt.ww lib/ww/syntax/decl.ww lib/ww/syntax/typ.ww lib/ww/syntax/sym.ww \
|
||||
selfhost/cmd/wcc/check.ww selfhost/cmd/wcc/wwi.ww \
|
||||
selfhost/cmd/wcc/cgen.ww selfhost/cmd/wcc/cgenexpr.ww \
|
||||
selfhost/cmd/wcc/cgenstmt.ww selfhost/cmd/wcc/cgenutil.ww \
|
||||
@@ -156,8 +154,6 @@ $(BIN)/w6c_ww: selfhost/cmd/w6c/main.ww \
|
||||
@mkdir -p $(BIN)/w6c_ww.d
|
||||
cd $(BIN)/w6c_ww.d && $(CURDIR)/$(BIN)/ww build \
|
||||
-I $(CURDIR)/lib/ww \
|
||||
-I $(CURDIR)/lib/ww/lex \
|
||||
-I $(CURDIR)/lib/ww/parse \
|
||||
-I $(CURDIR)/selfhost/cmd/wcc \
|
||||
$(CURDIR)/selfhost/cmd/w6c/main.ww
|
||||
mv $(BIN)/w6c_ww.d/main $@
|
||||
@@ -3606,8 +3602,6 @@ nocc:
|
||||
@# Pass -I $(CURDIR)/lib so `use os` etc. resolve to source.
|
||||
@cd $(NOCC_BIN) && ./ww build \
|
||||
-I $(CURDIR)/lib/ww \
|
||||
-I $(CURDIR)/lib/ww/lex \
|
||||
-I $(CURDIR)/lib/ww/parse \
|
||||
-I $(CURDIR)/selfhost/cmd/wcc \
|
||||
-I $(CURDIR)/lib $(CURDIR)/selfhost/cmd/w6c/main.ww && mv main w6c_ww1
|
||||
@cd $(NOCC_BIN) && ./ww build -I $(CURDIR)/selfhost/cmd/w6a \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// lib/ww/ast.ww — port of cmd/wcc/ast.c (Node defs + printer).
|
||||
// lib/ww/syntax/ast.ww — port of cmd/wcc/ast.c (Node defs + printer).
|
||||
//
|
||||
// Status: AST printer is fully ported. Constructor `newnode` is here.
|
||||
// The parser (parse.ww) is currently minimal — see its file header.
|
||||
@@ -7,11 +7,10 @@
|
||||
// by value (8 *node pointers + 2 strs + a few ints), so callers always
|
||||
// hand around `*node`. Only `newnode` allocates and returns a *node.
|
||||
|
||||
package ww;
|
||||
package syntax;
|
||||
|
||||
import os;
|
||||
import strconv;
|
||||
import tok;
|
||||
|
||||
// ---- Nkind ------------------------------------------------------------
|
||||
//
|
||||
@@ -1,6 +1,6 @@
|
||||
// asttest — functional-equivalence pin for [[nkname]] after the
|
||||
// if-ladder → switch fold (struct fold S2). Run with
|
||||
// `ww run lib/ww/asttest.ww`.
|
||||
// `ww run -I lib/ww lib/ww/syntax/asttest.ww`.
|
||||
//
|
||||
// nkname is checked against every nkind value (the full ladder the
|
||||
// switch replaced) plus the out-of-band fallback ("?"). A failing row
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
package main;
|
||||
|
||||
import ast;
|
||||
import syntax;
|
||||
|
||||
|
||||
fn checkname(k: nkind, want: str) void = {
|
||||
@@ -1,10 +1,9 @@
|
||||
// lib/ww/parse/decl.ww — declaration parsing, split out of parse.ww.
|
||||
// lib/ww/syntax/decl.ww — declaration parsing, split out of parse.ww.
|
||||
|
||||
package parse;
|
||||
package syntax;
|
||||
|
||||
import os;
|
||||
import strings;
|
||||
import tok;
|
||||
|
||||
// `import encoding.utf8;` — the driver resolves the dotted path to
|
||||
// a directory; only the leaf (`utf8`) is needed downstream as the
|
||||
@@ -1,9 +1,8 @@
|
||||
// lib/ww/parse/expr.ww — expression parsing, split out of parse.ww.
|
||||
// lib/ww/syntax/expr.ww — expression parsing, split out of parse.ww.
|
||||
|
||||
package parse;
|
||||
package syntax;
|
||||
|
||||
import os;
|
||||
import tok;
|
||||
|
||||
// streqlocal — str-to-str compare. Inlined here to avoid a cross-
|
||||
// module `use sym;` for one call site.
|
||||
@@ -1,4 +1,4 @@
|
||||
// lib/ww/lex/lex.ww — port of cmd/wcc/lex.c.
|
||||
// lib/ww/syntax/lex.ww — port of cmd/wcc/lex.c.
|
||||
//
|
||||
// The DFA, the helpers, and the order of decisions all mirror the C
|
||||
// version exactly. The 990_selfhost test diffs the resulting token
|
||||
@@ -11,10 +11,8 @@
|
||||
// in shape, not in observable behaviour. Token kind values stay
|
||||
// numerically identical.
|
||||
|
||||
package lex;
|
||||
package syntax;
|
||||
|
||||
// Sibling import (tok) auto-resolves via task #22 dir-enum when
|
||||
// callers `import lex;` (which dir-enums lib/ww/lex/).
|
||||
import os;
|
||||
import ascii;
|
||||
import strings;
|
||||
@@ -1,4 +1,4 @@
|
||||
// lib/ww/parse/parse.ww — port of cmd/wcc/parse.c (entry + plumbing).
|
||||
// lib/ww/syntax/parse.ww — port of cmd/wcc/parse.c (entry + plumbing).
|
||||
//
|
||||
// Split into Hare-style submodule: parse.ww (here) holds the parser
|
||||
// struct, lexer plumbing, parsetype, parsefile (entry). Expression,
|
||||
@@ -10,14 +10,12 @@
|
||||
// stores the current token as flat primitive fields rather than a
|
||||
// nested `tok` struct; `refill` copies a freshly lexed token in.
|
||||
|
||||
package parse;
|
||||
package syntax;
|
||||
|
||||
// Sibling imports (expr, stmt, decl) auto-resolve via task #22
|
||||
// dir-enum when callers `import parse;` (which dir-enums
|
||||
// lib/ww/parse/).
|
||||
// Sibling files (expr, stmt, decl) are the same `package syntax`,
|
||||
// auto-resolved via task #22 dir-enum of lib/ww/syntax/.
|
||||
import os;
|
||||
import strings;
|
||||
import tok;
|
||||
|
||||
type parser = struct {
|
||||
l: *lex,
|
||||
@@ -1,9 +1,8 @@
|
||||
// lib/ww/parse/stmt.ww — statement parsing, split out of parse.ww.
|
||||
// lib/ww/syntax/stmt.ww — statement parsing, split out of parse.ww.
|
||||
|
||||
package parse;
|
||||
package syntax;
|
||||
|
||||
import os;
|
||||
import tok;
|
||||
|
||||
fn parseletlocal(p: *parser) *node = {
|
||||
let pf = p.curfile;
|
||||
@@ -1,10 +1,10 @@
|
||||
// lib/ww/sym.ww — port of cmd/wcc/sym.c.
|
||||
// lib/ww/syntax/sym.ww — port of cmd/wcc/sym.c.
|
||||
//
|
||||
// Per-scope hashtable, chained to the parent. Lookup walks up.
|
||||
// Plan 9 / Hare flavoured. Duplicate definitions in the same scope
|
||||
// return nil; the caller flags the error.
|
||||
|
||||
package ww;
|
||||
package syntax;
|
||||
|
||||
// Symbol kinds — must stay numerically aligned with cmd/wcc/ww.h Skind.
|
||||
type skind = enum i32 {
|
||||
@@ -108,11 +108,10 @@ export fn scopelookup(s: *scope, name: str) *sym = {
|
||||
// Same FNV bucket + hashnext chain + parent walk as scopelookup, with
|
||||
// an `skind == SK_TYPE` filter. Used to disambiguate the bare-TNAME
|
||||
// vs imported-module-bareword collision: when scopelookup returns the
|
||||
// SK_USE sym for a leaf that ALSO names a type (e.g. `tok` struct
|
||||
// declared in lib/ww/lex/tok.ww with `package lex;` while
|
||||
// `import tok;` registers a same-name SK_USE), the resolver needs
|
||||
// the type entry — the struct's mod may differ from the leaf (lex/tok
|
||||
// pair) so scopelookupinmodule(c, leaf, leaf) won't find it.
|
||||
// SK_USE sym for a leaf that ALSO names a type (a same-name `import X;`
|
||||
// SK_USE shadowing a struct X declared in another module), the resolver
|
||||
// needs the type entry — the struct's mod may differ from the leaf so
|
||||
// scopelookupinmodule(c, leaf, leaf) won't find it.
|
||||
//
|
||||
// #58/#50: within each scope, Pass-1 prefers an SK_TYPE whose `sym.mod`
|
||||
// matches `mod`; Pass-2 falls back to the first SK_TYPE regardless of
|
||||
@@ -1,4 +1,4 @@
|
||||
// lib/ww/lex/tok.ww — port of cmd/wcc/tok.c plus the Tkind /
|
||||
// lib/ww/syntax/tok.ww — port of cmd/wcc/tok.c plus the Tkind /
|
||||
// Tok / Pos shapes from cmd/wcc/ww.h.
|
||||
//
|
||||
// Token kind values must stay numerically equal to the C side: the
|
||||
@@ -9,7 +9,7 @@
|
||||
// Bottom of file: tokprint, which emits one token per line in a
|
||||
// format identical to cmd/wcc/tok.c:tokprint().
|
||||
|
||||
package lex;
|
||||
package syntax;
|
||||
|
||||
import os;
|
||||
import strconv;
|
||||
@@ -1,7 +1,7 @@
|
||||
// toktest — functional-equivalence pin for [[tokname]], [[kwlookup]]
|
||||
// (struct fold S1) and [[tokprint]]/fputq (struct fold S9, the
|
||||
// if-ladder → switch folds in tok.ww).
|
||||
// Run with `ww run -I lib/ww/lex lib/ww/lex/toktest.ww`.
|
||||
// Run with `ww run -I lib/ww lib/ww/syntax/toktest.ww`.
|
||||
//
|
||||
// tokname is checked against every tkind value (the full ladder the
|
||||
// switch replaced, plus the unknown-kind fallback); kwlookup is
|
||||
@@ -22,8 +22,7 @@
|
||||
package main;
|
||||
|
||||
import os;
|
||||
import tok;
|
||||
import lex;
|
||||
import syntax;
|
||||
|
||||
|
||||
fn checkname(k: tkind, want: str) void = {
|
||||
@@ -1,4 +1,4 @@
|
||||
// lib/ww/typ.ww — port of cmd/wcc/type.c.
|
||||
// lib/ww/syntax/typ.ww — port of cmd/wcc/type.c.
|
||||
//
|
||||
// Status: full structural port. The C version uses module-globals for
|
||||
// the primitive types (tyvoid, tyi32, …); ww doesn't have writable
|
||||
@@ -6,7 +6,7 @@
|
||||
// the checker passes around explicitly. typesinit fills the tctx
|
||||
// once per program.
|
||||
|
||||
package ww;
|
||||
package syntax;
|
||||
|
||||
import os;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,12 +15,7 @@ package main;
|
||||
import os;
|
||||
import rt;
|
||||
import strings;
|
||||
import tok;
|
||||
import lex;
|
||||
import ast;
|
||||
import parse;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import check;
|
||||
import cgen;
|
||||
import wwi;
|
||||
|
||||
@@ -25,10 +25,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import ast;
|
||||
import tok;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import strconv;
|
||||
import strings;
|
||||
import io;
|
||||
|
||||
@@ -13,10 +13,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import ast;
|
||||
import tok;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import strconv;
|
||||
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import ast;
|
||||
import tok;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import strconv;
|
||||
|
||||
// cgfloatbits — materialise a float constant in X0: MOVQ the IEEE bits
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import ast;
|
||||
import tok;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import strconv;
|
||||
|
||||
// ---- statement cgen --------------------------------------------------
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import ast;
|
||||
import tok;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import strconv;
|
||||
|
||||
// ---- variadic-call helpers (Hare-style `T...` param) -----------------
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import tok;
|
||||
import syntax;
|
||||
import strconv;
|
||||
|
||||
type checker = struct {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
package wcc;
|
||||
|
||||
import os;
|
||||
import tok;
|
||||
import syntax;
|
||||
import strconv;
|
||||
|
||||
// --- byte writers ------------------------------------------------------
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,12 +12,7 @@
|
||||
package main;
|
||||
|
||||
import os;
|
||||
import tok;
|
||||
import lex;
|
||||
import ast;
|
||||
import parse;
|
||||
import typ;
|
||||
import sym;
|
||||
import syntax;
|
||||
import check;
|
||||
import cgen;
|
||||
import strconv;
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
package test;
|
||||
|
||||
import typ;
|
||||
import ast;
|
||||
import sym;
|
||||
import syntax;
|
||||
|
||||
export fn main() i32 = {
|
||||
let s: *scope = newscope(nil);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 904_tok_run — execute the lib/ww/lex tokname/kwlookup @test fixture
|
||||
* 904_tok_run — execute the lib/ww/syntax tokname/kwlookup @test fixture
|
||||
* under the C-side `ww run` driver and assert exit 0.
|
||||
*
|
||||
* Same thin-wrapper shape as 904_ascii_run / 967_bytes_run: toktest.ww
|
||||
@@ -38,10 +38,11 @@ main(void)
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
|
||||
const char *src = "lib/ww/lex/toktest.ww";
|
||||
char path[1024], cmd[2048];
|
||||
const char *src = "lib/ww/syntax/toktest.ww";
|
||||
char path[1024], inc[1024], cmd[3072];
|
||||
snprintf(path, sizeof path, "%s/%s", cwd, src);
|
||||
snprintf(cmd, sizeof cmd, "%s/ww test %s", bin, path);
|
||||
snprintf(inc, sizeof inc, "%s/lib/ww", cwd);
|
||||
snprintf(cmd, sizeof cmd, "%s/ww test -I %s %s", bin, inc, path);
|
||||
int rc = runwait(cmd);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "tok_run FAIL: %s exited %d\n", src, rc);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
* which the 990_selfhost wwdump diff only covers for kinds that appear
|
||||
* in its corpus.
|
||||
*
|
||||
* Unlike 904_tok_run, the fixture imports `ast` (package ww), whose
|
||||
* printer references tok's tkind/tokname, so the run needs
|
||||
* `-I lib/ww/lex` to resolve that transitive import.
|
||||
* Unlike 904_tok_run, the fixture imports the `syntax` package, whose
|
||||
* printer references the token tkind/tokname, so the run needs
|
||||
* `-I lib/ww` to resolve the `import syntax` directory package.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -42,10 +42,10 @@ main(void)
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
|
||||
const char *src = "lib/ww/asttest.ww";
|
||||
const char *src = "lib/ww/syntax/asttest.ww";
|
||||
char path[1024], inc[1024], cmd[3072];
|
||||
snprintf(path, sizeof path, "%s/%s", cwd, src);
|
||||
snprintf(inc, sizeof inc, "%s/lib/ww/lex", cwd);
|
||||
snprintf(inc, sizeof inc, "%s/lib/ww", cwd);
|
||||
snprintf(cmd, sizeof cmd, "%s/ww test -I %s %s", bin, inc, path);
|
||||
int rc = runwait(cmd);
|
||||
if (rc != 0) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -170,10 +170,10 @@ probe_dump_diff(const char *bin)
|
||||
{
|
||||
const char *tok_inputs[] = {
|
||||
"selfhost/cmd/wcc/err.ww",
|
||||
"lib/ww/lex/lex.ww",
|
||||
"lib/ww/lex/tok.ww",
|
||||
"lib/ww/ast.ww",
|
||||
"lib/ww/parse/parse.ww", "lib/ww/parse/expr.ww", "lib/ww/parse/stmt.ww", "lib/ww/parse/decl.ww",
|
||||
"lib/ww/syntax/lex.ww",
|
||||
"lib/ww/syntax/tok.ww",
|
||||
"lib/ww/syntax/ast.ww",
|
||||
"lib/ww/syntax/parse.ww", "lib/ww/syntax/expr.ww", "lib/ww/syntax/stmt.ww", "lib/ww/syntax/decl.ww",
|
||||
"selfhost/cmd/wwdump/main.ww",
|
||||
"selfhost/test/smoke.ww",
|
||||
NULL,
|
||||
@@ -186,12 +186,12 @@ probe_dump_diff(const char *bin)
|
||||
const char *ast_inputs[] = {
|
||||
"selfhost/test/uses.ww",
|
||||
"selfhost/cmd/wcc/err.ww",
|
||||
"lib/ww/lex/lex.ww",
|
||||
"lib/ww/lex/tok.ww",
|
||||
"lib/ww/ast.ww",
|
||||
"lib/ww/parse/parse.ww", "lib/ww/parse/expr.ww", "lib/ww/parse/stmt.ww", "lib/ww/parse/decl.ww",
|
||||
"lib/ww/typ.ww",
|
||||
"lib/ww/sym.ww",
|
||||
"lib/ww/syntax/lex.ww",
|
||||
"lib/ww/syntax/tok.ww",
|
||||
"lib/ww/syntax/ast.ww",
|
||||
"lib/ww/syntax/parse.ww", "lib/ww/syntax/expr.ww", "lib/ww/syntax/stmt.ww", "lib/ww/syntax/decl.ww",
|
||||
"lib/ww/syntax/typ.ww",
|
||||
"lib/ww/syntax/sym.ww",
|
||||
"selfhost/cmd/wcc/check.ww",
|
||||
"selfhost/cmd/wcc/cgen.ww",
|
||||
"selfhost/cmd/wwdump/main.ww",
|
||||
@@ -572,7 +572,7 @@ probe_resolve(const char *bin)
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return -1;
|
||||
const char *fixtures[] = {
|
||||
"selfhost/cmd/wcc/err.ww",
|
||||
"lib/ww/lex/tok.ww",
|
||||
"lib/ww/syntax/tok.ww",
|
||||
"selfhost/test/smoke.ww",
|
||||
NULL,
|
||||
};
|
||||
@@ -747,8 +747,8 @@ probe_ww_links(const char *bin)
|
||||
runwait(cmd);
|
||||
/* ww build to get the .combined.ww as a side effect. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse -I %s/selfhost/cmd/wcc %s >/dev/null 2>&1",
|
||||
tmpdir, bin, cwd, cwd, cwd, cwd, tmpsrc);
|
||||
"cd %s && timeout 180 %s/ww build -I %s/lib/ww -I %s/selfhost/cmd/wcc %s >/dev/null 2>&1",
|
||||
tmpdir, bin, cwd, cwd, tmpsrc);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "ww-links FAIL: ww build %s\n", fix);
|
||||
fail++;
|
||||
@@ -817,7 +817,7 @@ static int
|
||||
probe_cgen_match(const char *bin)
|
||||
{
|
||||
const char *files[] = {
|
||||
"lib/ww/lex/tok.ww",
|
||||
"lib/ww/syntax/tok.ww",
|
||||
"selfhost/test/smoke.ww",
|
||||
NULL,
|
||||
};
|
||||
|
||||
@@ -242,8 +242,8 @@ main(void)
|
||||
static char wwdump_src[2048], wwdump_incs[4096];
|
||||
snprintf(wwdump_src, sizeof wwdump_src, "%s/selfhost/cmd/wwdump/main.ww", cwd);
|
||||
snprintf(wwdump_incs, sizeof wwdump_incs,
|
||||
"%s/lib/ww:%s/lib/ww/lex:%s/lib/ww/parse:%s/lib/encoding/utf8:%s/selfhost/cmd/wcc",
|
||||
cwd, cwd, cwd, cwd, cwd);
|
||||
"%s/lib/ww:%s/lib/encoding/utf8:%s/selfhost/cmd/wcc",
|
||||
cwd, cwd, cwd);
|
||||
cases[1].src = wwdump_src;
|
||||
cases[1].incs = wwdump_incs;
|
||||
|
||||
|
||||
@@ -102,16 +102,16 @@ spawn_build(const char *bin, const char *cwd, struct buildjob *j)
|
||||
if (j->inc_local && j->inc_local[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww_ww build -o %s/main -I %s/%s "
|
||||
"-I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse "
|
||||
"-I %s/lib/ww "
|
||||
"-I %s/selfhost/cmd/wcc %s/%s >/dev/null 2>%s/build.err",
|
||||
j->workdir, bin, j->workdir, cwd, j->inc_local,
|
||||
cwd, cwd, cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
} else {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww_ww build -o %s/main "
|
||||
"-I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse "
|
||||
"-I %s/lib/ww "
|
||||
"-I %s/selfhost/cmd/wcc %s/%s >/dev/null 2>%s/build.err",
|
||||
j->workdir, bin, j->workdir, cwd, cwd, cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
j->workdir, bin, j->workdir, cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
}
|
||||
|
||||
pid_t p = fork();
|
||||
|
||||
Reference in New Issue
Block a user