go: parse.sx — type assertion v.(T) + minimal type parser + 9 tests [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 18s

Postfix '.' branch now peeks at the next token to disambiguate:
  .ident   →  selector / member access  (list :select OBJ "field")
  .(TYPE)  →  type assertion            (list :assert OBJ TYPE)

New gp-parse-type covers the minimum types needed for assertions:
  name        →  (list :ty-name "int")
  pkg.Name    →  (list :ty-sel "pkg" "Name")
  *T  / **T   →  (list :ty-ptr (list :ty-ptr ...))

Full type grammar — slice []T, array [N]T, map[K]V, chan, func,
struct, interface — is a separate Phase 2 sub-deliverable.

Type AST shapes are Go-specific tagged lists; the canonical AST kit
has no type-system primitives at all yet. Worth a richer kit
discussion once Phase 3 (bidirectional type checker) lands and the
sister plan static-types-bidirectional has a real surface to react to.

parse 70/70, total 199/199.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-27 07:57:29 +00:00
parent e64d72f554
commit 503bdf12d6
5 changed files with 116 additions and 10 deletions

View File

@@ -171,7 +171,9 @@ Progress-log line → push `origin/loops/go`.
`(list :index OBJ IDX)` and `(list :slice OBJ LOW HIGH MAX)`
(LOW/HIGH/MAX may be nil) — kit lacks both. Permissive parser
accepts `a[1::3]` (strict Go rejects, but type phase can enforce).
- [ ] Type assertion `v.(T)`.
- [x] Type assertion `v.(T)`. `(list :assert OBJ TYPE)`. Includes a
minimal `gp-parse-type` (named / qualified `pkg.T` / pointer
`*T` / `**T`); full type grammar still pending below.
- [ ] Type expressions: basic, slice `[]T`, array `[N]T`, map `map[K]V`,
chan `chan T` / `chan<- T` / `<-chan T`, func, struct, interface,
pointer `*T`.
@@ -184,7 +186,7 @@ Progress-log line → push `origin/loops/go`.
assign, short-decl `:=`, send `ch <- v`, recv `<-ch`.
- [ ] End-to-end: hello-world, fibonacci, FizzBuzz, goroutine ping-pong,
struct + method.
- **Acceptance:** parse/ suite at 80+ tests. Current: 61/61.
- **Acceptance:** parse/ suite at 80+ tests. Current: 70/70.
### Phase 3 — Bidirectional type checker, MVP (`lib/go/types.sx`) ⬜
- **Independent implementation.** Do NOT use lib/guest/static-types-
@@ -467,6 +469,16 @@ Minimal repro: see `lib/go/lex.sx#gl-oct-digit?` and `#gl-match-op`.
_Newest first. Append one dated entry per commit._
- 2026-05-27 — Phase 2 cont.: type assertion `v.(T)` postfix form.
Postfix `.` branch now disambiguates between `.field` (selector) and
`.(...)` (type assertion) by peeking at the next token. New
`gp-parse-type` handles the minimum needed: named (`int`, `MyType`),
qualified (`pkg.T`), pointer (`*T`, `**T`). AST shapes are
Go-specific tagged lists — kit has no notion of types at all yet
(this is a meta-gap: full bidirectional types arrive in Phase 3, but
even the parser needs a type substrate). Covers chained,
call-result, after-selector, and binary-precedence interactions. +9
tests, parse 70/70, total 199/199. `[nothing]`.
- 2026-05-27 — Phase 2 cont.: index `x[i]` and slice `x[a:b]` /
`x[a:b:c]` postfix forms. New `gp-parse-bracket` + `gp-parse-bracket-expr`
branch off the same postfix loop as calls/selectors. AST: Go-specific