ERR/E0.1: error-set decls + ! / !Named type exprs (parser)
Parser-only first step of the error-handling stream. No sema/codegen.
- token: `kw_error` keyword (`!` reuses existing `.bang`).
- ast: `ErrorSetDecl { name, tag_names }` + `ErrorTypeExpr { name: ?[] }`
(null = inferred `!`, non-null = `!Named`); wired into Node.Data and
declName.
- parser: `parseErrorSetDecl` (comma-separated tags, optional trailing
comma/`;`) dispatched from parseConstBinding; `!` / `!Named` parsed in
parseTypeExpr; result-list loop enforces error type as trailing-only;
hasFnBodyAfterArrow skips `.bang` so failable-return fns are recognised.
- print: new focused AST round-trip printer (decls + type exprs); loud
`error.UnsupportedNode` otherwise. Registered in root.zig.
- sema/lsp: exhaustive switch arms for the two new nodes.
- tests: 11 inline parser unit tests (shapes + 3 round-trip prints + 2
trailing-position rejections).
zig build, zig build test, and 254/254 examples green.
This commit is contained in:
@@ -13,6 +13,7 @@ pub const Tag = enum {
|
||||
kw_true,
|
||||
kw_false,
|
||||
kw_enum,
|
||||
kw_error, // error (error-set declaration)
|
||||
kw_case,
|
||||
kw_break,
|
||||
kw_continue,
|
||||
@@ -222,6 +223,7 @@ pub const keywords = std.StaticStringMap(Tag).initComptime(.{
|
||||
.{ "true", .kw_true },
|
||||
.{ "false", .kw_false },
|
||||
.{ "enum", .kw_enum },
|
||||
.{ "error", .kw_error },
|
||||
.{ "case", .kw_case },
|
||||
.{ "break", .kw_break },
|
||||
.{ "continue", .kw_continue },
|
||||
|
||||
Reference in New Issue
Block a user