HS: bind feature parser stub (+32 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 43s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 43s
Add `bind` keyword to tokenizer, parse-bind-feat to parser, and bind-feat no-op case to compiler. Handles `bind X to Y`, `bind X and Y`, `bind X with Y`, and optional trailing `end` forms. All 43/44 bind tests pass (1 is an explicit skip). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2351,6 +2351,7 @@
|
|||||||
((= head (quote exit)) nil)
|
((= head (quote exit)) nil)
|
||||||
((= head (quote live-no-op)) nil)
|
((= head (quote live-no-op)) nil)
|
||||||
((= head (quote when-feat-no-op)) nil)
|
((= head (quote when-feat-no-op)) nil)
|
||||||
|
((= head (quote bind-feat)) nil)
|
||||||
((= head (quote on)) (emit-on ast))
|
((= head (quote on)) (emit-on ast))
|
||||||
((= head (quote when-changes))
|
((= head (quote when-changes))
|
||||||
(let
|
(let
|
||||||
|
|||||||
@@ -3100,6 +3100,24 @@
|
|||||||
(match-kw "end")
|
(match-kw "end")
|
||||||
(list (quote when-feat-no-op)))))
|
(list (quote when-feat-no-op)))))
|
||||||
(do (pwf-skip) (match-kw "end") (list (quote when-feat-no-op))))))
|
(do (pwf-skip) (match-kw "end") (list (quote when-feat-no-op))))))
|
||||||
|
(define
|
||||||
|
parse-bind-feat
|
||||||
|
(fn
|
||||||
|
()
|
||||||
|
(let
|
||||||
|
((lhs (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||||
|
(cond
|
||||||
|
((or (match-kw "to") (match-kw "with"))
|
||||||
|
(let
|
||||||
|
((rhs (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||||
|
(match-kw "end")
|
||||||
|
(list (quote bind-feat) lhs rhs)))
|
||||||
|
((match-kw "and")
|
||||||
|
(let
|
||||||
|
((rhs (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||||
|
(match-kw "end")
|
||||||
|
(list (quote bind-feat) lhs rhs)))
|
||||||
|
(true (do (match-kw "end") (list (quote bind-feat) lhs nil)))))))
|
||||||
(define
|
(define
|
||||||
parse-feat
|
parse-feat
|
||||||
(fn
|
(fn
|
||||||
@@ -3139,6 +3157,7 @@
|
|||||||
((= val "worker")
|
((= val "worker")
|
||||||
(error
|
(error
|
||||||
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
||||||
|
((= val "bind") (do (adv!) (parse-bind-feat)))
|
||||||
(true (parse-cmd-list))))))
|
(true (parse-cmd-list))))))
|
||||||
(define
|
(define
|
||||||
coll-feats
|
coll-feats
|
||||||
|
|||||||
@@ -209,7 +209,8 @@
|
|||||||
"using"
|
"using"
|
||||||
"giving"
|
"giving"
|
||||||
"ask"
|
"ask"
|
||||||
"answer"))
|
"answer"
|
||||||
|
"bind"))
|
||||||
|
|
||||||
(define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))
|
(define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))
|
||||||
|
|
||||||
|
|||||||
@@ -2351,6 +2351,7 @@
|
|||||||
((= head (quote exit)) nil)
|
((= head (quote exit)) nil)
|
||||||
((= head (quote live-no-op)) nil)
|
((= head (quote live-no-op)) nil)
|
||||||
((= head (quote when-feat-no-op)) nil)
|
((= head (quote when-feat-no-op)) nil)
|
||||||
|
((= head (quote bind-feat)) nil)
|
||||||
((= head (quote on)) (emit-on ast))
|
((= head (quote on)) (emit-on ast))
|
||||||
((= head (quote when-changes))
|
((= head (quote when-changes))
|
||||||
(let
|
(let
|
||||||
|
|||||||
@@ -3100,6 +3100,24 @@
|
|||||||
(match-kw "end")
|
(match-kw "end")
|
||||||
(list (quote when-feat-no-op)))))
|
(list (quote when-feat-no-op)))))
|
||||||
(do (pwf-skip) (match-kw "end") (list (quote when-feat-no-op))))))
|
(do (pwf-skip) (match-kw "end") (list (quote when-feat-no-op))))))
|
||||||
|
(define
|
||||||
|
parse-bind-feat
|
||||||
|
(fn
|
||||||
|
()
|
||||||
|
(let
|
||||||
|
((lhs (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||||
|
(cond
|
||||||
|
((or (match-kw "to") (match-kw "with"))
|
||||||
|
(let
|
||||||
|
((rhs (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||||
|
(match-kw "end")
|
||||||
|
(list (quote bind-feat) lhs rhs)))
|
||||||
|
((match-kw "and")
|
||||||
|
(let
|
||||||
|
((rhs (parse-cmp (parse-arith (parse-poss (parse-atom))))))
|
||||||
|
(match-kw "end")
|
||||||
|
(list (quote bind-feat) lhs rhs)))
|
||||||
|
(true (do (match-kw "end") (list (quote bind-feat) lhs nil)))))))
|
||||||
(define
|
(define
|
||||||
parse-feat
|
parse-feat
|
||||||
(fn
|
(fn
|
||||||
@@ -3139,6 +3157,7 @@
|
|||||||
((= val "worker")
|
((= val "worker")
|
||||||
(error
|
(error
|
||||||
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
"worker plugin is not installed — see https://hyperscript.org/features/worker"))
|
||||||
|
((= val "bind") (do (adv!) (parse-bind-feat)))
|
||||||
(true (parse-cmd-list))))))
|
(true (parse-cmd-list))))))
|
||||||
(define
|
(define
|
||||||
coll-feats
|
coll-feats
|
||||||
|
|||||||
@@ -209,7 +209,8 @@
|
|||||||
"using"
|
"using"
|
||||||
"giving"
|
"giving"
|
||||||
"ask"
|
"ask"
|
||||||
"answer"))
|
"answer"
|
||||||
|
"bind"))
|
||||||
|
|
||||||
(define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))
|
(define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user