js-on-sx: parser handles comma operator (a, b, c)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s

Was failing with "Expected punct ')' got punct ','" because the
paren handler only consumed a single assignment. Added
jp-parse-comma-seq helpers that build a js-comma AST node with
the expression list; transpiler emits (begin ...) so each is
evaluated in order and the last value is returned.
built-ins/Object: 44/50 → 46/50. conformance.sh: 148/148.
This commit is contained in:
2026-05-08 13:20:53 +00:00
parent b7627b4102
commit 4ab79f5758
5 changed files with 48 additions and 28 deletions

View File

@@ -418,17 +418,43 @@
(dict-set! st :idx saved)
(jp-advance! st)
(let
((e (jp-parse-assignment st)))
((e (jp-parse-comma-seq st)))
(jp-expect! st "punct" ")")
e)))
(do
(dict-set! st :idx saved)
(jp-advance! st)
(let
((e (jp-parse-assignment st)))
((e (jp-parse-comma-seq st)))
(jp-expect! st "punct" ")")
e)))))))
(define
jp-parse-comma-seq
(fn
(st)
(let
((first-expr (jp-parse-assignment st)))
(if
(jp-at? st "punct" ",")
(jp-parse-comma-seq-rest st (list first-expr))
first-expr))))
(define
jp-parse-comma-seq-rest
(fn
(st acc)
(do
(jp-advance! st)
(let
((next-expr (jp-parse-assignment st)))
(let
((acc2 (append acc (list next-expr))))
(if
(jp-at? st "punct" ",")
(jp-parse-comma-seq-rest st acc2)
(cons (quote js-comma) (list acc2))))))))
(define
jp-collect-params
(fn