go: lex.sx — decimal float + imaginary literals + 22 tests [consumes-lex]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
Adds Go float and imaginary literal forms per Go spec § Floating-point literals and § Imaginary literals: 3.14 .5 1. 1e10 1.5e-3 2.0e+2 1E5 (floats) 2i 3.14i 1e2i (imag) gl-read-number! returns one of "int" / "float" / "imag"; gl-finish-number! factors out the post-mantissa exponent + 'i' suffix logic so the int / float / leading-dot-float paths all share it. scan! adds a .<digit> branch ahead of the operator matcher so '.5' tokenises as float. ASI trigger list extended to include float + imag (Go spec § Semicolons: all literal types trigger). Greedy-grammar pin (a single test '1.method' lexes as float ident), since the Go spec says the '.' after a digit always belongs to the number, never to a following identifier. Hex floats (0x1.fp0) deferred — not commonly used. lex 114/114. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -141,12 +141,13 @@ Progress-log line → push `origin/loops/go`.
|
||||
- [x] **Automatic semicolon insertion** (Go spec § Semicolons) — newline,
|
||||
EOF, and block-comment-with-newline trigger `;` after
|
||||
ident/int/string/rune/{break,continue,fallthrough,return}/{++,--,),],}}.
|
||||
- [ ] Float / imaginary literals
|
||||
- [x] Float / imaginary literals (decimal floats: `3.14 .5 1. 1e10 1.5e-3`;
|
||||
imag: `2i 3.14i 1e2i`; hex floats `0x1.fp0` deferred)
|
||||
- [ ] Raw string literals `` `...` ``
|
||||
- [x] Hex/octal/binary integer literals (0x… 0o… 0b…) + underscores
|
||||
(legacy 0123 octal also accepted; consumes lex-hex-digit?)
|
||||
- [ ] Full operator set audit (47 distinct per Go spec)
|
||||
- **Acceptance:** lex/ suite at 50+ tests. Current: 92/92.
|
||||
- **Acceptance:** lex/ suite at 50+ tests. Current: 114/114.
|
||||
|
||||
### Phase 2 — Parser (`lib/go/parse.sx`) ⬜
|
||||
- Consume `lib/guest/core/pratt.sx` + `lib/guest/core/ast.sx`. Chisel notes
|
||||
@@ -405,6 +406,12 @@ _(none yet)_
|
||||
|
||||
_Newest first. Append one dated entry per commit._
|
||||
|
||||
- 2026-05-27 — Phase 1 cont.: decimal float + imaginary literals.
|
||||
`3.14`, `.5`, `1.`, `1e10`, `1.5e-3`, `2i`, `3.14i`. `gl-finish-number!`
|
||||
handles exponent + `i` suffix; `gl-read-number!` returns the type
|
||||
string (int/float/imag). ASI trigger list extended to float/imag.
|
||||
Greedy-grammar pin: `1.method` lexes as `float ident`. Hex floats
|
||||
(`0x1.fp0`) deferred. +22 tests, lex 114/114. `[consumes-lex]`.
|
||||
- 2026-05-27 — Phase 1 cont.: prefixed integer literals (`0x..`, `0X..`,
|
||||
`0b..`, `0B..`, `0o..`, `0O..`, legacy `0123`) + underscore separators
|
||||
in any digit run. Dispatch in `gl-read-number!`; consumes
|
||||
|
||||
Reference in New Issue
Block a user