From: Chris Hanson Date: Sun, 20 Sep 2009 06:54:13 +0000 (-0700) Subject: Refactor syntax to break it into smaller, more coherent pieces. X-Git-Tag: 20100708-Gtk~328 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=d846a9b166f5dd72a83e9a11b1be5590d60ced3e;p=mit-scheme.git Refactor syntax to break it into smaller, more coherent pieces. Simplify where easy to do so. --- diff --git a/src/compiler/machines/C/compiler.pkg b/src/compiler/machines/C/compiler.pkg index 839dc510b..17272cda4 100644 --- a/src/compiler/machines/C/compiler.pkg +++ b/src/compiler/machines/C/compiler.pkg @@ -213,9 +213,7 @@ USA. make-rvalue make-snode package - rule-matcher) - (import (runtime syntactic-closures) - syntax-match?)) + rule-matcher)) (define-package (compiler declarations) (files "machines/C/decls") diff --git a/src/compiler/machines/i386/compiler.pkg b/src/compiler/machines/i386/compiler.pkg index 34314bdb9..572de333f 100644 --- a/src/compiler/machines/i386/compiler.pkg +++ b/src/compiler/machines/i386/compiler.pkg @@ -214,9 +214,7 @@ USA. make-rvalue make-snode package - rule-matcher) - (import (runtime syntactic-closures) - syntax-match?)) + rule-matcher)) (define-package (compiler declarations) (files "machines/i386/decls") diff --git a/src/edwin/clsmac.scm b/src/edwin/clsmac.scm index af5d48ed0..24dae1590 100644 --- a/src/edwin/clsmac.scm +++ b/src/edwin/clsmac.scm @@ -86,24 +86,21 @@ USA. (define with-instance-variables (make-unmapped-macro-reference-trap (make-compiler-item - (lambda (form environment history) - (if (syntax-match? '(IDENTIFIER EXPRESSION (* IDENTIFIER) + EXPRESSION) - (cdr form)) - (let ((class-name (cadr form)) - (self (caddr form)) - (free-names (cadddr form)) - (body (cddddr form))) - (transform-instance-variables - (class-instance-transforms - (name->class (identifier->symbol class-name))) - (compile/subexpression self environment history select-caddr) - free-names - (compile/subexpression - `(,(close-syntax 'BEGIN system-global-environment) ,@body) - environment - history - select-cddddr))) - (ill-formed-syntax form)))))) + (lambda (form environment) + (syntax-check '(KEYWORD IDENTIFIER EXPRESSION (* IDENTIFIER) + EXPRESSION) + form) + (let ((class-name (cadr form)) + (self (caddr form)) + (free-names (cadddr form)) + (body (cddddr form))) + (transform-instance-variables + (class-instance-transforms + (name->class (identifier->symbol class-name))) + (compile/expression self environment) + free-names + (compile/expression + `(,(close-syntax 'BEGIN system-global-environment) ,@body) + environment))))))) (define-syntax ==> (syntax-rules () diff --git a/src/edwin/edwin.pkg b/src/edwin/edwin.pkg index cba2d0e8f..05499b982 100644 --- a/src/edwin/edwin.pkg +++ b/src/edwin/edwin.pkg @@ -135,11 +135,9 @@ USA. define-method usual==> with-instance-variables) - (import (runtime syntactic-closures) - compile/subexpression - make-compiler-item - select-caddr - select-cddddr)) + (import (runtime syntax) + compile/expression + make-compiler-item)) (define-package (edwin class-macros transform-instance-variables) (files "xform") diff --git a/src/runtime/defstr.scm b/src/runtime/defstr.scm index 7b8e5575a..21362245a 100644 --- a/src/runtime/defstr.scm +++ b/src/runtime/defstr.scm @@ -73,37 +73,35 @@ differences: |# -(define-expander 'DEFINE-STRUCTURE system-global-environment - (lambda (form environment closing-environment) - (if (not (and (pair? (cdr form)) (list? (cddr form)))) - (error "Ill-formed special form:" form)) - (make-syntactic-closure closing-environment '() - (let ((name-and-options (cadr form)) - (slot-descriptions (cddr form))) +(define-syntax define-structure + (sc-macro-transformer + (lambda (form use-environment) + (syntax-check '(KEYWORD + DATUM) form) + (capture-syntactic-environment + (lambda (closing-environment) (let ((structure - (call-with-values - (lambda () + (receive (name options) + (let ((name-and-options (cadr form))) (if (pair? name-and-options) (values (car name-and-options) (cdr name-and-options)) (values name-and-options '()))) - (lambda (name options) - (if (not (symbol? name)) - (error "Structure name must be a symbol:" name)) - (if (not (list? options)) - (error "Structure options must be a list:" options)) - (let ((context - (make-parser-context name - environment - closing-environment))) - (parse/options options - (parse/slot-descriptions slot-descriptions) - context)))))) + (if (not (symbol? name)) + (error "Structure name must be a symbol:" name)) + (if (not (list? options)) + (error "Structure options must be a list:" options)) + (let ((context + (make-parser-context name + use-environment + closing-environment))) + (parse/options options + (parse/slot-descriptions (cddr form)) + context))))) `(BEGIN ,@(type-definitions structure) ,@(constructor-definitions structure) ,@(accessor-definitions structure) ,@(modifier-definitions structure) ,@(predicate-definitions structure) - ,@(copier-definitions structure))))))) + ,@(copier-definitions structure)))))))) ;;;; Parse options @@ -255,7 +253,7 @@ differences: (and (identifier? object) (there-exists? false-expression-names (lambda (name) - (identifier=? (parser-context/environment context) + (identifier=? (parser-context/use-environment context) object (parser-context/closing-environment context) name)))))) @@ -563,10 +561,10 @@ differences: (eq? (structure/physical-type structure) 'RECORD)) (define-record-type - (make-parser-context name environment closing-environment) + (make-parser-context name use-environment closing-environment) parser-context? (name parser-context/name) - (environment parser-context/environment) + (use-environment parser-context/use-environment) (closing-environment parser-context/closing-environment)) (define-record-type