go: parse.sx — switch + select + 8 tests; stmts done [shapes-scheduler]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Adds Go's switch and select statements:
switch TAG { case V1, V2: a; case V3: b; default: c }
switch { case cond: ... } — tagless
select { case x := <-ch: a; case ch <- v: b; default: c }
AST shapes:
(list :switch TAG CASES) — TAG nil for tagless
(list :case VALUES BODY) — VALUES is expr-list
(list :select CASES)
(list :select-case COMM-STMT BODY) — COMM-STMT is send/recv-assign/bare-recv
(list :default BODY)
gp-parse-case-body reads stmts until the next case/default/}/eof
without consuming the terminator — used by both switch and select.
select-case parsing reuses gp-parse-stmt for the comm-stmt, so all
four shapes (send, x := <-ch, x = <-ch, bare <-ch) fall out from the
existing stmt parser. Composite-lit suppression is engaged for the
switch tag expression.
Type-switch (`switch v := x.(type) { case int: ... }`) is the one
deferred shape; needs the `.(type)` pseudo-syntax recognised in the
expression layer. Phase 2 statement coverage is otherwise complete.
This is also a chiselling iteration for scheduler sister kit. Diary
updated with select-case design insights:
* All four select-case shapes share (list :select-case STMT BODY)
— kit primitive sched-select accepts a uniform list of cases.
* Default vs no-default determines blocking semantics. Erlang's
`receive ... after Timeout -> ...` is the analogue — both fit
"non-blocking fallback case" in the kit API.
parse 169/169, total 298/298.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -231,6 +231,24 @@ real result.
|
||||
|
||||
_Newest first. Append one dated entry per milestone landed._
|
||||
|
||||
- 2026-05-27 — Follow-up from same Phase 2 work: **`select` AST shape**
|
||||
landed. Each case is `(list :select-case COMM-STMT BODY)` where
|
||||
COMM-STMT is one of `:send`, `:short-decl` (recv into new var),
|
||||
`:assign` (recv into existing var), or a bare receive expression
|
||||
`(:app (:var "<-") [chan])`. The shape is uniform across all four
|
||||
comm-stmt kinds — the kit's `sched-select` primitive should accept a
|
||||
list of cases each described by `(direction chan value-target?)` and
|
||||
let the kit's runtime pick a ready case. That uniformity is what
|
||||
makes a single kit primitive cover all four Go case shapes.
|
||||
|
||||
Also: Go's `select` with `default` makes the multiplexer non-blocking;
|
||||
without default it blocks until a case is ready. The kit primitive
|
||||
should mirror this — present-or-absent default determines blocking
|
||||
semantics. Erlang's `receive ... after Timeout -> ...` is a similar
|
||||
pattern with a timeout case rather than default; the kit primitive
|
||||
should handle both as instances of "non-blocking-fallback case."
|
||||
Source: Go-on-SX commit `parse.sx — switch + select`.
|
||||
|
||||
- 2026-05-27 — From Go-on-SX Phase 2 (parser side, ahead of scheduler
|
||||
implementation): the **parsed AST shapes** for Go's concurrency
|
||||
primitives have landed and are worth recording before Phase 5 builds
|
||||
|
||||
Reference in New Issue
Block a user