rewrite er-macro-transformer in scheme

This commit is contained in:
Yuichi Nishiwaki 2014-07-17 11:32:41 +09:00
parent 5d9242f5b5
commit 73a6eaf9da
1 changed files with 22 additions and 0 deletions

View File

@ -92,6 +92,28 @@
(dictionary-set! cache atom id)
id)))))))
(define (er-macro-transformer f)
(lambda (expr use-env mac-env)
(define cache (make-dictionary))
(define (rename sym)
(if (dictionary-has? cache sym)
(dictionary-ref cache sym)
(begin
(define id (make-identifier sym mac-env))
(dictionary-set! cache sym id)
id)))
(define (compare sym1 sym2)
(if (symbol? sym1)
(if (symbol? sym2)
(identifier=? use-env sym1 use-env sym2)
#f)
#f))
(f expr rename compare)))
(define (sc-macro-transformer f)
(lambda (expr use-env mac-env)
(make-syntactic-closure mac-env '() (f expr use-env))))