-;;; -*-Scheme-*-
-;;;
-;;; $Id: mit-syntax.scm,v 14.10 2002/12/13 18:55:07 cph Exp $
-;;;
-;;; Copyright (c) 1989-1991, 2001, 2002 Massachusetts Institute of Technology
-;;;
-;;; This file is part of MIT Scheme.
-;;;
-;;; MIT Scheme is free software; you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published
-;;; by the Free Software Foundation; either version 2 of the License,
-;;; or (at your option) any later version.
-;;;
-;;; MIT Scheme is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;;; General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with MIT Scheme; if not, write to the Free Software
-;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-;;; 02111-1307, USA.
+#| -*-Scheme-*-
+
+$Id: mit-syntax.scm,v 14.11 2003/02/12 19:39:52 cph Exp $
+
+Copyright 1989,1990,1991,2001,2002,2003 Massachusetts Institute of Technology
+
+This file is part of MIT Scheme.
+
+MIT Scheme is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+MIT Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT Scheme; if not, write to the Free Software Foundation,
+Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+|#
;;;; MIT Scheme Syntax
(classifier->keyword
(lambda (form environment definition-environment history)
definition-environment
- (let ((body-environment
- (make-internal-syntactic-environment environment)))
+ (let* ((binding-environment
+ (make-internal-syntactic-environment environment))
+ (body-environment
+ (make-internal-syntactic-environment binding-environment)))
(classify/let-like form
environment
+ binding-environment
body-environment
body-environment
history
(lambda (form environment definition-environment history)
definition-environment
(syntax-check '(KEYWORD (* (IDENTIFIER ? EXPRESSION)) + FORM) form history)
- (let ((body-environment (make-internal-syntactic-environment environment)))
+ (let* ((binding-environment
+ (make-internal-syntactic-environment environment))
+ (body-environment
+ (make-internal-syntactic-environment binding-environment)))
(for-each (let ((item (make-reserved-name-item history)))
(lambda (binding)
- (syntactic-environment/define body-environment
+ (syntactic-environment/define binding-environment
(car binding)
item)))
(cadr form))
(classify/let-like form
- body-environment
+ binding-environment
+ binding-environment
body-environment
body-environment
history
\f
(define-classifier 'LET-SYNTAX system-global-environment
(lambda (form environment definition-environment history)
- definition-environment
(syntax-check '(KEYWORD (* (IDENTIFIER EXPRESSION)) + FORM) form history)
- (classify/let-like form
- environment
- definition-environment
- (make-internal-syntactic-environment environment)
- history
- syntactic-binding-theory
- output/let)))
+ (let* ((binding-environment
+ (make-internal-syntactic-environment environment))
+ (body-environment
+ (make-internal-syntactic-environment binding-environment)))
+ (classify/let-like form
+ environment
+ binding-environment
+ body-environment
+ definition-environment
+ history
+ syntactic-binding-theory
+ output/let))))
(define-er-macro-transformer 'LET*-SYNTAX system-global-environment
(lambda (form rename compare)
(define-classifier 'LETREC-SYNTAX system-global-environment
(lambda (form environment definition-environment history)
- definition-environment
(syntax-check '(KEYWORD (* (IDENTIFIER EXPRESSION)) + FORM) form history)
- (let ((body-environment (make-internal-syntactic-environment environment)))
+ (let* ((binding-environment
+ (make-internal-syntactic-environment environment))
+ (body-environment
+ (make-internal-syntactic-environment binding-environment)))
(for-each (let ((item (make-reserved-name-item history)))
(lambda (binding)
- (syntactic-environment/define body-environment
+ (syntactic-environment/define binding-environment
(car binding)
item)))
(cadr form))
(classify/let-like form
+ binding-environment
+ binding-environment
body-environment
definition-environment
- body-environment
history
syntactic-binding-theory
output/letrec))))
\f
-(define (classify/let-like form environment definition-environment
- body-environment history binding-theory output/let)
+(define (classify/let-like form
+ value-environment
+ binding-environment
+ body-environment
+ definition-environment
+ history
+ binding-theory
+ output/let)
;; Classify right-hand sides first, in order to catch references to
;; reserved names. Then bind names prior to classifying body.
(let* ((bindings
(delete-matching-items!
(map (lambda (binding item)
- (binding-theory body-environment
+ (binding-theory binding-environment
(car binding)
item
history))
(cadr form)
(select-map (lambda (binding selector)
(classify/subexpression (cadr binding)
- environment
+ value-environment
history
(selector/add-cadr
selector)))
#| -*-Scheme-*-
-$Id: syntax-output.scm,v 14.7 2003/02/09 01:58:09 cph Exp $
+$Id: syntax-output.scm,v 14.8 2003/02/12 19:40:38 cph Exp $
Copyright 1989,1990,1991,2001,2002,2003 Massachusetts Institute of Technology
(output/named-lambda lambda-tag:unnamed lambda-list body))
(define (output/named-lambda name lambda-list body)
- (output/lambda-internal name lambda-list '() body))
-
-(define (output/lambda-internal name lambda-list declarations body)
(call-with-values (lambda () (parse-mit-lambda-list lambda-list))
(lambda (required optional rest)
- (make-lambda* name required optional rest
- (let ((declarations (apply append declarations)))
- (if (pair? declarations)
- (make-sequence (make-block-declaration declarations)
- body)
- body))))))
+ (make-lambda* name required optional rest body))))
(define (output/delay expression)
(make-delay expression))
(output/combination (output/named-lambda lambda-tag:let names body) values))
(define (output/letrec names values body)
- (output/let names
- (map (lambda (name) name (output/unassigned)) names)
+ (output/let '() '()
(make-sequence
- (map* (list (scan-defines body
- (lambda (names declarations body)
- (if (or (pair? names)
- (pair? declarations))
- (output/let '() '()
- (make-open-block names
- declarations
- body))
- body))))
- output/assignment names values))))
+ (append! (map make-definition names values)
+ (list
+ (let ((body (scan-defines body make-open-block)))
+ (if (open-block? body)
+ (output/let '() '() body)
+ body)))))))
(define (output/body declarations body)
(scan-defines (let ((declarations (apply append declarations)))