process imported forms as toplevel, not as text

1. register imported types
2. protect against multiple imports (diamond, circular)
This commit is contained in:
2026-09-16 01:11:53 +03:00
parent 85bf1c163c
commit d0d0ea8e84
5 changed files with 32 additions and 13 deletions

View File

@@ -93,17 +93,9 @@
(else (sex-error sex-form "unknown top level form" sex-form))))
(define (process-imports module-public-forms acc)
;; Recursively process imports: register public macros, cons all
;; other public things to our acc
(if (null? module-public-forms) acc
(match (car module-public-forms)
(('defmacro . rest)
(defmacro rest)
(process-imports (cdr module-public-forms) acc))
(else
(process-imports (cdr module-public-forms)
(cons (car module-public-forms)
acc))))))
;; consume (import ...) form and process imports so
;; data types end up in types db
(fold match-sex-form acc module-public-forms))
(define (macro-expand form)
"Walk the form recursively and expand all macros, until none is left."