HS: fix compiler AST-unwrap + restore hs-id= dispatch after merge regression
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 16s

Merge c36fd5b2 stripped the source-info dict unwrapping from hs-to-sx
(the (let ((ast (if (and (dict? ast) (:hs-ast)) ...) wrapper) and also
introduced E37 tokenizer whitespace-token changes that broke the parser.

Reverts tokenizer/runtime to pre-E37 HEAD~1 state, restores hs-to-sx
with AST unwrapping from 61c9697f, and adds back the hs-id= dispatch
clause. Baseline: 178/195.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 19:13:02 +00:00
parent cabb0467ab
commit 92adf9d496
7 changed files with 2979 additions and 3521 deletions

View File

@@ -334,17 +334,11 @@
(= ch "r")
(do (append! chars "\r") (hs-advance! 1))
(= ch "b")
(do
(append! chars (char-from-code 8))
(hs-advance! 1))
(do (append! chars (char-from-code 8)) (hs-advance! 1))
(= ch "f")
(do
(append! chars (char-from-code 12))
(hs-advance! 1))
(do (append! chars (char-from-code 12)) (hs-advance! 1))
(= ch "v")
(do
(append! chars (char-from-code 11))
(hs-advance! 1))
(do (append! chars (char-from-code 11)) (hs-advance! 1))
(= ch "\\")
(do (append! chars "\\") (hs-advance! 1))
(= ch quote-char)
@@ -359,16 +353,12 @@
(hs-hex-digit? (hs-peek 1)))
(let
((d1 (hs-hex-val (hs-cur)))
(d2 (hs-hex-val (hs-peek 1))))
(append!
chars
(char-from-code (+ (* d1 16) d2)))
(d2 (hs-hex-val (hs-peek 1))))
(append! chars (char-from-code (+ (* d1 16) d2)))
(hs-advance! 2))
(error "Invalid hexadecimal escape: \\x")))
:else (do
(append! chars "\\")
(append! chars ch)
(hs-advance! 1)))))
:else
(do (append! chars "\\") (append! chars ch) (hs-advance! 1)))))
(loop))
(= (hs-cur) quote-char)
(hs-advance! 1)
@@ -475,13 +465,7 @@
scan!
(fn
()
(do
(let
((ws-start pos))
(skip-ws!)
(when
(and (> (len tokens) 0) (> pos ws-start))
(hs-emit! "whitespace" (slice src ws-start pos) ws-start))))
(skip-ws!)
(when
(< pos src-len)
(let
@@ -505,25 +489,6 @@
(do (hs-emit! "selector" (read-selector) start) (scan!))
(and (= ch ".") (< (+ pos 1) src-len) (= (hs-peek 1) "."))
(do (hs-emit! "op" ".." start) (hs-advance! 2) (scan!))
(and
(= ch ".")
(< (+ pos 1) src-len)
(or
(hs-letter? (hs-peek 1))
(= (hs-peek 1) "-")
(= (hs-peek 1) "_"))
(> (len tokens) 0)
(let
((lt (dict-get (nth tokens (- (len tokens) 1)) :type)))
(or
(= lt "paren-close")
(= lt "brace-close")
(= lt "bracket-close"))))
(do
(hs-emit! "dot" "." start)
(hs-advance! 1)
(hs-emit! "ident" (read-ident pos) start)
(scan!))
(and
(= ch ".")
(< (+ pos 1) src-len)
@@ -535,22 +500,6 @@
(hs-advance! 1)
(hs-emit! "class" (read-class-name pos) start)
(scan!))
(and
(= ch "#")
(< (+ pos 1) src-len)
(hs-ident-start? (hs-peek 1))
(> (len tokens) 0)
(let
((lt (dict-get (nth tokens (- (len tokens) 1)) :type)))
(or
(= lt "paren-close")
(= lt "brace-close")
(= lt "bracket-close"))))
(do
(hs-emit! "op" "#" start)
(hs-advance! 1)
(hs-emit! "ident" (read-ident pos) start)
(scan!))
(and
(= ch "#")
(< (+ pos 1) src-len)
@@ -620,7 +569,21 @@
(let
((word (read-ident start)))
(let
((full-word (if (and (< pos src-len) (= (hs-cur) "'") (< (+ pos 1) src-len) (hs-letter? (hs-peek 1)) (not (and (= (hs-peek 1) "s") (or (>= (+ pos 2) src-len) (not (hs-ident-char? (hs-peek 2))))))) (do (hs-advance! 1) (str word "'" (read-ident pos))) word)))
((full-word
(if
(and
(< pos src-len)
(= (hs-cur) "'")
(< (+ pos 1) src-len)
(hs-letter? (hs-peek 1))
(not
(and
(= (hs-peek 1) "s")
(or
(>= (+ pos 2) src-len)
(not (hs-ident-char? (hs-peek 2)))))))
(do (hs-advance! 1) (str word "'" (read-ident pos)))
word)))
(hs-emit!
(if (hs-keyword? full-word) "keyword" "ident")
full-word