Parser: put at start/end of, take for — 309/941 (33%)

- put parser: added 'at start of' and 'at end of' positional syntax
- take parser: added 'for' as alternative to 'from' for target clause
- runtime: hs-put! handles "start" (afterbegin) and "end" (beforeend)
- eval-hs: smart wrapping for commands vs expressions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 16:19:46 +00:00
parent 1461919857
commit e85de7d5cc
4 changed files with 24 additions and 6 deletions

View File

@@ -730,8 +730,13 @@
(list (quote put!) value "before" (parse-expr)))
((match-kw "after")
(list (quote put!) value "after" (parse-expr)))
((match-kw "at")
(cond
((match-kw "start") (do (expect-kw! "of") (list (quote put!) value "start" (parse-expr))))
((match-kw "end") (do (expect-kw! "of") (list (quote put!) value "end" (parse-expr))))
(true (error (str "Expected start/end after at, position " p)))))
(true
(error (str "Expected into/before/after at position " p)))))))
(error (str "Expected into/before/after/at at position " p)))))))
(define
parse-if-cmd
(fn
@@ -919,7 +924,9 @@
(let
((cls (get (adv!) "value")))
(let
((tgt (parse-tgt-kw "from" (list (quote me)))))
((tgt (if (match-kw "for")
(parse-expr)
(parse-tgt-kw "from" (list (quote me))))))
(list (quote take) cls tgt)))
nil)))
(define

View File

@@ -88,7 +88,9 @@
((= pos "into") (dom-set-inner-html target value))
((= pos "before")
(dom-insert-adjacent-html target "beforebegin" value))
((= pos "after") (dom-insert-adjacent-html target "afterend" value)))))
((= pos "after") (dom-insert-adjacent-html target "afterend" value))
((= pos "start") (dom-insert-adjacent-html target "afterbegin" value))
((= pos "end") (dom-insert-adjacent-html target "beforeend" value)))))
;; ── Navigation / traversal ──────────────────────────────────────