go: parse.sx — multi-form file parsing + 7 e2e tests; PHASE 2 COMPLETE [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Final Phase 2 sub-deliverable. go-parse now handles whole Go files:
- Empty source → nil
- Single top-level form → that form (backward-compatible with ~169
existing single-stmt / single-decl tests)
- Multiple forms → (list :file FORMS), the canonical Go file shape
Implementation: gp-parse-all loops gp-parse-top until eof, tolerating
ASI semis between forms, then returns based on form count.
End-to-end test set (asserts the top-level decl-tag sequence via a
new decl-tags helper, not the full AST tree — that'd be unwieldy):
- hello-world :package :import :func-decl
- recursive fibonacci :package :func-decl
- FizzBuzz :package :import :func-decl
- goroutine ping-pong :package :func-decl :func-decl
- struct + method :package :type-decl :method-decl :func-decl
- interface + method :package :type-decl :type-decl :method-decl
- defer + select + range :package :func-decl
Type-switch (`switch v := x.(type) { ... }`) is the one syntactic
shape still deferred from Phase 2; doesn't gate Phase 3.
**Phase 2 (parser) is complete.** parse 176/176, total 305/305. Next:
Phase 3 — bidirectional type checker. The sister-plan diary for
static-types-bidirectional already has the :field binding-group
insight; Phase 3 will add the synth/check shape that emerges.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -153,7 +153,7 @@ Progress-log line → push `origin/loops/go`.
|
||||
- **Acceptance:** lex/ suite at 50+ tests. Current: 129/129. **Phase 1
|
||||
done** — hex floats deferred (rare). Move to Phase 2 next.
|
||||
|
||||
### Phase 2 — Parser (`lib/go/parse.sx`) ⬜
|
||||
### Phase 2 — Parser (`lib/go/parse.sx`) ✅
|
||||
- [x] Parser scaffold + Go operator-precedence table (entry shape from
|
||||
`lib/guest/pratt.sx`) + primary expressions (int/float/imag/string/
|
||||
rune/ident → ast-literal / ast-var via `lib/guest/ast.sx`).
|
||||
@@ -203,11 +203,15 @@ Progress-log line → push `origin/loops/go`.
|
||||
bare-recv / default)** all done. Composite-literal `{` suppression
|
||||
active in control-flow conditions. Type-switch (`switch v :=
|
||||
x.(type)`) deferred to a follow-up.
|
||||
- [ ] End-to-end: hello-world, fibonacci, FizzBuzz, goroutine ping-pong,
|
||||
struct + method.
|
||||
- **Acceptance:** parse/ suite at 80+ tests. **Acceptance bar crossed:
|
||||
169/169.** Remaining sub-item (end-to-end programs) keeps Phase 2
|
||||
open ⬜.
|
||||
- [x] End-to-end: hello-world, fibonacci, FizzBuzz, goroutine ping-pong,
|
||||
struct + method, interface, defer+select+range. `go-parse` extended
|
||||
to handle multi-form files: returns the single form for one-form
|
||||
input (backward compat) or `(list :file FORMS)` for multiple.
|
||||
Structural tests assert top-level decl-tag sequences via the
|
||||
`decl-tags` helper rather than full ASTs.
|
||||
- **Acceptance:** parse/ suite at 80+ tests. Current: **176/176**.
|
||||
**Phase 2 complete.** Type-switch is the one syntactic shape still
|
||||
deferred to a follow-up; it doesn't gate Phase 3.
|
||||
|
||||
### Phase 3 — Bidirectional type checker, MVP (`lib/go/types.sx`) ⬜
|
||||
- **Independent implementation.** Do NOT use lib/guest/static-types-
|
||||
@@ -524,6 +528,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 complete.** End-to-end multi-form file parsing.
|
||||
`go-parse` now returns single forms for backward compat (~169 tests
|
||||
unchanged) or `(list :file FORMS)` for multi-form input. Tests cover
|
||||
hello-world, fibonacci, FizzBuzz, goroutine ping-pong, struct+method,
|
||||
interface+method, and defer+select+range — each asserted via top-
|
||||
level `decl-tags`. Type-switch is the one syntactic shape still
|
||||
deferred. +7 tests, parse 176/176, total 305/305. Next: Phase 3
|
||||
(bidirectional type checker). `[nothing]` — pure Go parser
|
||||
composition; the cross-language insights are already in the sister-
|
||||
plan diaries from earlier Phase 2 commits.
|
||||
- 2026-05-27 — Phase 2 cont.: `switch` and `select` statements.
|
||||
Tagged + tagless switch, multi-value cases, `default`, and select
|
||||
with recv-into-var / send / bare-recv / default cases. New
|
||||
|
||||
Reference in New Issue
Block a user