implement define-macro in scheme

This commit is contained in:
Yuichi Nishiwaki 2014-07-20 11:11:39 +09:00
parent b901188aa0
commit 240c5d9ac4
1 changed files with 16 additions and 1 deletions

View File

@ -124,10 +124,25 @@
(rename sym)))
(f (walk inject expr) inject compare))))
(define-syntax define-macro
(er-macro-transformer
(lambda (expr r c)
(define formal (car (cdr expr)))
(define body (cdr (cdr expr)))
(if (symbol? formal)
(list (r 'define-syntax) formal
(list (r 'lambda) (list (r 'form) '_ '_)
(list (r 'apply) (car body) (list (r 'cdr) (r 'form)))))
(list (r 'define-macro) (car formal)
(cons (r 'lambda)
(cons (cdr formal)
body)))))))
(export make-syntactic-closure
close-syntax
capture-syntactic-environment
sc-macro-transformer
rsc-macro-transformer
er-macro-transformer
ir-macro-transformer))
ir-macro-transformer
define-macro))