From 73a6eaf9da5c54f8fd3af3d973f90ef67c660c30 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 17 Jul 2014 11:32:41 +0900 Subject: [PATCH] rewrite er-macro-transformer in scheme --- piclib/built-in.scm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 5b220ca9..764b282c 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -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))))