Hyperscript: focus command, diagnostic test output, blur keyword

Parser/compiler/runtime for focus command. Tokenizer: focus, blur,
precedes, follows, ignoring, case keywords. Test spec: per-test
failure output for diagnosis.

374/831 (45%)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 12:38:05 +00:00
parent 1783f4805a
commit f60d22e86e
12 changed files with 277 additions and 190 deletions

View File

@@ -1061,6 +1061,8 @@
(list (quote nil?) t)
(list (quote set!) t v))))
((= head (quote halt!)) (list (quote hs-halt!) (nth ast 1)))
((= head (quote focus!))
(list (quote dom-focus) (hs-to-sx (nth ast 1))))
(true ast))))))))
;; ── Convenience: source → SX ─────────────────────────────────

View File

@@ -1266,6 +1266,13 @@
(define
parse-param-list
(fn () (if (= (tp-type) "paren-open") (parse-call-args) (list))))
(define
parse-focus-cmd
(fn
()
(let
((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end"))) (list (quote me))) (true (parse-expr)))))
(list (quote focus!) tgt))))
(define
parse-feat-body
(fn
@@ -1452,6 +1459,8 @@
(do (adv!) (parse-default-cmd)))
((and (= typ "keyword") (= val "halt"))
(do (adv!) (parse-halt-cmd)))
((and (= typ "keyword") (= val "focus"))
(do (adv!) (parse-focus-cmd)))
(true (parse-expr))))))
(define
parse-cmd-list
@@ -1496,7 +1505,8 @@
(= v "default")
(= v "scroll")
(= v "select")
(= v "reset"))))
(= v "reset")
(= v "focus"))))
(define
cl-collect
(fn

View File

@@ -170,7 +170,9 @@
"precedes"
"follows"
"ignoring"
"case"))
"case"
"focus"
"blur"))
(define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))