Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SRFI 139 #85

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions %3a139.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!r6rs
(library (srfi :139)
(export define-syntax-parameter syntax-parameterize)
(import (srfi :139 impl)))
31 changes: 31 additions & 0 deletions %3a139/impl.chezscheme.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(library (srfi :139 impl)
(export define-syntax-parameter
syntax-parameterize)
(import (chezscheme)
(srfi :213))

(define-syntax syntax-parameter? (syntax-rules ()))
(define-syntax define-syntax-parameter
(syntax-rules ()
((_ name default-transformer)
(begin
(define-syntax name default-transformer)
(define-property name syntax-parameter? #t)))))

(define-syntax syntax-parameterize
(lambda (stx)
(capture-lookup
(lambda (lookup)
(syntax-case stx ()
((_ ((name new-transformer) ...) body_0 body_1 ...)
(cond ((find (lambda (n)
(not (lookup n #'syntax-parameter?)))
#'(name ...))
=> (lambda (n)
(syntax-violation 'syntax-parameterize
"identifier is not bound to a syntax parameter"
stx
n)))
(else
#'(fluid-let-syntax ((name new-transformer) ...)
body_0 body_1 ...))))))))))
Loading