haskell: Phase 14 — record update r { field = v } (parser + desugar + eval)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m6s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 16:43:20 +00:00
parent 9307437679
commit 76d141737a
4 changed files with 94 additions and 2 deletions

View File

@@ -208,7 +208,12 @@
((= (get t "type") "char")
(do (hk-advance!) (list :char (get t "value"))))
((= (get t "type") "varid")
(do (hk-advance!) (list :var (get t "value"))))
(do
(hk-advance!)
(cond
((hk-match? "lbrace" nil)
(hk-parse-rec-update (list :var (get t "value"))))
(:else (list :var (get t "value"))))))
((= (get t "type") "conid")
(do
(hk-advance!)
@@ -489,6 +494,34 @@
(hk-rc-loop)
(hk-expect! "rbrace" nil)
(list :rec-create cname fields)))))
(define
hk-parse-rec-update
(fn
(rec-expr)
(begin
(hk-expect! "lbrace" nil)
(let
((fields (list)))
(define
hk-ru-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-ru-loop))))))))))
(hk-ru-loop)
(hk-expect! "rbrace" nil)
(list :rec-update rec-expr fields)))))
(define
hk-parse-fexp
(fn