mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-09 22:17:34 +02:00
Wrap identifier-syntax output in make-transformer
This commit is contained in:
parent
eb8582f5b1
commit
d769a7970c
1 changed files with 13 additions and 7 deletions
|
@ -381,22 +381,28 @@
|
||||||
(define-current-ellipsis ellipsis)
|
(define-current-ellipsis ellipsis)
|
||||||
. body))))))
|
. body))))))
|
||||||
|
|
||||||
;; identifier-syntax definition from R6RS Libraries section 12.9
|
;; identifier-syntax adapted from R6RS Libraries section 12.9
|
||||||
|
;; (changes: use only round brackets; can't use fenders in Chibi
|
||||||
|
;; syntax-rules; wrap the transformer procedures in make-transformer
|
||||||
|
;; so they can be used in Chibi anywhere a syntax transformer is
|
||||||
|
;; used, not just in {define,let,letrec}-syntax)
|
||||||
(define-syntax identifier-syntax
|
(define-syntax identifier-syntax
|
||||||
(syntax-rules (set!)
|
(syntax-rules (set!)
|
||||||
((_ e)
|
((_ e)
|
||||||
(lambda (x)
|
(make-transformer
|
||||||
(syntax-case x ()
|
(lambda (x)
|
||||||
(id (identifier? #'id) #'e)
|
(syntax-case x ()
|
||||||
((_ x (... ...)) #'(e x (... ...))))))
|
(id (identifier? #'id) #'e)
|
||||||
|
((_ x (... ...)) #'(e x (... ...)))))))
|
||||||
((_ (id exp1) ((set! var val) exp2))
|
((_ (id exp1) ((set! var val) exp2))
|
||||||
#;(and (identifier? #'id) (identifier? #'var))
|
#;(and (identifier? #'id) (identifier? #'var))
|
||||||
(make-variable-transformer
|
(make-transformer
|
||||||
|
(make-variable-transformer
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(syntax-case x (set!)
|
(syntax-case x (set!)
|
||||||
((set! var val) #'exp2)
|
((set! var val) #'exp2)
|
||||||
((id x (... ...)) #'(exp1 x (... ...)))
|
((id x (... ...)) #'(exp1 x (... ...)))
|
||||||
(id (identifier? #'id) #'exp1)))))))
|
(id (identifier? #'id) #'exp1))))))))
|
||||||
|
|
||||||
;; Local variables:
|
;; Local variables:
|
||||||
;; eval: (put '%define-syntax 'scheme-indent-function 1)
|
;; eval: (put '%define-syntax 'scheme-indent-function 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue