1
0
forked from alex-eg/sex

index a unit past its first bad form

Record plain declarations, with location and docstring, and keep going
when one toplevel form is wrong. sexc --check and --symbols print
that. Specs, realizations, and closure helpers stay out of the index
for future rework (@alex-eg).
This commit is contained in:
2026-11-11 07:38:33 +03:00
parent 5e842c4df6
commit 7bbb8e19ac
10 changed files with 876 additions and 50 deletions

View File

@@ -16,7 +16,8 @@
apply-macro
defmacro
macro-definition
restore-macro!)
restore-macro!
reset-macros!)
(define (cat-syms s-1 s-2)
(fmt #f s-1 s-2))
@@ -30,7 +31,15 @@
(define (comment . _)
(void))
;;; Every name given a macro, so a later unit can take them all off.
(define +macro-names+ (list))
(define (note-macro-name! name)
(unless (memq name +macro-names+)
(set! +macro-names+ (cons name +macro-names+))))
(define (register-macro name arglist body)
(note-macro-name! name)
(put! name 'sex-macro
`(lambda ,arglist
;; A macro body is ordinary Scheme, evaluated at compile
@@ -96,9 +105,14 @@
(define (restore-macro! name definition)
(if definition
(put! name 'sex-macro definition)
(begin (note-macro-name! name)
(put! name 'sex-macro definition))
(remprop! name 'sex-macro)))
(define (reset-macros!)
(for-each (lambda (name) (remprop! name 'sex-macro)) +macro-names+)
(set! +macro-names+ (list)))
(define (defmacro form)
(let ((arglist (car form))
(body (cdr form)))