go: parse.sx — unary prefix operators + 11 tests [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Adds Go unary prefix operators per Go spec § Operators: +x -x !x ^x *p &v <-ch gp-parse-unary is recursive (so !!x and -^x chain correctly) and sits between gp-parse-expr and gp-parse-primary — unary therefore always binds tighter than any binary op without needing a unary entry in the precedence table. Symbols +, -, *, &, ^ are shared between unary and binary forms; the positional split (expression-start sees unary, mid-expression sees binary) disambiguates them cleanly with no lookback. Unary nodes are single-arg ast-app: (ast-app (ast-var OP) (list OPERAND)) parse 37/37, total 166/166. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -160,7 +160,9 @@ Progress-log line → push `origin/loops/go`.
|
||||
- [x] Binary operators (Pratt precedence climbing using `pratt-op-lookup`
|
||||
+ Go precedence table). Operator app emitted as
|
||||
`(ast-app (ast-var OP) [LHS RHS])`; left-assoc raises right-min by 1.
|
||||
- [ ] Unary operators (`!x`, `-x`, `^x`, `*p`, `&v`, `<-ch`).
|
||||
- [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`.
|
||||
- [ ] Index `x[i]` and slice `x[a:b]`/`x[a:b:c]`.
|
||||
- [ ] Type assertion `v.(T)`.
|
||||
@@ -176,7 +178,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: 26/26.
|
||||
- **Acceptance:** parse/ suite at 80+ tests. Current: 37/37.
|
||||
|
||||
### Phase 3 — Bidirectional type checker, MVP (`lib/go/types.sx`) ⬜
|
||||
- **Independent implementation.** Do NOT use lib/guest/static-types-
|
||||
@@ -435,6 +437,13 @@ 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.: unary prefix operators (`+`, `-`, `!`, `^`,
|
||||
`*`, `&`, `<-`). `gp-parse-unary` is recursive (`!!x`) and sits between
|
||||
`gp-parse-expr` and `gp-parse-primary` so unary always binds tighter
|
||||
than any binary. Symbols `+ - * & ^` are shared with binary; the
|
||||
positional split (expression-start vs mid-expression) disambiguates
|
||||
cleanly without lookback. Unary nodes are single-arg `ast-app`. +11
|
||||
tests, parse 37/37, total 166/166. `[nothing]` — pure Go parser work.
|
||||
- 2026-05-27 — Phase 2 cont.: binary operators via Pratt precedence
|
||||
climbing. `gp-pratt-loop` consumes `pratt-op-lookup` against
|
||||
`go-precedence-table`; left-assoc bumps right-min by 1, right-assoc
|
||||
|
||||
Reference in New Issue
Block a user