HS: contains/matches ignoring case support — 425→426
- Parser: contains/matches with ignoring case modifier - Compiler: contains-ignore-case? → hs-contains-ignore-case? - Compiler: matches-ignore-case? → hs-matches-ignore-case? - Runtime: downcase-based case-insensitive contains/matches Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -688,11 +688,21 @@
|
|||||||
(quote hs-matches?)
|
(quote hs-matches?)
|
||||||
(hs-to-sx (nth ast 1))
|
(hs-to-sx (nth ast 1))
|
||||||
(hs-to-sx (nth ast 2))))
|
(hs-to-sx (nth ast 2))))
|
||||||
|
((= head (quote matches-ignore-case?))
|
||||||
|
(list
|
||||||
|
(quote hs-matches-ignore-case?)
|
||||||
|
(hs-to-sx (nth ast 1))
|
||||||
|
(hs-to-sx (nth ast 2))))
|
||||||
((= head (quote contains?))
|
((= head (quote contains?))
|
||||||
(list
|
(list
|
||||||
(quote hs-contains?)
|
(quote hs-contains?)
|
||||||
(hs-to-sx (nth ast 1))
|
(hs-to-sx (nth ast 1))
|
||||||
(hs-to-sx (nth ast 2))))
|
(hs-to-sx (nth ast 2))))
|
||||||
|
((= head (quote contains-ignore-case?))
|
||||||
|
(list
|
||||||
|
(quote hs-contains-ignore-case?)
|
||||||
|
(hs-to-sx (nth ast 1))
|
||||||
|
(hs-to-sx (nth ast 2))))
|
||||||
((= head (quote as))
|
((= head (quote as))
|
||||||
(list (quote hs-coerce) (hs-to-sx (nth ast 1)) (nth ast 2)))
|
(list (quote hs-coerce) (hs-to-sx (nth ast 1)) (nth ast 2)))
|
||||||
((= head (quote in?))
|
((= head (quote in?))
|
||||||
|
|||||||
@@ -520,9 +520,27 @@
|
|||||||
(match-kw "with")
|
(match-kw "with")
|
||||||
(list (quote ends-with?) left (parse-expr))))
|
(list (quote ends-with?) left (parse-expr))))
|
||||||
((and (= typ "keyword") (= val "matches"))
|
((and (= typ "keyword") (= val "matches"))
|
||||||
(do (adv!) (list (quote matches?) left (parse-expr))))
|
(do
|
||||||
|
(adv!)
|
||||||
|
(let
|
||||||
|
((right (parse-expr)))
|
||||||
|
(if
|
||||||
|
(match-kw "ignoring")
|
||||||
|
(do
|
||||||
|
(match-kw "case")
|
||||||
|
(list (quote matches-ignore-case?) left right))
|
||||||
|
(list (quote matches?) left right)))))
|
||||||
((and (= typ "keyword") (= val "contains"))
|
((and (= typ "keyword") (= val "contains"))
|
||||||
(do (adv!) (list (quote contains?) left (parse-expr))))
|
(do
|
||||||
|
(adv!)
|
||||||
|
(let
|
||||||
|
((right (parse-expr)))
|
||||||
|
(if
|
||||||
|
(match-kw "ignoring")
|
||||||
|
(do
|
||||||
|
(match-kw "case")
|
||||||
|
(list (quote contains-ignore-case?) left right))
|
||||||
|
(list (quote contains?) left right)))))
|
||||||
((and (= typ "keyword") (= val "as"))
|
((and (= typ "keyword") (= val "as"))
|
||||||
(do
|
(do
|
||||||
(adv!)
|
(adv!)
|
||||||
|
|||||||
@@ -392,6 +392,12 @@
|
|||||||
hs-eq-ignore-case
|
hs-eq-ignore-case
|
||||||
(fn (a b) (= (downcase (str a)) (downcase (str b)))))
|
(fn (a b) (= (downcase (str a)) (downcase (str b)))))
|
||||||
;; DOM query stub — sandbox returns empty list
|
;; DOM query stub — sandbox returns empty list
|
||||||
|
(define
|
||||||
|
hs-contains-ignore-case?
|
||||||
|
(fn
|
||||||
|
(haystack needle)
|
||||||
|
(contains? (downcase (str haystack)) (downcase (str needle)))))
|
||||||
|
;; Method dispatch — obj.method(args)
|
||||||
(define
|
(define
|
||||||
hs-falsy?
|
hs-falsy?
|
||||||
(fn
|
(fn
|
||||||
@@ -403,7 +409,9 @@
|
|||||||
((and (list? v) (= (len v) 0)) true)
|
((and (list? v) (= (len v) 0)) true)
|
||||||
((= v 0) true)
|
((= v 0) true)
|
||||||
(true false))))
|
(true false))))
|
||||||
;; Method dispatch — obj.method(args)
|
|
||||||
|
;; ── 0.9.90 features ─────────────────────────────────────────────
|
||||||
|
;; beep! — debug logging, returns value unchanged
|
||||||
(define
|
(define
|
||||||
hs-matches?
|
hs-matches?
|
||||||
(fn
|
(fn
|
||||||
@@ -412,9 +420,7 @@
|
|||||||
(string? target)
|
(string? target)
|
||||||
(if (= pattern ".*") true (string-contains? target pattern))
|
(if (= pattern ".*") true (string-contains? target pattern))
|
||||||
false)))
|
false)))
|
||||||
|
;; Property-based is — check obj.key truthiness
|
||||||
;; ── 0.9.90 features ─────────────────────────────────────────────
|
|
||||||
;; beep! — debug logging, returns value unchanged
|
|
||||||
(define
|
(define
|
||||||
hs-contains?
|
hs-contains?
|
||||||
(fn
|
(fn
|
||||||
@@ -434,9 +440,9 @@
|
|||||||
true
|
true
|
||||||
(hs-contains? (rest collection) item)))))
|
(hs-contains? (rest collection) item)))))
|
||||||
(true false))))
|
(true false))))
|
||||||
;; Property-based is — check obj.key truthiness
|
|
||||||
(define precedes? (fn (a b) (< (str a) (str b))))
|
|
||||||
;; Array slicing (inclusive both ends)
|
;; Array slicing (inclusive both ends)
|
||||||
|
(define precedes? (fn (a b) (< (str a) (str b))))
|
||||||
|
;; Collection: sorted by
|
||||||
(define
|
(define
|
||||||
hs-empty?
|
hs-empty?
|
||||||
(fn
|
(fn
|
||||||
@@ -447,7 +453,7 @@
|
|||||||
((list? v) (= (len v) 0))
|
((list? v) (= (len v) 0))
|
||||||
((dict? v) (= (len (keys v)) 0))
|
((dict? v) (= (len (keys v)) 0))
|
||||||
(true false))))
|
(true false))))
|
||||||
;; Collection: sorted by
|
;; Collection: sorted by descending
|
||||||
(define
|
(define
|
||||||
hs-empty-target!
|
hs-empty-target!
|
||||||
(fn
|
(fn
|
||||||
@@ -468,11 +474,11 @@
|
|||||||
(dom-set-prop target "value" ""))))
|
(dom-set-prop target "value" ""))))
|
||||||
((= tag "FORM") (dom-set-inner-html target ""))
|
((= tag "FORM") (dom-set-inner-html target ""))
|
||||||
(true (dom-set-inner-html target ""))))))))
|
(true (dom-set-inner-html target ""))))))))
|
||||||
;; Collection: sorted by descending
|
|
||||||
(define hs-first (fn (lst) (first lst)))
|
|
||||||
;; Collection: split by
|
;; Collection: split by
|
||||||
(define hs-last (fn (lst) (last lst)))
|
(define hs-first (fn (lst) (first lst)))
|
||||||
;; Collection: joined by
|
;; Collection: joined by
|
||||||
|
(define hs-last (fn (lst) (last lst)))
|
||||||
|
|
||||||
(define
|
(define
|
||||||
hs-template
|
hs-template
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -520,9 +520,27 @@
|
|||||||
(match-kw "with")
|
(match-kw "with")
|
||||||
(list (quote ends-with?) left (parse-expr))))
|
(list (quote ends-with?) left (parse-expr))))
|
||||||
((and (= typ "keyword") (= val "matches"))
|
((and (= typ "keyword") (= val "matches"))
|
||||||
(do (adv!) (list (quote matches?) left (parse-expr))))
|
(do
|
||||||
|
(adv!)
|
||||||
|
(let
|
||||||
|
((right (parse-expr)))
|
||||||
|
(if
|
||||||
|
(match-kw "ignoring")
|
||||||
|
(do
|
||||||
|
(match-kw "case")
|
||||||
|
(list (quote matches-ignore-case?) left right))
|
||||||
|
(list (quote matches?) left right)))))
|
||||||
((and (= typ "keyword") (= val "contains"))
|
((and (= typ "keyword") (= val "contains"))
|
||||||
(do (adv!) (list (quote contains?) left (parse-expr))))
|
(do
|
||||||
|
(adv!)
|
||||||
|
(let
|
||||||
|
((right (parse-expr)))
|
||||||
|
(if
|
||||||
|
(match-kw "ignoring")
|
||||||
|
(do
|
||||||
|
(match-kw "case")
|
||||||
|
(list (quote contains-ignore-case?) left right))
|
||||||
|
(list (quote contains?) left right)))))
|
||||||
((and (= typ "keyword") (= val "as"))
|
((and (= typ "keyword") (= val "as"))
|
||||||
(do
|
(do
|
||||||
(adv!)
|
(adv!)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user