haskell: Phase 14 — record creation Foo { f = e, … } (parser + desugar)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m0s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 16:11:23 +00:00
parent b89e321007
commit 9307437679
4 changed files with 137 additions and 40 deletions

View File

@@ -210,7 +210,12 @@
((= (get t "type") "varid")
(do (hk-advance!) (list :var (get t "value"))))
((= (get t "type") "conid")
(do (hk-advance!) (list :con (get t "value"))))
(do
(hk-advance!)
(cond
((hk-match? "lbrace" nil)
(hk-parse-rec-create (get t "value")))
(:else (list :con (get t "value"))))))
((= (get t "type") "qvarid")
(do (hk-advance!) (list :var (get t "value"))))
((= (get t "type") "qconid")
@@ -456,6 +461,34 @@
(do
(hk-expect! "rbracket" nil)
(list :list (list first-e))))))))))
(define
hk-parse-rec-create
(fn
(cname)
(begin
(hk-expect! "lbrace" nil)
(let
((fields (list)))
(define
hk-rc-loop
(fn
()
(when
(hk-match? "varid" nil)
(let
((fname (get (hk-advance!) "value")))
(begin
(hk-expect! "reservedop" "=")
(let
((fexpr (hk-parse-expr-inner)))
(begin
(append! fields (list fname fexpr))
(when
(hk-match? "comma" nil)
(begin (hk-advance!) (hk-rc-loop))))))))))
(hk-rc-loop)
(hk-expect! "rbrace" nil)
(list :rec-create cname fields)))))
(define
hk-parse-fexp
(fn