go: parse.sx — interface type expressions + 8 tests; type expressions DONE [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Adds Go interface type expressions:
interface {} → empty
interface { Close() } → no-param method
interface { String() string } → with single return
interface { Read([]byte) (int, error) } → multi-return method
interface { Stringer } → embedded named iface
interface { io.Reader } → qualified embedded
interface { io.Reader; Close() error } → mixed
gp-parse-interface-elems walks elements tolerating ASI semis. Each
element is either:
(list :method NAME PARAMS RESULTS)
(list :embed TYPE)
Method params/results reuse gp-parse-func-type-params/results — the
shape is identical to a free-standing func type. Go 1.18+ type sets
(interface { ~int | ~float64 }) are deferred until the generics
sub-deliverable.
With this, the full Phase 2 **type expressions** sub-deliverable is
complete (pending only field tags, struct/iface embeds details,
variadic, named func params, generics — all flagged later).
parse 106/106, total 235/235.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -174,12 +174,13 @@ Progress-log line → push `origin/loops/go`.
|
||||
- [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: **slice `[]T`, array `[N]T`, map `map[K]V`, chan
|
||||
- [x] Type expressions: **slice `[]T`, array `[N]T`, map `map[K]V`, chan
|
||||
`chan T` / `chan<- T` / `<-chan T`, pointer `*T`, named `T`,
|
||||
qualified `pkg.T`, func `func(...) ...`, struct `struct{...}` with
|
||||
shared-type field rows (`x, y int`)** all done — kit has no type
|
||||
primitives. Interface, embedded fields, field tags, variadic,
|
||||
named func-params, generics deferred.
|
||||
shared-type field rows (`x, y int`), interface `interface{...}`
|
||||
with methods + embedded interfaces (named and qualified)** all
|
||||
done — kit has no type primitives. Field tags, struct embeds,
|
||||
variadic, named func-params, Go 1.18 type sets, generics deferred.
|
||||
- [ ] Composite literals: `T{...}`, `[]T{...}`, `map[K]V{...}`,
|
||||
`struct{...}{...}`.
|
||||
- [ ] Declarations: `package`, `import`, `var`, `const`, `type`, `func`
|
||||
@@ -190,8 +191,8 @@ Progress-log line → push `origin/loops/go`.
|
||||
- [ ] End-to-end: hello-world, fibonacci, FizzBuzz, goroutine ping-pong,
|
||||
struct + method.
|
||||
- **Acceptance:** parse/ suite at 80+ tests. **Acceptance bar crossed:
|
||||
98/98.** Remaining sub-items (interface types, composite literals,
|
||||
decls, stmts, e2e) still keep Phase 2 open ⬜.
|
||||
106/106.** Remaining sub-items (composite literals, decls, stmts,
|
||||
e2e) still keep Phase 2 open ⬜.
|
||||
|
||||
### Phase 3 — Bidirectional type checker, MVP (`lib/go/types.sx`) ⬜
|
||||
- **Independent implementation.** Do NOT use lib/guest/static-types-
|
||||
@@ -508,6 +509,18 @@ 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.: interface-type expressions. `interface {}`,
|
||||
`interface { Close() }`, `interface { String() string }`,
|
||||
`interface { Read([]byte) (int, error) }`, plus embedded interfaces
|
||||
(`Stringer`, `io.Reader`). AST shape:
|
||||
`(list :ty-interface ELEMS)` where each element is either
|
||||
`(list :method NAME PARAMS RESULTS)` or `(list :embed TYPE)`. Method
|
||||
params reuse `gp-parse-func-type-params` — same anonymous-only shape
|
||||
as func types. Go 1.18+ type sets (`~int | ~float64`) deferred to
|
||||
generics work. With this, all Phase-2 **type expressions** are
|
||||
complete. +8 tests, parse 106/106, total 235/235. `[nothing]` — pure
|
||||
Go parser; the field-binding-group kit-gap proposal from the previous
|
||||
commit covers the cross-language angle.
|
||||
- 2026-05-27 — Phase 2 cont.: struct-type expressions. `struct {}`,
|
||||
`struct { x int }`, `struct { x int; y string }`, `struct { x, y int }`
|
||||
(shared type), nested struct fields. `gp-parse-struct-fields` walks
|
||||
|
||||
Reference in New Issue
Block a user