HS: parenthesized commands and features (+1 test)
Three parser additions so scripts like `(on click (log me) (trigger foo))` parse into a single feature with both commands in its body: 1. parse-feat: new cond branch for `paren-open` — advance, recurse parse-feat, consume `paren-close`. Allows a feature like `(on click ...)` to be grouped in parens. 2. parse-cmd: two new cond branches — on `paren-close` return nil (so cl-collect terminates at an outer group close), and on `paren-open` advance / recurse / close. Allows single parenthesized commands like `(log me)`. 3. cl-collect: previously only recursed when the next token was a recognised command keyword (`cmd-kw?`), so after `(log me)` the sibling `(trigger foo)` would end the feature body and re-surface as a top-level feature. Extended the recursion predicate to also fire when the next token is `paren-open`. Suite hs-upstream-core/parser: 9/14 -> 10/14. Smoke 0-195: 165/195 -> 166/195.
This commit is contained in:
@@ -2347,6 +2347,14 @@
|
||||
(let
|
||||
((typ (tp-type)) (val (tp-val)))
|
||||
(cond
|
||||
((= typ "paren-close") nil)
|
||||
((= typ "paren-open")
|
||||
(do
|
||||
(adv!)
|
||||
(let
|
||||
((inner (parse-cmd)))
|
||||
(if (= (tp-type) "paren-close") (adv!) nil)
|
||||
inner)))
|
||||
((and (= typ "keyword") (or (= val "catch") (= val "finally") (= val "end") (= val "else") (= val "otherwise")))
|
||||
nil)
|
||||
((and (= typ "keyword") (= val "add"))
|
||||
@@ -2519,7 +2527,7 @@
|
||||
(list (quote if) (list (quote no) cnd) cmd))))))
|
||||
((match-kw "then")
|
||||
(cl-collect (append acc2 (list (quote __then__)))))
|
||||
((and (not (at-end?)) (= (tp-type) "keyword") (cmd-kw? (tp-val)))
|
||||
((or (and (not (at-end?)) (= (tp-type) "keyword") (cmd-kw? (tp-val))) (= (tp-type) "paren-open"))
|
||||
(cl-collect acc2))
|
||||
(true acc2)))))))
|
||||
(let
|
||||
@@ -2655,6 +2663,13 @@
|
||||
(let
|
||||
((val (tp-val)))
|
||||
(cond
|
||||
((= (tp-type) "paren-open")
|
||||
(do
|
||||
(adv!)
|
||||
(let
|
||||
((inner (parse-feat)))
|
||||
(if (= (tp-type) "paren-close") (adv!) nil)
|
||||
inner)))
|
||||
((= val "on") (do (adv!) (parse-on-feat)))
|
||||
((= val "init") (do (adv!) (parse-init-feat)))
|
||||
((= val "def") (do (adv!) (parse-def-feat)))
|
||||
|
||||
Reference in New Issue
Block a user