diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index 524b5b2f..04285b43 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -2351,6 +2351,7 @@ ((= head (quote exit)) nil) ((= head (quote live-no-op)) nil) ((= head (quote when-feat-no-op)) nil) + ((= head (quote bind-feat)) nil) ((= head (quote on)) (emit-on ast)) ((= head (quote when-changes)) (let diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index 62a6434c..0be063cb 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -3100,6 +3100,24 @@ (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 parse-feat (fn @@ -3139,6 +3157,7 @@ ((= val "worker") (error "worker plugin is not installed — see https://hyperscript.org/features/worker")) + ((= val "bind") (do (adv!) (parse-bind-feat))) (true (parse-cmd-list)))))) (define coll-feats diff --git a/lib/hyperscript/tokenizer.sx b/lib/hyperscript/tokenizer.sx index 367a178d..4824b51d 100644 --- a/lib/hyperscript/tokenizer.sx +++ b/lib/hyperscript/tokenizer.sx @@ -209,7 +209,8 @@ "using" "giving" "ask" - "answer")) + "answer" + "bind")) (define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords))) diff --git a/shared/static/wasm/sx/hs-compiler.sx b/shared/static/wasm/sx/hs-compiler.sx index 524b5b2f..04285b43 100644 --- a/shared/static/wasm/sx/hs-compiler.sx +++ b/shared/static/wasm/sx/hs-compiler.sx @@ -2351,6 +2351,7 @@ ((= head (quote exit)) nil) ((= head (quote live-no-op)) nil) ((= head (quote when-feat-no-op)) nil) + ((= head (quote bind-feat)) nil) ((= head (quote on)) (emit-on ast)) ((= head (quote when-changes)) (let diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index 62a6434c..0be063cb 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -3100,6 +3100,24 @@ (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 parse-feat (fn @@ -3139,6 +3157,7 @@ ((= val "worker") (error "worker plugin is not installed — see https://hyperscript.org/features/worker")) + ((= val "bind") (do (adv!) (parse-bind-feat))) (true (parse-cmd-list)))))) (define coll-feats diff --git a/shared/static/wasm/sx/hs-tokenizer.sx b/shared/static/wasm/sx/hs-tokenizer.sx index 367a178d..4824b51d 100644 --- a/shared/static/wasm/sx/hs-tokenizer.sx +++ b/shared/static/wasm/sx/hs-tokenizer.sx @@ -209,7 +209,8 @@ "using" "giving" "ask" - "answer")) + "answer" + "bind")) (define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))