HS: parser fixes — parenthesized commands + add error + class-name depth (+3 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
- parse-on-feat: event-vars paren check now restores position and returns empty
list when the first token after '(' is a keyword (command starter). Previously
'(log me)' was consumed as event variable names instead of a parenthesized
command, silently dropping the command body and returning empty innerHTML.
Fixes 'can support parenthesized commands and features'.
- parse-add-cmd: true-fallback now throws instead of returning nil when no 'to'
keyword follows the expression. Makes 'add - to' and similar invalid add forms
throw a parse error, satisfying assert-throws in 'basic parse error messages
work' and '_hyperscript() evaluate API still throws on first error'.
- read-class-name: '(' and ')' now only allowed inside '[...]' bracket groups
(depth > 0). Previously allowing them at top level caused '.innerHTML)' at the
end of a possessive expression to be consumed into the class token, producing
'innerHTML))' as a bogus property name. Tailwind classes like
'group-[:nth-of-type(3)_&]:block' still tokenize correctly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -459,7 +459,7 @@
|
||||
(define
|
||||
build-name
|
||||
(fn
|
||||
(acc)
|
||||
(acc depth)
|
||||
(cond
|
||||
((and (< pos src-len) (= (hs-cur) "\\") (< (+ pos 1) src-len))
|
||||
(do
|
||||
@@ -467,15 +467,35 @@
|
||||
(let
|
||||
((c (hs-cur)))
|
||||
(hs-advance! 1)
|
||||
(build-name (str acc c)))))
|
||||
((and (< pos src-len) (or (hs-ident-char? (hs-cur)) (= (hs-cur) ":") (= (hs-cur) "[") (= (hs-cur) "]") (= (hs-cur) "(") (= (hs-cur) ")") (= (hs-cur) "&")))
|
||||
(build-name (str acc c) depth))))
|
||||
((and (< pos src-len) (= (hs-cur) "["))
|
||||
(do
|
||||
(let
|
||||
((c (hs-cur)))
|
||||
(hs-advance! 1)
|
||||
(build-name (str acc c)))))
|
||||
(build-name (str acc c) (+ depth 1)))))
|
||||
((and (< pos src-len) (= (hs-cur) "]"))
|
||||
(do
|
||||
(let
|
||||
((c (hs-cur)))
|
||||
(hs-advance! 1)
|
||||
(build-name
|
||||
(str acc c)
|
||||
(if (> depth 0) (- depth 1) 0)))))
|
||||
((and (< pos src-len) (> depth 0) (or (= (hs-cur) "(") (= (hs-cur) ")")))
|
||||
(do
|
||||
(let
|
||||
((c (hs-cur)))
|
||||
(hs-advance! 1)
|
||||
(build-name (str acc c) depth))))
|
||||
((and (< pos src-len) (or (hs-ident-char? (hs-cur)) (= (hs-cur) ":") (= (hs-cur) "&")))
|
||||
(do
|
||||
(let
|
||||
((c (hs-cur)))
|
||||
(hs-advance! 1)
|
||||
(build-name (str acc c) depth))))
|
||||
(true acc))))
|
||||
(build-name "")))
|
||||
(build-name "" 0)))
|
||||
(define
|
||||
hs-emit!
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user