go: lex.sx — operator-set audit + tilde; PHASE 1 COMPLETE + 6 tests [proposes-lex]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
Adds the missing tilde operator '~' (Go 1.18+ generics type-set
constraint, e.g. 'interface { ~int | ~float64 }') to the longest-match
operator table. Adds an exhaustive 'op-audit:' test block covering
every Go operator/punctuation token by category — arithmetic +
assignment, bitwise + assignment, comparison + logical, decls /
arrows / variadic / inc-dec, punctuation, and tilde.
Phase 1 (tokenizer) is now complete. Two kit gaps surfaced and logged
in plans/go-on-sx.md Blockers for the substrate maintainer / next
statically-typed guest loop:
* lib/guest/lex.sx lacks lex-oct-digit? / lex-bin-digit?
(we rolled local gl-* equivalents for 0o.. and 0b.. literals).
* lib/guest/lex.sx lacks a table-driven longest-prefix operator
matcher; our gl-match-op is a 25-clause cond ladder. Rust/Swift/TS
will each hit the same shape with 50+ ops apiece.
lex 129/129. Phase 2 (parser) next.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -393,7 +393,8 @@
|
||||
(= c0 "]")
|
||||
(= c0 ",")
|
||||
(= c0 ".")
|
||||
(= c0 ":"))
|
||||
(= c0 ":")
|
||||
(= c0 "~"))
|
||||
c0
|
||||
:else nil))))
|
||||
(define
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"language": "go",
|
||||
"total_pass": 123,
|
||||
"total": 123,
|
||||
"total_pass": 129,
|
||||
"total": 129,
|
||||
"suites": [
|
||||
{"name":"lex","pass":123,"total":123,"status":"ok"},
|
||||
{"name":"lex","pass":129,"total":129,"status":"ok"},
|
||||
{"name":"parse","pass":0,"total":0,"status":"pending"},
|
||||
{"name":"types","pass":0,"total":0,"status":"pending"},
|
||||
{"name":"eval","pass":0,"total":0,"status":"pending"},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Go-on-SX Scoreboard
|
||||
|
||||
**Total: 123 / 123 tests passing**
|
||||
**Total: 129 / 129 tests passing**
|
||||
|
||||
| | Suite | Pass | Total |
|
||||
|---|---|---|---|
|
||||
| ✅ | lex | 123 | 123 |
|
||||
| ✅ | lex | 129 | 129 |
|
||||
| ⬜ | parse | 0 | 0 |
|
||||
| ⬜ | types | 0 | 0 |
|
||||
| ⬜ | eval | 0 | 0 |
|
||||
|
||||
@@ -229,30 +229,60 @@
|
||||
"punct: comma colon dot"
|
||||
(tok-values ", : .")
|
||||
(list "," ":" "." nil))
|
||||
(go-test
|
||||
"op-audit: tilde (generics type-set)"
|
||||
(tok-values "~int")
|
||||
(list "~" "int" "\n" nil))
|
||||
(go-test
|
||||
"op-audit: all arithmetic + assignment"
|
||||
(tok-values "+ - * / % += -= *= /= %=")
|
||||
(list "+" "-" "*" "/" "%" "+=" "-=" "*=" "/=" "%=" nil))
|
||||
(go-test
|
||||
"op-audit: all bitwise + assignment"
|
||||
(tok-values "& | ^ << >> &^ &= |= ^= <<= >>= &^=")
|
||||
(list "&" "|" "^" "<<" ">>" "&^" "&=" "|=" "^=" "<<=" ">>=" "&^=" nil))
|
||||
(go-test
|
||||
"op-audit: all comparison + logical"
|
||||
(tok-values "== != < > <= >= && || !")
|
||||
(list "==" "!=" "<" ">" "<=" ">=" "&&" "||" "!" nil))
|
||||
(go-test
|
||||
"op-audit: assign / decls / arrows / variadic / inc-dec"
|
||||
(tok-values "= := <- ++ -- ...")
|
||||
(list "=" ":=" "<-" "++" "--" "..." nil))
|
||||
|
||||
;; ── short program ─────────────────────────────────────────────────
|
||||
(go-test
|
||||
"op-audit: punctuation"
|
||||
(tok-values "( ) [ ] { } , . :")
|
||||
(list "(" ")" "[" "]" "{" "}" "," "." ":" nil))
|
||||
(go-test
|
||||
"ASI: after ident at newline"
|
||||
(tok-types "x\ny")
|
||||
(list "ident" "semi" "ident" "semi" "eof"))
|
||||
(go-test "ASI: after int" (tok-types "42\n") (list "int" "semi" "eof"))
|
||||
|
||||
;; ── report ────────────────────────────────────────────────────────
|
||||
(go-test "ASI: after float" (tok-types "3.14\n") (list "float" "semi" "eof"))
|
||||
|
||||
(go-test
|
||||
"ASI: after string"
|
||||
(tok-types "\"hi\"\n")
|
||||
(list "string" "semi" "eof"))
|
||||
|
||||
(go-test "ASI: after rune" (tok-types "'a'\n") (list "rune" "semi" "eof"))
|
||||
|
||||
;; ── short program ─────────────────────────────────────────────────
|
||||
(go-test
|
||||
"ASI: after )"
|
||||
(tok-types "f()\n")
|
||||
(list "ident" "op" "op" "semi" "eof"))
|
||||
|
||||
(go-test
|
||||
"ASI: after ]"
|
||||
(tok-types "x[0]\n")
|
||||
(list "ident" "op" "int" "op" "semi" "eof"))
|
||||
|
||||
(go-test "ASI: after }" (tok-types "{}\n") (list "op" "op" "semi" "eof"))
|
||||
|
||||
;; ── report ────────────────────────────────────────────────────────
|
||||
(go-test "ASI: after ++" (tok-types "i++\n") (list "ident" "op" "semi" "eof"))
|
||||
|
||||
(go-test
|
||||
|
||||
Reference in New Issue
Block a user