aboutsummaryrefslogtreecommitdiffstats
path: root/csc/macros.csc
diff options
context:
space:
mode:
Diffstat (limited to 'csc/macros.csc')
-rw-r--r--csc/macros.csc22
1 files changed, 21 insertions, 1 deletions
diff --git a/csc/macros.csc b/csc/macros.csc
index 288865d..4559991 100644
--- a/csc/macros.csc
+++ b/csc/macros.csc
@@ -32,6 +32,7 @@
library-ref-name
library-ref?
make-call
+ make-call-builtin
make-constant
make-define-syntax
make-lambda
@@ -748,6 +749,24 @@
(_ (raise-syntax-error "unexpected form in builtin-define-syntax" x))))))
+ (define builtin-call-builtin
+ (make-macro-transformer
+ (lambda (x)
+ (syntax-case x
+ ((_ op . args) when (identifier? op)
+ (make-call-builtin (identifier-name op)
+ (let loop ((args args)
+ (expanded-args '()))
+ (syntax-case args
+ ('() (reverse expanded-args))
+ ((head . tail)
+ (loop tail
+ (cons (expand-syntax-object head)
+ expanded-args)))
+ (_ (raise-syntax-error "unexpected form in call-builtin"))))))
+ (_ (raise-syntax-error "unexpected form in call-builtin" x))))))
+
+
(define builtins-environment
(alist->substitutions
(list (cons 'syntax-rules builtin-syntax-rules)
@@ -757,7 +776,8 @@
(cons 'quote builtin-quote)
(cons 'lambda builtin-lambda)
(cons 'builtin-define builtin-define)
- (cons 'define-syntax builtin-define-syntax))))
+ (cons 'define-syntax builtin-define-syntax)
+ (cons 'call-builtin builtin-call-builtin))))
; Expands the body of a library, or top level. expand-body can be thought