selfhost: mirror enum tokens + AST + parsetype branch

Parses byte-identical to the C frontend on enum sources (verified
via `diff` of wwdump vs wwdump_ww -a on an enum-using fixture).
The selfhost side reserves the slot in the AST and TY_* enums so
later check.ww and cgen mirror work doesn't shift numeric IDs.

Codegen-side enum support (member-value folding in cgdot, enum↔int
pass-through in cgtypeassert) is deferred — current selfhost sources
don't use enum, so 990_selfhost / 995_self_rebuild stay green.

main.combined.ww in wwdump/ and w6c/ regenerated by `ww build` as
a side effect of `make wwstage`.
This commit is contained in:
2026-05-12 04:20:59 +09:00
parent 34817eedcd
commit 5bf30f209c
7 changed files with 1161 additions and 6 deletions

1014
lib/ww/lex/lex.combined.ww Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -111,8 +111,9 @@ def TK_FATARROW: i32 = 81;
def TK_IS: i32 = 82;
def TK_VOID: i32 = 83;
def TK_YIELD: i32 = 84;
def TK_ENUM: i32 = 85;
def TK_LAST: i32 = 85;
def TK_LAST: i32 = 86;
// ---- Pos / Tok --------------------------------------------------------
//
@@ -166,6 +167,7 @@ export fn kwlookup(p: *u8, n: i32) i32 = {
if (streqn(p, "def", n)) { return TK_DEF; };
if (streqn(p, "defer", n)) { return TK_DEFER; };
if (streqn(p, "else", n)) { return TK_ELSE; };
if (streqn(p, "enum", n)) { return TK_ENUM; };
if (streqn(p, "export", n)) { return TK_EXPORT; };
if (streqn(p, "false", n)) { return TK_FALSE; };
if (streqn(p, "fn", n)) { return TK_FN; };
@@ -232,6 +234,7 @@ export fn tokname(k: i32) str = {
if (k == TK_MATCH) { return "match"; };
if (k == TK_CONST) { return "const"; };
if (k == TK_UNDER) { return "_"; };
if (k == TK_ENUM) { return "enum"; };
if (k == TK_LPAREN) { return "("; };
if (k == TK_RPAREN) { return ")"; };