HS: extend parser/runtime + new node test runner; ignore test-results/
- Parser: `--` line comments, `|` op, `result` → `the-result`, query-scoped `<sel> in <expr>`, `is a/an <type>` predicate, multi-`as` chaining with `|`, `match`/`precede` keyword aliases, `[attr]` add/toggle, between attr forms - Runtime: per-element listener registry + hs-deactivate!, attr toggle variants, set-inner-html boots subtree, hs-append polymorphic on string/list/element, default? / array-set! / query-all-in / list-set via take+drop, hs-script idempotence guard - Integration: skip reserved (me/it/event/you/yourself) when collecting vars - Tokenizer: emit `--` comments and `|` op - Test framework + conformance runner updates; new tests/hs-run-filtered.js (single-process Node runner using OCaml VM step-limit to bound infinite loops); generate-sx-conformance-dev.py improvements - mcp_tree.ml + run_tests.ml: harness extensions - .gitignore: top-level test-results/ (Playwright artifacts) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,13 @@
|
||||
(do (adv!) (list kind (str "." val) (list (quote me)))))
|
||||
((= typ "id")
|
||||
(do (adv!) (list kind (str "#" val) (list (quote me)))))
|
||||
((= typ "attr")
|
||||
(do
|
||||
(adv!)
|
||||
(list
|
||||
(quote attr)
|
||||
val
|
||||
(list kind (str "[" val "]") (list (quote me))))))
|
||||
(true (list kind "*" (list (quote me))))))))
|
||||
(define
|
||||
parse-pos-kw
|
||||
@@ -146,8 +153,10 @@
|
||||
(do (adv!) (list (quote me))))
|
||||
((and (= typ "keyword") (= val "I"))
|
||||
(do (adv!) (list (quote me))))
|
||||
((and (= typ "keyword") (or (= val "it") (= val "result")))
|
||||
((and (= typ "keyword") (= val "it"))
|
||||
(do (adv!) (list (quote it))))
|
||||
((and (= typ "keyword") (= val "result"))
|
||||
(do (adv!) (quote the-result)))
|
||||
((and (= typ "keyword") (= val "event"))
|
||||
(do (adv!) (list (quote event))))
|
||||
((and (= typ "keyword") (= val "target"))
|
||||
@@ -174,7 +183,18 @@
|
||||
(do (adv!) (parse-pos-kw (quote last))))
|
||||
((= typ "id")
|
||||
(do (adv!) (list (quote query) (str "#" val))))
|
||||
((= typ "selector") (do (adv!) (list (quote query) val)))
|
||||
((= typ "selector")
|
||||
(do
|
||||
(adv!)
|
||||
(if
|
||||
(and (= (tp-type) "keyword") (= (tp-val) "in"))
|
||||
(do
|
||||
(adv!)
|
||||
(list
|
||||
(quote query-scoped)
|
||||
val
|
||||
(parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||
(list (quote query) val))))
|
||||
((= typ "attr")
|
||||
(do (adv!) (list (quote attr) val (list (quote me)))))
|
||||
((= typ "style")
|
||||
@@ -426,7 +446,7 @@
|
||||
(list (quote type-check) left type-name)))))))
|
||||
(true
|
||||
(let
|
||||
((right (parse-expr)))
|
||||
((right (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||
(if
|
||||
(match-kw "ignoring")
|
||||
(do
|
||||
@@ -892,6 +912,18 @@
|
||||
(let
|
||||
((tgt (if (match-kw "to") (parse-expr) (list (quote me)))))
|
||||
(list (quote set-styles) (reverse pairs) tgt)))))
|
||||
((and (= (tp-type) "bracket-open") (> (len tokens) (+ p 1)) (= (get (nth tokens (+ p 1)) "type") "attr"))
|
||||
(do
|
||||
(adv!)
|
||||
(let
|
||||
((attr-name (get (adv!) "value")))
|
||||
(when (and (= (tp-type) "op") (= (tp-val) "=")) (adv!))
|
||||
(let
|
||||
((attr-val (parse-expr)))
|
||||
(when (= (tp-type) "bracket-close") (adv!))
|
||||
(let
|
||||
((tgt (parse-tgt-kw "to" (list (quote me)))))
|
||||
(list (quote add-attr) attr-name attr-val tgt))))))
|
||||
(true
|
||||
(let
|
||||
((value (parse-expr)))
|
||||
@@ -978,20 +1010,58 @@
|
||||
()
|
||||
(cond
|
||||
((match-kw "between")
|
||||
(if
|
||||
(= (tp-type) "class")
|
||||
(let
|
||||
((cls1 (do (let ((v (tp-val))) (adv!) v))))
|
||||
(expect-kw! "and")
|
||||
(if
|
||||
(= (tp-type) "class")
|
||||
(let
|
||||
((cls2 (do (let ((v (tp-val))) (adv!) v))))
|
||||
(cond
|
||||
((= (tp-type) "class")
|
||||
(let
|
||||
((cls1 (do (let ((v (tp-val))) (adv!) v))))
|
||||
(expect-kw! "and")
|
||||
(if
|
||||
(= (tp-type) "class")
|
||||
(let
|
||||
((tgt (parse-tgt-kw "on" (list (quote me)))))
|
||||
(list (quote toggle-between) cls1 cls2 tgt)))
|
||||
nil))
|
||||
nil))
|
||||
((cls2 (do (let ((v (tp-val))) (adv!) v))))
|
||||
(let
|
||||
((tgt (parse-tgt-kw "on" (list (quote me)))))
|
||||
(list (quote toggle-between) cls1 cls2 tgt)))
|
||||
nil)))
|
||||
((and (= (tp-type) "bracket-open") (> (len tokens) (+ p 1)) (= (get (nth tokens (+ p 1)) "type") "attr"))
|
||||
(do
|
||||
(adv!)
|
||||
(let
|
||||
((n1 (get (adv!) "value")))
|
||||
(when
|
||||
(and (= (tp-type) "op") (= (tp-val) "="))
|
||||
(adv!))
|
||||
(let
|
||||
((v1 (parse-expr)))
|
||||
(when (= (tp-type) "bracket-close") (adv!))
|
||||
(expect-kw! "and")
|
||||
(when (= (tp-type) "bracket-open") (adv!))
|
||||
(let
|
||||
((n2 (get (adv!) "value")))
|
||||
(when
|
||||
(and (= (tp-type) "op") (= (tp-val) "="))
|
||||
(adv!))
|
||||
(let
|
||||
((v2 (parse-expr)))
|
||||
(when (= (tp-type) "bracket-close") (adv!))
|
||||
(let
|
||||
((tgt (parse-tgt-kw "on" (list (quote me)))))
|
||||
(if
|
||||
(= n1 n2)
|
||||
(list
|
||||
(quote toggle-attr-between)
|
||||
n1
|
||||
v1
|
||||
v2
|
||||
tgt)
|
||||
(list
|
||||
(quote toggle-attr-diff)
|
||||
n1
|
||||
v1
|
||||
n2
|
||||
v2
|
||||
tgt)))))))))
|
||||
(true nil)))
|
||||
((= (tp-type) "class")
|
||||
(let
|
||||
((cls (do (let ((v (tp-val))) (adv!) v))))
|
||||
@@ -1064,6 +1134,18 @@
|
||||
val2
|
||||
tgt)))
|
||||
(list (quote toggle-attr) attr-name tgt)))))
|
||||
((and (= (tp-type) "bracket-open") (> (len tokens) (+ p 1)) (= (get (nth tokens (+ p 1)) "type") "attr"))
|
||||
(do
|
||||
(adv!)
|
||||
(let
|
||||
((attr-name (get (adv!) "value")))
|
||||
(when (and (= (tp-type) "op") (= (tp-val) "=")) (adv!))
|
||||
(let
|
||||
((attr-val (parse-expr)))
|
||||
(when (= (tp-type) "bracket-close") (adv!))
|
||||
(let
|
||||
((tgt (parse-tgt-kw "on" (list (quote me)))))
|
||||
(list (quote toggle-attr-val) attr-name attr-val tgt))))))
|
||||
((and (= (tp-type) "keyword") (= (tp-val) "my"))
|
||||
(do
|
||||
(adv!)
|
||||
@@ -1338,19 +1420,23 @@
|
||||
(fn
|
||||
()
|
||||
(let
|
||||
((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr)))))
|
||||
((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr)))))
|
||||
(let
|
||||
((strategy (if (match-kw "with") (if (at-end?) "display" (let ((s (tp-val))) (adv!) s)) "display")))
|
||||
(list (quote hide) tgt strategy)))))
|
||||
(let
|
||||
((when-cond (if (and (= (tp-type) "keyword") (= (tp-val) "when")) (do (adv!) (parse-expr)) nil)))
|
||||
(list (quote hide) tgt strategy when-cond))))))
|
||||
(define
|
||||
parse-show-cmd
|
||||
(fn
|
||||
()
|
||||
(let
|
||||
((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr)))))
|
||||
((tgt (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end") (= (tp-val) "with") (= (tp-val) "when") (= (tp-val) "add") (= (tp-val) "remove") (= (tp-val) "set") (= (tp-val) "put") (= (tp-val) "toggle") (= (tp-val) "hide") (= (tp-val) "show"))) (list (quote me))) (true (parse-expr)))))
|
||||
(let
|
||||
((strategy (if (match-kw "with") (if (at-end?) "display" (let ((s (tp-val))) (adv!) s)) "display")))
|
||||
(list (quote show) tgt strategy)))))
|
||||
(let
|
||||
((when-cond (if (and (= (tp-type) "keyword") (= (tp-val) "when")) (do (adv!) (parse-expr)) nil)))
|
||||
(list (quote show) tgt strategy when-cond))))))
|
||||
(define
|
||||
parse-transition-cmd
|
||||
(fn
|
||||
@@ -1493,7 +1579,7 @@
|
||||
(ca-collect (append acc (list arg)))))))
|
||||
(ca-collect (list))))
|
||||
(define parse-call-cmd (fn () (parse-expr)))
|
||||
(define parse-get-cmd (fn () (parse-expr)))
|
||||
(define parse-get-cmd (fn () (list (quote __get-cmd) (parse-expr))))
|
||||
(define
|
||||
parse-take-cmd
|
||||
(fn
|
||||
@@ -1501,12 +1587,34 @@
|
||||
(cond
|
||||
((= (tp-type) "class")
|
||||
(let
|
||||
((cls (do (let ((v (tp-val))) (adv!) v))))
|
||||
((classes (list)))
|
||||
(let
|
||||
((from-sel (if (match-kw "from") (parse-expr) nil)))
|
||||
((collect (fn () (when (= (tp-type) "class") (let ((v (tp-val))) (adv!) (set! classes (append classes (list v))) (collect))))))
|
||||
(collect)
|
||||
(let
|
||||
((for-tgt (if (match-kw "for") (parse-expr) nil)))
|
||||
(list (quote take!) "class" cls from-sel for-tgt)))))
|
||||
((from-sel (if (match-kw "from") (parse-expr) nil)))
|
||||
(let
|
||||
((for-tgt (if (match-kw "for") (parse-expr) nil)))
|
||||
(if
|
||||
(= (len classes) 1)
|
||||
(list
|
||||
(quote take!)
|
||||
"class"
|
||||
(first classes)
|
||||
from-sel
|
||||
for-tgt)
|
||||
(cons
|
||||
(quote do)
|
||||
(map
|
||||
(fn
|
||||
(cls)
|
||||
(list
|
||||
(quote take!)
|
||||
"class"
|
||||
cls
|
||||
from-sel
|
||||
for-tgt))
|
||||
classes))))))))
|
||||
((= (tp-type) "attr")
|
||||
(let
|
||||
((attr-name (get (adv!) "value")))
|
||||
@@ -1588,7 +1696,7 @@
|
||||
(adv!)
|
||||
(expect-kw! "of")
|
||||
(let
|
||||
((regex (parse-expr)))
|
||||
((regex (parse-atom)))
|
||||
(do
|
||||
(cond
|
||||
((match-kw "of") nil)
|
||||
@@ -1606,7 +1714,7 @@
|
||||
(adv!)
|
||||
(expect-kw! "of")
|
||||
(let
|
||||
((regex (parse-expr)))
|
||||
((regex (parse-atom)))
|
||||
(do
|
||||
(cond
|
||||
((match-kw "of") nil)
|
||||
@@ -1697,7 +1805,7 @@
|
||||
(match-kw "of")
|
||||
(list (make-symbol ".") (parse-expr) val)
|
||||
(cond
|
||||
((= val "result") (list (quote it)))
|
||||
((= val "result") (quote the-result))
|
||||
((= val "first") (parse-pos-kw (quote first)))
|
||||
((= val "last") (parse-pos-kw (quote last)))
|
||||
((= val "closest") (parse-trav (quote closest)))
|
||||
|
||||
Reference in New Issue
Block a user