(scons-define nested
(apply scons-lambda bvl body-forms))))))
system-global-environment))
-
-(define (parse-define-form form rename)
- (cond ((syntax-match? '((datum . mit-bvl) + form) (cdr form))
- (parse-define-form
- `(,(car form) ,(caadr form)
- ,(if (identifier? (caadr form))
- `(,(rename 'NAMED-LAMBDA) ,@(cdr form))
- `(,(rename 'LAMBDA) ,(cdadr form) ,@(cddr form))))
- rename))
- ((syntax-match? '(identifier ? expression) (cdr form))
- (values (cadr form)
- (if (pair? (cddr form))
- (caddr form)
- (unassigned-expression))))
- (else
- (ill-formed-syntax form))))
\f
(define :let
(spar-transformer->runtime
(receive :receive)
(unless :unless)
(when :when)
- get-supported-features)
- (export (runtime)
- parse-define-form))
+ get-supported-features))
(define-package (runtime syntax syntax-rules)
(files "syntax-rules")
(er-macro-transformer
(lambda (form rename compare)
(declare (ignore compare))
- (receive (name value)
- (parse-define-form form rename)
- `(,(rename 'BEGIN)
- (,(rename 'DEFINE) ,name)
- (,(rename 'ADD-BOOT-INIT!)
- (,(rename 'LAMBDA) ()
- (,(rename 'SET!) ,name ,value)
- ,(rename 'UNSPECIFIC))))))))
+ (syntax-check '(_ identifier expression) form)
+ (let ((name (cadr form))
+ (value (caddr form)))
+ `(,(rename 'begin)
+ (,(rename 'define) ,name)
+ (,(rename 'add-boot-init!)
+ (,(rename 'lambda) ()
+ (,(rename 'set!) ,name ,value)
+ ,(rename 'unspecific))))))))
(define-syntax select-on-bytes-per-word
(er-macro-transformer
|#
(let ((environment (make-top-level-environment)))
- (environment-link-name environment '(runtime mit-macros) 'parse-define-form)
(load (merge-pathnames "unit-testing" (current-load-pathname))
environment)
(for-each (lambda (name)
(define-syntax define-for-tests
(er-macro-transformer
(lambda (form rename compare)
- compare
- (receive (name value)
- (parse-define-form form rename)
- `(,(rename 'BEGIN)
- (,(rename 'DEFINE) ,name ,value)
- (,(rename 'ADD-TEST-DEFINITION) ',name ,name))))))
+ (declare (ignore compare))
+ (let ((name
+ (let loop ((p (cadr form)))
+ (cond ((pair? p) (loop (car p)))
+ ((identifier? p) p)
+ (else (ill-formed-syntax form))))))
+ `(,(rename 'begin)
+ (,(rename 'define) ,@(cdr form))
+ (,(rename 'add-test-definition) ',name ,name))))))
(define (add-test-definition name value)
(let ((p (assq name test-definitions)))