From d1c76d784b6681525a408065ea9dbe3b0fcd3d79 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 26 Dec 2017 00:09:51 -0500 Subject: [PATCH] Eliminate unused and unneeded definition-environment in syntaxer. --- src/runtime/mit-syntax.scm | 50 ++++++++++++--------------------- src/runtime/syntax-classify.scm | 28 +++++++----------- src/runtime/syntax.scm | 8 ++---- 3 files changed, 31 insertions(+), 55 deletions(-) diff --git a/src/runtime/mit-syntax.scm b/src/runtime/mit-syntax.scm index 4e690cb7c..686a6f1b0 100644 --- a/src/runtime/mit-syntax.scm +++ b/src/runtime/mit-syntax.scm @@ -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))))) -(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. ;;;; 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 () diff --git a/src/runtime/syntax-classify.scm b/src/runtime/syntax-classify.scm index c918f22d6..125b883ac 100644 --- a/src/runtime/syntax-classify.scm +++ b/src/runtime/syntax-classify.scm @@ -28,7 +28,7 @@ USA. (declare (usual-integrations)) -(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)) -(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) diff --git a/src/runtime/syntax.scm b/src/runtime/syntax.scm index 69cdb70de..64620fbd0 100644 --- a/src/runtime/syntax.scm +++ b/src/runtime/syntax.scm @@ -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 -- 2.25.1