HS: fix empty/halt/morph/reset/dialog — 17 upstream tests pass
- parser `empty` no-target → (ref "me") (was bogus (sym "me")) - parser `halt` modes distinguish: "all"/"bubbling"/"default" halt execution (raise hs-return), "the-event"/"the event's" only stop propagation/default. "'s" now matched as op token, not keyword. - parser `get` cmd: dispatch + cmd-kw list + parse-get-cmd (parses expr with optional `as TYPE`). Required for `get result as JSON` in fetch chains. - compiler empty-target for (local X): emit (set! X (hs-empty-like X)) so arrays/sets/maps clear the variable, not call DOM empty on the value. - runtime hs-empty-like: container-of-same-type empty value. - runtime hs-empty-target!: drop dead FORM branch that was short-circuiting to innerHTML=""; the querySelectorAll-over-inputs branch now runs. - runtime hs-halt!: take ev param (was free `event` lookup); raise hs-return to stop execution unless mode is "the-event". - runtime hs-reset!: type-aware — FORM → reset, INPUT/TEXTAREA → value/checked from defaults, SELECT → defaultSelected option. - runtime hs-open!/hs-close!: toggle `open` attribute on details elements (not just the prop) so dom-has-attr? assertions work. - runtime hs-coerce JSON: json-stringify dict/list (was str). - test-runner mock: host-get on List + "length"/"size" (was only Dict); dom-set-attr tracks defaultChecked / defaultSelected / defaultValue; mock_query_all supports comma-separated selector groups. - generator: emit boolean attrs (checked/selected/etc) even with null value; drop overcautious "skip HS with bare quotes or embedded HTML" guard so morph tests (source contains embedded <div>) emit properly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,14 +23,48 @@
|
||||
((th (first target)))
|
||||
(cond
|
||||
((= th dot-sym)
|
||||
(list
|
||||
(quote dom-set-prop)
|
||||
(hs-to-sx (nth target 1))
|
||||
(nth target 2)
|
||||
value))
|
||||
(let
|
||||
((base-ast (nth target 1)) (prop (nth target 2)))
|
||||
(cond
|
||||
((and (list? base-ast) (= (first base-ast) (quote query)) (let ((s (nth base-ast 1))) (and (string? s) (> (len s) 0) (= (substring s 0 1) "."))))
|
||||
(list
|
||||
(quote for-each)
|
||||
(list
|
||||
(quote fn)
|
||||
(list (quote __hs-el))
|
||||
(list
|
||||
(quote dom-set-prop)
|
||||
(quote __hs-el)
|
||||
prop
|
||||
value))
|
||||
(list (quote hs-query-all) (nth base-ast 1))))
|
||||
((and (list? base-ast) (= (first base-ast) dot-sym) (let ((inner (nth base-ast 1))) (and (list? inner) (= (first inner) (quote query)) (let ((s (nth inner 1))) (and (string? s) (> (len s) 0) (= (substring s 0 1) "."))))))
|
||||
(let
|
||||
((inner (nth base-ast 1))
|
||||
(mid-prop (nth base-ast 2)))
|
||||
(list
|
||||
(quote for-each)
|
||||
(list
|
||||
(quote fn)
|
||||
(list (quote __hs-el))
|
||||
(list
|
||||
(quote dom-set-prop)
|
||||
(list
|
||||
(quote host-get)
|
||||
(quote __hs-el)
|
||||
mid-prop)
|
||||
prop
|
||||
value))
|
||||
(list (quote hs-query-all) (nth inner 1)))))
|
||||
(true
|
||||
(list
|
||||
(quote dom-set-prop)
|
||||
(hs-to-sx base-ast)
|
||||
prop
|
||||
value)))))
|
||||
((= th (quote attr))
|
||||
(list
|
||||
(quote dom-set-attr)
|
||||
(quote hs-set-attr!)
|
||||
(hs-to-sx (nth target 2))
|
||||
(nth target 1)
|
||||
value))
|
||||
@@ -44,6 +78,12 @@
|
||||
(list (quote set!) (make-symbol (nth target 1)) value))
|
||||
((= th (quote local))
|
||||
(list (quote define) (make-symbol (nth target 1)) value))
|
||||
((= th (quote dom-ref))
|
||||
(list
|
||||
(quote hs-dom-set!)
|
||||
(hs-to-sx (nth target 2))
|
||||
(nth target 1)
|
||||
value))
|
||||
((= th (quote me))
|
||||
(list (quote dom-set-inner-html) (quote me) value))
|
||||
((= th (quote it)) (list (quote set!) (quote it) value))
|
||||
@@ -55,6 +95,8 @@
|
||||
(hs-to-sx (nth target 1))
|
||||
(hs-to-sx (nth target 2))
|
||||
value))
|
||||
((or (= th (quote next)) (= th (quote previous)) (= th (quote closest)))
|
||||
(list (quote dom-set-inner-html) (hs-to-sx target) value))
|
||||
((= th (quote of))
|
||||
(let
|
||||
((prop-ast (nth target 1)) (obj-ast (nth target 2)))
|
||||
@@ -76,7 +118,7 @@
|
||||
(list? prop-ast)
|
||||
(= (first prop-ast) (quote attr)))
|
||||
(list
|
||||
(quote dom-set-attr)
|
||||
(quote hs-set-attr!)
|
||||
(hs-to-sx obj-ast)
|
||||
(nth prop-ast 1)
|
||||
value)
|
||||
@@ -247,7 +289,14 @@
|
||||
(ast)
|
||||
(let
|
||||
((var-name (nth ast 1))
|
||||
(collection (hs-to-sx (nth ast 2)))
|
||||
(raw-coll (hs-to-sx (nth ast 2)))
|
||||
(collection
|
||||
(if
|
||||
(symbol? raw-coll)
|
||||
(list
|
||||
(quote hs-safe-call)
|
||||
(list (quote fn) (list) raw-coll))
|
||||
raw-coll))
|
||||
(body (hs-to-sx (nth ast 3))))
|
||||
(if
|
||||
(and (> (len ast) 4) (= (nth ast 4) :index))
|
||||
@@ -308,48 +357,120 @@
|
||||
(cond
|
||||
((and (list? expr) (= (first expr) (quote attr)))
|
||||
(let
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me))))
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
|
||||
(attr-name (nth expr 1)))
|
||||
(list
|
||||
(quote dom-set-attr)
|
||||
el
|
||||
(nth expr 1)
|
||||
(quote let)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote parse-number)
|
||||
(list (quote dom-get-attr) el (nth expr 1)))
|
||||
amount))))
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote dom-get-attr) el attr-name))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote dom-set-attr) el attr-name (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) dot-sym))
|
||||
(let
|
||||
((obj (hs-to-sx (nth expr 1))) (prop (nth expr 2)))
|
||||
(list
|
||||
(quote host-set!)
|
||||
obj
|
||||
prop
|
||||
(quote let)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote parse-number)
|
||||
(list (quote host-get) obj prop))
|
||||
amount))))
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote host-get) obj prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote host-set!) obj prop (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) (quote style)))
|
||||
(let
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
|
||||
(prop (nth expr 1)))
|
||||
(list
|
||||
(quote dom-set-style)
|
||||
el
|
||||
prop
|
||||
(quote let)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote parse-number)
|
||||
(list (quote dom-get-style) el prop))
|
||||
amount))))
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote dom-get-style) el prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote dom-set-style) el prop (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) (quote dom-ref)))
|
||||
(let
|
||||
((el (hs-to-sx (nth expr 2))) (name (nth expr 1)))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote hs-dom-get) el name))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote hs-dom-set!) el name (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) (quote array-index)) (list? (nth expr 1)) (= (first (nth expr 1)) (quote ref)))
|
||||
(let
|
||||
((var-sym (make-symbol (nth (nth expr 1) 1)))
|
||||
(idx (hs-to-sx (nth expr 2))))
|
||||
(list
|
||||
(quote let)
|
||||
(list (list (quote __hs-idx) idx))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote +)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote nth) var-sym (quote __hs-idx)))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list
|
||||
(quote set!)
|
||||
var-sym
|
||||
(list
|
||||
(quote hs-list-set)
|
||||
var-sym
|
||||
(quote __hs-idx)
|
||||
(quote __hs-new)))
|
||||
(list (quote set!) (quote it) (quote __hs-new)))))))
|
||||
(true
|
||||
(let
|
||||
((t (hs-to-sx expr)))
|
||||
(list (quote set!) t (list (quote +) t amount)))))))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list (quote +) (list (quote hs-to-number) t) amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote set!) t (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new)))))))))
|
||||
(define
|
||||
emit-dec
|
||||
(fn
|
||||
@@ -357,48 +478,120 @@
|
||||
(cond
|
||||
((and (list? expr) (= (first expr) (quote attr)))
|
||||
(let
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me))))
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
|
||||
(attr-name (nth expr 1)))
|
||||
(list
|
||||
(quote dom-set-attr)
|
||||
el
|
||||
(nth expr 1)
|
||||
(quote let)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote parse-number)
|
||||
(list (quote dom-get-attr) el (nth expr 1)))
|
||||
amount))))
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote dom-get-attr) el attr-name))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote dom-set-attr) el attr-name (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) dot-sym))
|
||||
(let
|
||||
((obj (hs-to-sx (nth expr 1))) (prop (nth expr 2)))
|
||||
(list
|
||||
(quote host-set!)
|
||||
obj
|
||||
prop
|
||||
(quote let)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote parse-number)
|
||||
(list (quote host-get) obj prop))
|
||||
amount))))
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote host-get) obj prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote host-set!) obj prop (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) (quote style)))
|
||||
(let
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
|
||||
(prop (nth expr 1)))
|
||||
(list
|
||||
(quote dom-set-style)
|
||||
el
|
||||
prop
|
||||
(quote let)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote parse-number)
|
||||
(list (quote dom-get-style) el prop))
|
||||
amount))))
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote dom-get-style) el prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote dom-set-style) el prop (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) (quote dom-ref)))
|
||||
(let
|
||||
((el (hs-to-sx (nth expr 2))) (name (nth expr 1)))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote hs-dom-get) el name))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote hs-dom-set!) el name (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))
|
||||
((and (list? expr) (= (first expr) (quote array-index)) (list? (nth expr 1)) (= (first (nth expr 1)) (quote ref)))
|
||||
(let
|
||||
((var-sym (make-symbol (nth (nth expr 1) 1)))
|
||||
(idx (hs-to-sx (nth expr 2))))
|
||||
(list
|
||||
(quote let)
|
||||
(list (list (quote __hs-idx) idx))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote -)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote nth) var-sym (quote __hs-idx)))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list
|
||||
(quote set!)
|
||||
var-sym
|
||||
(list
|
||||
(quote hs-list-set)
|
||||
var-sym
|
||||
(quote __hs-idx)
|
||||
(quote __hs-new)))
|
||||
(list (quote set!) (quote it) (quote __hs-new)))))))
|
||||
(true
|
||||
(let
|
||||
((t (hs-to-sx expr)))
|
||||
(list (quote set!) t (list (quote -) t amount)))))))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list (quote -) (list (quote hs-to-number) t) amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote set!) t (quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new)))))))))
|
||||
(define
|
||||
emit-behavior
|
||||
(fn
|
||||
@@ -427,7 +620,7 @@
|
||||
((= head (quote null-literal)) nil)
|
||||
((= head (quote not))
|
||||
(list (quote not) (hs-to-sx (nth ast 1))))
|
||||
((or (= head (quote starts-with?)) (= head (quote ends-with?)) (= head (quote contains?)) (= head (quote precedes?)) (= head (quote follows?)) (= head (quote exists?)))
|
||||
((or (= head (quote and)) (= head (quote or)) (= head (quote >=)) (= head (quote <=)) (= head (quote >)) (= head (quote <)))
|
||||
(cons head (map hs-to-sx (rest ast))))
|
||||
((= head (quote object-literal))
|
||||
(let
|
||||
@@ -559,6 +752,37 @@
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))
|
||||
(hs-to-sx (nth ast 3))))
|
||||
((= head (quote pick-first))
|
||||
(list
|
||||
(quote hs-pick-first)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote pick-last))
|
||||
(list
|
||||
(quote hs-pick-last)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote pick-random))
|
||||
(list
|
||||
(quote hs-pick-random)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(if (nil? (nth ast 2)) nil (hs-to-sx (nth ast 2)))))
|
||||
((= head (quote pick-items))
|
||||
(list
|
||||
(quote hs-pick-items)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))
|
||||
(hs-to-sx (nth ast 3))))
|
||||
((= head (quote pick-match))
|
||||
(list
|
||||
(quote regex-match)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote pick-matches))
|
||||
(list
|
||||
(quote regex-find-all)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote prop-is))
|
||||
(list
|
||||
(quote hs-prop-is)
|
||||
@@ -656,6 +880,11 @@
|
||||
(quote dom-get-style)
|
||||
(hs-to-sx (nth ast 2))
|
||||
(nth ast 1)))
|
||||
((= head (quote dom-ref))
|
||||
(list
|
||||
(quote hs-dom-get)
|
||||
(hs-to-sx (nth ast 2))
|
||||
(nth ast 1)))
|
||||
((= head (quote has-class?))
|
||||
(list
|
||||
(quote dom-has-class?)
|
||||
@@ -742,6 +971,26 @@
|
||||
(quote hs-ends-with-ic?)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote starts-with?))
|
||||
(list
|
||||
(quote hs-starts-with?)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote ends-with?))
|
||||
(list
|
||||
(quote hs-ends-with?)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote precedes?))
|
||||
(list
|
||||
(quote hs-precedes?)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote follows?))
|
||||
(list
|
||||
(quote hs-follows?)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote contains?))
|
||||
(list
|
||||
(quote hs-contains?)
|
||||
@@ -922,7 +1171,15 @@
|
||||
(hs-to-sx tgt)
|
||||
(list (quote hs-remove-from!) val (hs-to-sx tgt)))))
|
||||
((= head (quote empty-target))
|
||||
(list (quote hs-empty-target!) (hs-to-sx (nth ast 1))))
|
||||
(let
|
||||
((tgt (nth ast 1)))
|
||||
(if
|
||||
(and (list? tgt) (= (first tgt) (quote local)))
|
||||
(list
|
||||
(quote set!)
|
||||
(make-symbol (nth tgt 1))
|
||||
(list (quote hs-empty-like) (make-symbol (nth tgt 1))))
|
||||
(list (quote hs-empty-target!) (hs-to-sx tgt)))))
|
||||
((= head (quote open-element))
|
||||
(list (quote hs-open!) (hs-to-sx (nth ast 1))))
|
||||
((= head (quote close-element))
|
||||
@@ -937,6 +1194,11 @@
|
||||
(quote do)
|
||||
(emit-set lhs (hs-to-sx rhs))
|
||||
(emit-set rhs (quote _swap_tmp))))))
|
||||
((= head (quote morph!))
|
||||
(list
|
||||
(quote hs-morph!)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote remove-attr))
|
||||
(let
|
||||
((tgt (if (nil? (nth ast 2)) (quote me) (hs-to-sx (nth ast 2)))))
|
||||
@@ -977,6 +1239,23 @@
|
||||
(quote hs-set-on!)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(hs-to-sx (nth ast 2))))
|
||||
((= head (quote set-on!))
|
||||
(let
|
||||
((lhs (nth ast 1))
|
||||
(tgt-ast (nth ast 2))
|
||||
(val-ast (nth ast 3)))
|
||||
(if
|
||||
(and (list? lhs) (= (first lhs) (quote dom-ref)))
|
||||
(list
|
||||
(quote hs-dom-set!)
|
||||
(hs-to-sx tgt-ast)
|
||||
(nth lhs 1)
|
||||
(hs-to-sx val-ast))
|
||||
(list
|
||||
(quote hs-set-on!)
|
||||
(hs-to-sx lhs)
|
||||
(hs-to-sx tgt-ast)
|
||||
(hs-to-sx val-ast)))))
|
||||
((= head (quote toggle-between))
|
||||
(list
|
||||
(quote hs-toggle-between!)
|
||||
@@ -1051,6 +1330,9 @@
|
||||
(or
|
||||
(= (first c) (quote hs-fetch))
|
||||
(= (first c) (quote hs-wait))
|
||||
(= (first c) (quote hs-wait-for))
|
||||
(= (first c) (quote hs-query-first))
|
||||
(= (first c) (quote hs-query-all))
|
||||
(= (first c) (quote perform)))))
|
||||
compiled))
|
||||
(reduce
|
||||
@@ -1061,7 +1343,7 @@
|
||||
(list (list (quote it) cmd))
|
||||
body))
|
||||
(nth compiled (- (len compiled) 1))
|
||||
(reverse (rest (reverse compiled))))
|
||||
(rest (reverse compiled)))
|
||||
(cons (quote do) compiled))))
|
||||
((= head (quote wait)) (list (quote hs-wait) (nth ast 1)))
|
||||
((= head (quote wait-for)) (emit-wait-for ast))
|
||||
@@ -1194,20 +1476,39 @@
|
||||
((= head (quote measure))
|
||||
(list (quote hs-measure) (hs-to-sx (nth ast 1))))
|
||||
((= head (quote increment!))
|
||||
(emit-inc
|
||||
(nth ast 1)
|
||||
(nth ast 2)
|
||||
(if (> (len ast) 3) (nth ast 3) nil)))
|
||||
(if
|
||||
(= (len ast) 3)
|
||||
(emit-inc (nth ast 1) 1 (nth ast 2))
|
||||
(emit-inc
|
||||
(nth ast 1)
|
||||
(nth ast 2)
|
||||
(if (> (len ast) 3) (nth ast 3) nil))))
|
||||
((= head (quote decrement!))
|
||||
(emit-dec
|
||||
(nth ast 1)
|
||||
(nth ast 2)
|
||||
(if (> (len ast) 3) (nth ast 3) nil)))
|
||||
(if
|
||||
(= (len ast) 3)
|
||||
(emit-dec (nth ast 1) 1 (nth ast 2))
|
||||
(emit-dec
|
||||
(nth ast 1)
|
||||
(nth ast 2)
|
||||
(if (> (len ast) 3) (nth ast 3) nil))))
|
||||
((= head (quote break)) (list (quote raise) "hs-break"))
|
||||
((= head (quote continue))
|
||||
(list (quote raise) "hs-continue"))
|
||||
((= head (quote exit)) nil)
|
||||
((= head (quote live-no-op)) nil)
|
||||
((= head (quote when-feat-no-op)) nil)
|
||||
((= head (quote on)) (emit-on ast))
|
||||
((= head (quote when-changes))
|
||||
(let
|
||||
((expr (nth ast 1)) (body (nth ast 2)))
|
||||
(if
|
||||
(and (list? expr) (= (first expr) (quote dom-ref)))
|
||||
(list
|
||||
(quote hs-dom-watch!)
|
||||
(hs-to-sx (nth expr 2))
|
||||
(nth expr 1)
|
||||
(list (quote fn) (list (quote it)) (hs-to-sx body)))
|
||||
nil)))
|
||||
((= head (quote init))
|
||||
(list
|
||||
(quote hs-init)
|
||||
@@ -1352,7 +1653,14 @@
|
||||
(quote when)
|
||||
(list (quote nil?) t)
|
||||
(list (quote set!) t v))))
|
||||
((= head (quote halt!)) (list (quote hs-halt!) (nth ast 1)))
|
||||
((= head (quote hs-is))
|
||||
(list
|
||||
(quote hs-is)
|
||||
(hs-to-sx (nth ast 1))
|
||||
(list (quote fn) (list) (hs-to-sx (nth (nth ast 2) 2)))
|
||||
(nth ast 3)))
|
||||
((= head (quote halt!))
|
||||
(list (quote hs-halt!) (quote event) (nth ast 1)))
|
||||
((= head (quote focus!))
|
||||
(list (quote dom-focus) (hs-to-sx (nth ast 1))))
|
||||
(true ast))))))))
|
||||
|
||||
Reference in New Issue
Block a user