Parser: skip unit suffix when next ident is a comparison keyword (starts, ends, contains, matches, is, does, in, precedes, follows). Fixes "123 starts with '12'" returning "123starts" instead of true. eval-hs: use hs-compile directly instead of hs-to-sx-from-source with "return " prefix, which was causing the parser to consume the comparison as a string suffix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
(define spec-form-params
|
|
(fn
|
|
(form)
|
|
(if
|
|
(< (len form) 2)
|
|
(list)
|
|
(let
|
|
((body (nth form (- (len form) 1))))
|
|
(if
|
|
(and
|
|
(list? body)
|
|
(> (len body) 1)
|
|
(= (type-of (first body)) "symbol")
|
|
(or
|
|
(= (symbol-name (first body)) "fn")
|
|
(= (symbol-name (first body)) "lambda")))
|
|
(let
|
|
((raw-params (nth body 1)))
|
|
(if
|
|
(list? raw-params)
|
|
(map
|
|
(fn
|
|
(p)
|
|
(cond
|
|
(= (type-of p) "symbol")
|
|
{:type nil :name (symbol-name p)}
|
|
(and
|
|
(list? p)
|
|
(>= (len p) 3)
|
|
(= (type-of (first p)) "symbol"))
|
|
{:type (if (and (>= (len p) 3) (= (type-of (nth p 2)) "symbol")) (symbol-name (nth p 2)) nil) :name (symbol-name (first p))}
|
|
:else {:type nil :name (str p)}))
|
|
raw-params)
|
|
(list)))
|
|
(list))))))
|