;;;; Macro transformers
(define (transformer-keyword name transformer->expander)
- (lambda (form environment definition-environment)
- definition-environment ;ignore
+ (lambda (form environment)
(syntax-check '(KEYWORD EXPRESSION) form)
(let ((item (classify/expression (cadr form) environment)))
(make-keyword-value-item
bvl)))
(values bvl
(compile-body-item
- (classify/body body
- environment
- environment))))))
+ (classify/body body environment))))))
-(define (classifier:begin form environment definition-environment)
+(define (classifier:begin form environment)
(syntax-check '(KEYWORD * FORM) form)
- (classify/body (cdr form) environment definition-environment))
+ (classify/body (cdr form) environment))
(define (compiler:if form environment)
(syntax-check '(KEYWORD EXPRESSION EXPRESSION ? EXPRESSION) form)
(define keyword:define
(classifier->keyword
- (lambda (form environment definition-environment)
- (classify/define form environment definition-environment
- variable-binding-theory))))
+ (lambda (form environment)
+ (classify/define form environment variable-binding-theory))))
-(define (classifier:define-syntax form environment definition-environment)
+(define (classifier:define-syntax form environment)
(syntax-check '(KEYWORD IDENTIFIER EXPRESSION) form)
- (classify/define form environment definition-environment
- syntactic-binding-theory))
+ (classify/define form environment syntactic-binding-theory))
-(define (classify/define form environment definition-environment
- binding-theory)
- (if (not (syntactic-environment/top-level? definition-environment))
- (syntactic-environment/define definition-environment
+(define (classify/define form environment binding-theory)
+ (if (not (syntactic-environment/top-level? environment))
+ (syntactic-environment/define environment
(cadr form)
(make-reserved-name-item)))
- (binding-theory definition-environment
+ (binding-theory environment
(cadr form)
(classify/expression (caddr form) environment)))
(define keyword:let
(classifier->keyword
- (lambda (form environment definition-environment)
- definition-environment
+ (lambda (form environment)
(let* ((binding-environment
(make-internal-syntactic-environment environment))
(body-environment
output/let)))))
\f
-(define (classifier:let-syntax form environment definition-environment)
- definition-environment
+(define (classifier:let-syntax form environment)
(syntax-check '(KEYWORD (* (IDENTIFIER EXPRESSION)) + FORM) form)
(let* ((binding-environment
(make-internal-syntactic-environment environment))
(define keyword:let-syntax
(classifier->keyword classifier:let-syntax))
-(define (classifier:letrec-syntax form environment definition-environment)
- definition-environment
+(define (classifier:letrec-syntax form environment)
(syntax-check '(KEYWORD (* (IDENTIFIER EXPRESSION)) + FORM) form)
(let* ((binding-environment
(make-internal-syntactic-environment environment))
(classify/expression (cadr binding)
value-environment))
(cadr form)))))
- (body
- (classify/body (cddr form)
- body-environment
- body-environment)))
+ (body (classify/body (cddr form) body-environment)))
(if (eq? binding-theory syntactic-binding-theory)
body
(make-expression-item
(define keyword:access
(classifier->keyword
- (lambda (form environment definition-environment)
- definition-environment
+ (lambda (form environment)
(make-access-item (cadr form)
(classify/expression (caddr form) environment)))))
\f
;;;; Declarations
-(define (classifier:declare form environment definition-environment)
- definition-environment
+(define (classifier:declare form environment)
(syntax-check '(KEYWORD * (IDENTIFIER * DATUM)) form)
(make-declaration-item
(lambda ()
(declare (usual-integrations))
\f
-(define (classify/form form environment definition-environment)
+(define (classify/form form environment)
(cond ((identifier? form)
(let ((item (lookup-identifier form environment)))
(if (keyword-item? item)
(classify/form form
(make-partial-syntactic-environment free-names
environment
- closing-env)
- definition-environment)))
+ closing-env))))
((pair? form)
(let ((item
(strip-keyword-value-item
(classify/expression (car form) environment))))
(cond ((classifier-item? item)
- ((classifier-item/classifier item) form
- environment
- definition-environment))
+ ((classifier-item/classifier item) form environment))
((compiler-item? item)
(make-expression-item
(let ((compiler (compiler-item/compiler item)))
((expander-item? item)
(classify/form ((expander-item/expander item) form
environment)
- environment
- definition-environment))
+ environment))
(else
(if (not (list? (cdr form)))
(syntax-error "Combination must be a proper list:" form))
(keyword-value-item/item item)
item))
\f
-(define (classify/forms forms environment definition-environment)
+(define (classify/forms forms environment)
(map (lambda (form)
- (classify/form form environment definition-environment))
+ (classify/form form environment))
forms))
(define (classify/expression expression environment)
- (classify/form expression environment null-syntactic-environment))
+ (classify/form expression environment))
(define (classify/expressions expressions environment)
- (classify/forms expressions environment null-syntactic-environment))
+ (classify/forms expressions environment))
-(define (classify/body forms environment definition-environment)
+(define (classify/body forms environment)
;; Top-level syntactic definitions affect all forms that appear
;; after them, so classify FORMS in order.
(make-body-item
(let forms-loop ((forms forms) (body-items '()))
(if (pair? forms)
(let items-loop
- ((items
- (item->list
- (classify/form (car forms)
- environment
- definition-environment)))
+ ((items (item->list (classify/form (car forms) environment)))
(body-items body-items))
(if (pair? items)
(items-loop (cdr items)
(output/post-process-expression
(if (syntactic-environment/top-level? senv)
(compile-body-item/top-level
- (let ((senv (make-top-level-syntactic-environment senv)))
- (classify/body forms senv senv)))
+ (classify/body forms (make-top-level-syntactic-environment senv)))
(output/sequence (compile/expressions forms senv))))))))
(define (compile/expression expression environment)
(define (capture-syntactic-environment expander)
`(,(classifier->keyword
- (lambda (form environment definition-environment)
+ (lambda (form environment)
form ;ignore
(classify/form (expander environment)
- environment
- definition-environment)))))
+ environment)))))
(define (reverse-syntactic-environments environment procedure)
(capture-syntactic-environment