Eliminate unused and unneeded definition-environment in syntaxer.
authorChris Hanson <org/chris-hanson/cph>
Tue, 26 Dec 2017 05:09:51 +0000 (00:09 -0500)
committerChris Hanson <org/chris-hanson/cph>
Tue, 26 Dec 2017 05:09:51 +0000 (00:09 -0500)
src/runtime/mit-syntax.scm
src/runtime/syntax-classify.scm
src/runtime/syntax.scm

index 4e690cb7ce21a259235783fecd6bbf0ee02e5e38..686a6f1b0acbf18553c5573e95e94114d466b79c 100644 (file)
@@ -32,8 +32,7 @@ USA.
 ;;;; 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
@@ -88,13 +87,11 @@ USA.
                                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)
@@ -142,22 +139,19 @@ USA.
 
 (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)))
 
@@ -180,8 +174,7 @@ USA.
 
 (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
@@ -194,8 +187,7 @@ USA.
                          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))
@@ -211,8 +203,7 @@ USA.
 (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))
@@ -250,10 +241,7 @@ USA.
                               (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
@@ -294,8 +282,7 @@ USA.
 
 (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)))))
 
@@ -325,8 +312,7 @@ USA.
 \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 ()
index c918f22d6416900a2746623a555b6897f869a5ae..125b883ac136d1a07a003335b0b0a4620ab3eec2 100644 (file)
@@ -28,7 +28,7 @@ USA.
 
 (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)
@@ -49,16 +49,13 @@ USA.
           (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)))
@@ -67,8 +64,7 @@ USA.
                 ((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))
@@ -86,29 +82,25 @@ USA.
       (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)
index 69cdb70dea7b8e58d6595bfc65926321a7c88773..64620fbd013322d52d4e4ff61ab1bcb9d9104dfd 100644 (file)
@@ -54,8 +54,7 @@ USA.
        (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)
@@ -182,11 +181,10 @@ USA.
 
 (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