ww: lift introspection files to lib/ww/ (ast, lex, tok, parse, typ, sym)

This commit is contained in:
2026-05-11 16:17:23 +09:00
parent 3f8d64e01b
commit 177862fb29
16 changed files with 80 additions and 74 deletions

View File

@@ -437,8 +437,8 @@ export fn parseu64(s: str) (u64 | str) = {
return v;
};
// MODULE: wcc
// selfhost/cmd/wcc/tok.ww — port of cmd/wcc/tok.c plus the Tkind /
// MODULE: ww
// lib/ww/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
@@ -927,8 +927,8 @@ export fn toupper(c: u8) u8 = {
return c;
};
// MODULE: wcc
// selfhost/cmd/wcc/lex.ww — port of cmd/wcc/lex.c.
// MODULE: ww
// lib/ww/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
@@ -1616,8 +1616,8 @@ export fn lexnext(l: *lex, out: *tok) void = {
out.text = astrndup(l.a, one.ptr, 1u64);
};
// MODULE: wcc
// selfhost/cmd/wcc/ast.ww — port of cmd/wcc/ast.c (Node defs + printer).
// MODULE: ww
// lib/ww/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.
@@ -1954,8 +1954,8 @@ export fn astprint(fd: i32, n: *node) void = {
pr(fd, n, 0);
};
// MODULE: wcc
// selfhost/cmd/wcc/parse.ww — port of cmd/wcc/parse.c.
// MODULE: ww
// lib/ww/parse.ww — port of cmd/wcc/parse.c.
//
// Status: GROWING stub. Currently handles top-level `use IDENT;`,
// `def NAME: TYPE = LIT;`, `type NAME = TYPE;`, and `fn NAME(params)
@@ -2942,8 +2942,8 @@ export fn parsefile(p: *parser) *node = {
return f;
};
// MODULE: wcc
// selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c.
// MODULE: ww
// lib/ww/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
@@ -3273,8 +3273,8 @@ export fn typeeq(a: *tinfo, b: *tinfo) bool = {
return true; // primitives match by kind alone
};
// MODULE: wcc
// selfhost/cmd/wcc/sym.ww — port of cmd/wcc/sym.c.
// MODULE: ww
// lib/ww/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