haskell: Phase 14 — record syntax in parser (con-rec AST node)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m1s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 15:07:38 +00:00
parent 2adbc101fa
commit ca9e12fc57
2 changed files with 49 additions and 11 deletions

View File

@@ -1212,16 +1212,47 @@
(not (hk-match? "conid" nil))
(hk-err "expected constructor name"))
(let
((name (get (hk-advance!) "value")) (fields (list)))
(define
hk-cd-loop
(fn
()
(when
(hk-atype-start? (hk-peek))
(do (append! fields (hk-parse-atype)) (hk-cd-loop)))))
(hk-cd-loop)
(list :con-def name fields))))
((name (get (hk-advance!) "value")))
(cond
((hk-match? "lbrace" nil)
(begin
(hk-advance!)
(let
((rec-fields (list)))
(define
hk-rec-loop
(fn
()
(when
(hk-match? "varid" nil)
(let
((fname (get (hk-advance!) "value")))
(begin
(hk-expect! "reservedop" "::")
(let
((ftype (hk-parse-type)))
(begin
(append! rec-fields (list fname ftype))
(when
(hk-match? "comma" nil)
(begin (hk-advance!) (hk-rec-loop))))))))))
(hk-rec-loop)
(hk-expect! "rbrace" nil)
(list :con-rec name rec-fields))))
(:else
(let
((fields (list)))
(define
hk-cd-loop
(fn
()
(when
(hk-atype-start? (hk-peek))
(begin
(append! fields (hk-parse-atype))
(hk-cd-loop)))))
(hk-cd-loop)
(list :con-def name fields)))))))
(define
hk-parse-tvars
(fn