go: parse.sx — function calls + member access + 12 tests [consumes-ast proposes-ast]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s

Adds postfix expression forms per Go spec:
  f()  f(x)  f(x, y, z)       — function calls
  x.y  x.y.z  obj.method(x)   — selector / member access

gp-parse-postfix sits between gp-parse-unary and gp-parse-primary,
so calls and selectors bind tighter than any unary prefix — `-f(x)`
parses as `-(f(x))`, not `(-f)(x)`. Postfix is left-associative
(`x.y.z` = `(x.y).z`), so the loop iterates rather than recurses
on the LHS.

AST shapes:
  Call:     (ast-app FN ARGS)              — canonical
  Selector: (list :select OBJ "field")     — Go-specific tag

The selector shape is a kit gap — lib/guest/ast.sx ships ast-app but
no ast-select, despite `obj.field` being universal across Go, Rust,
Swift, TS, JS, Python, Ruby, Java, C#. Logged in Blockers; tagging
[proposes-ast]. Worth promoting on the next nominally-typed guest.

parse 49/49, total 178/178.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-27 07:48:21 +00:00
parent 728a91e49f
commit e1c5fdae53
5 changed files with 169 additions and 8 deletions

View File

@@ -163,7 +163,10 @@ Progress-log line → push `origin/loops/go`.
- [x] Unary operators (`+x`, `-x`, `!x`, `^x`, `*p`, `&v`, `<-ch`).
`gp-parse-unary` recursive, sits between `gp-parse-expr` and
`gp-parse-primary`; right-associative chains (`!!x`).
- [ ] Function calls `f(a, b)` and member access `x.field`.
- [x] Function calls `f(a, b)` (canonical `ast-app`) and member access
`x.field` (Go-specific `(list :select OBJ "field")` — the AST kit
doesn't ship a selector node; this is a sister-plan-static-types
data point about what the canonical AST is missing).
- [ ] Index `x[i]` and slice `x[a:b]`/`x[a:b:c]`.
- [ ] Type assertion `v.(T)`.
- [ ] Type expressions: basic, slice `[]T`, array `[N]T`, map `map[K]V`,
@@ -178,7 +181,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: 37/37.
- **Acceptance:** parse/ suite at 80+ tests. Current: 49/49.
### Phase 3 — Bidirectional type checker, MVP (`lib/go/types.sx`) ⬜
- **Independent implementation.** Do NOT use lib/guest/static-types-
@@ -414,6 +417,19 @@ Every commit ends its message with a chisel note in brackets:
## Blockers
### Kit-gap proposals against `lib/guest/ast.sx`
Observed from building the Go parser:
1. **No selector / field-access node.** `obj.field` is a universal shape
across nominally-typed languages — Go, Rust, Swift, TS, JS, Python,
Ruby, Java, C#. The kit ships `ast-app` (function application) but
not `ast-select`. We rolled `(list :select OBJ "field")` locally as
a Go-specific tag. Worth promoting once a second consumer hits the
same need (likely immediately — almost every guest needs it).
Minimal repro: see `lib/go/parse.sx#gp-parse-postfix` (`.` branch).
### Kit-gap proposals against `lib/guest/lex.sx`
Observed from building the Go tokenizer. Not blocking Phase 2; surfaced
@@ -437,6 +453,15 @@ 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.: postfix forms — function calls `f(a, b)`
via canonical `ast-app`, and member access `x.field` via Go-specific
`(list :select OBJ "field")`. The AST kit has no selector node;
logged in Blockers as `[proposes-ast]` — every nominally-typed guest
will hit the same gap, worth promoting on the next consumer. Postfix
loop sits between unary and primary so calls bind tighter than unary
(`-f(x)` = `-(f(x))`). Covers nested calls, chained selectors,
methods `obj.m(x)`, mixed precedence. +12 tests, parse 49/49, total
178/178. `[consumes-ast proposes-ast]`.
- 2026-05-27 — Phase 2 cont.: unary prefix operators (`+`, `-`, `!`, `^`,
`*`, `&`, `<-`). `gp-parse-unary` is recursive (`!!x`) and sits between
`gp-parse-expr` and `gp-parse-primary` so unary always binds tighter