#| -*-Scheme-*-
-$Id: mit-syntax.scm,v 14.18 2003/03/14 01:11:36 cph Exp $
+$Id: mit-syntax.scm,v 14.19 2003/04/17 02:52:08 cph Exp $
Copyright 1989,1990,1991,2001,2002,2003 Massachusetts Institute of Technology
(lambda (form environment definition-environment history)
definition-environment ;ignore
(syntax-check '(KEYWORD EXPRESSION) form history)
- (expression->transformer-item (classify/subexpression (cadr form)
- environment
- history
- select-cadr)
- environment
- history
- transformer->expander-name
- transformer->expander)))
-
-(define (expression->transformer-item item environment history
- transformer->expander-name
- transformer->expander)
- (make-transformer-item
+ (expression->keyword-value-item (classify/subexpression (cadr form)
+ environment
+ history
+ select-cadr)
+ environment
+ history
+ transformer->expander-name
+ transformer->expander)))
+
+(define (expression->keyword-value-item item environment history
+ transformer->expander-name
+ transformer->expander)
+ (make-keyword-value-item
(transformer->expander
(transformer-eval (compile-item/expression item)
(syntactic-environment->environment environment))
history))
(define (syntactic-binding-theory environment name item history)
- (let ((item
- (if (expression-item? item)
- ;; Kludge to support old syntax -- treat procedure
- ;; argument as non-hygienic transformer.
- (expression->transformer-item
- item environment history
- 'NON-HYGIENIC-MACRO-TRANSFORMER->EXPANDER
- non-hygienic-macro-transformer->expander)
- item)))
- (if (not (keyword-item? item))
- (let ((history (item/history item)))
- (syntax-error history "Syntactic binding value must be a keyword:"
- (history/original-form history))))
- (overloaded-binding-theory environment name item history)))
+ (if (not (keyword-item? item))
+ (let ((history (item/history item)))
+ (syntax-error history "Syntactic binding value must be a keyword:"
+ (history/original-form history))))
+ (overloaded-binding-theory environment name item history))
(define (variable-binding-theory environment name item history)
(if (keyword-item? item)
name
(item/new-history item #f))
;; User-defined macros at top level are preserved in the output.
- (if (and (transformer-item? item)
+ (if (and (keyword-value-item? item)
(syntactic-environment/top-level? environment))
(make-binding-item history name item)
(make-null-binding-item history)))
#| -*-Scheme-*-
-$Id: syntactic-closures.scm,v 14.15 2003/03/08 02:07:18 cph Exp $
+$Id: syntactic-closures.scm,v 14.16 2003/04/17 02:52:16 cph Exp $
Copyright 1989,1990,1991,2001,2002,2003 Massachusetts Institute of Technology
(if (binding-item? item)
(let ((name (binding-item/name item))
(value (binding-item/value item)))
- (if (transformer-item? value)
+ (if (keyword-value-item? value)
(output/top-level-syntax-definition
name
- (compile-item/expression (transformer-item/expression value)))
+ (compile-item/expression (keyword-value-item/expression value)))
(output/top-level-definition
name
(compile-item/expression value))))
(define (classify/form form environment definition-environment history)
(cond ((identifier? form)
- (item/new-history (lookup-identifier environment form) history))
+ (let ((item
+ (item/new-history (lookup-identifier environment form)
+ history)))
+ (if (keyword-item? item)
+ (make-keyword-ref-item (strip-keyword-value-item item)
+ form
+ history)
+ item)))
((syntactic-closure? form)
(let ((form (syntactic-closure/form form))
(environment
history))))
((pair? form)
(let ((item
- (classify/subexpression (car form) environment history
- select-car)))
+ (strip-keyword-value-item
+ (classify/subexpression (car form) environment history
+ select-car))))
(cond ((classifier-item? item)
((classifier-item/classifier item) form
environment
environment
definition-environment
history))
- ((transformer-item? item)
- (classify/expander (transformer-item/expander item)
- form
- environment
- definition-environment
- history))
(else
(if (not (list? (cdr form)))
(syntax-error history
declarations
(cons (car items) items*)))
(values (reverse! declarations) (reverse! items*)))))
+
+(define (strip-keyword-value-item item)
+ (if (keyword-value-item? item)
+ (keyword-value-item/item item)
+ item))
\f
;;;; Syntactic Closures
(or (classifier-item? item)
(compiler-item? item)
(expander-item? item)
- (transformer-item? item)))
+ (keyword-value-item? item)))
(define (make-keyword-type name fields)
(make-item-type name fields keyword-item-compiler))
(item-accessor <expander-item> 'ENVIRONMENT))
-(define <transformer-item>
- (make-keyword-type "transformer-item" '(EXPANDER EXPRESSION)))
+(define <keyword-value-item>
+ (make-keyword-type "keyword-value-item" '(ITEM EXPRESSION)))
+
+(define make-keyword-value-item
+ (keyword-constructor <keyword-value-item> '(ITEM EXPRESSION)))
-(define make-transformer-item
- (keyword-constructor <transformer-item> '(EXPANDER EXPRESSION)))
+(define keyword-value-item?
+ (item-predicate <keyword-value-item>))
-(define transformer-item?
- (item-predicate <transformer-item>))
+(define keyword-value-item/item
+ (item-accessor <keyword-value-item> 'ITEM))
-(define transformer-item/expander
- (item-accessor <transformer-item> 'EXPANDER))
+(define keyword-value-item/expression
+ (item-accessor <keyword-value-item> 'EXPRESSION))
-(define transformer-item/expression
- (item-accessor <transformer-item> 'EXPRESSION))
+(define (make-keyword-ref-item item identifier history)
+ (make-keyword-value-item item
+ (make-expression-item history
+ (let ((name (identifier->symbol identifier)))
+ (lambda ()
+ (output/combination
+ (output/access-reference 'SYNTACTIC-KEYWORD->ITEM
+ system-global-environment)
+ (list name (output/the-environment))))))))
\f
;;; Variable items represent run-time variables.
(map (lambda (item)
(if (binding-item? item)
(let ((value (binding-item/value item)))
- (if (transformer-item? value)
+ (if (keyword-value-item? value)
(output/sequence '())
(output/definition (binding-item/name item)
(compile-item/expression value))))