Artifact
bd53090b5e1cb91d03ee382a9484cd53512b60ce:
- File
srfi/s0/cond-expand.sls
— part of check-in
[80c8c83034]
at
2016-07-07 18:11:39
on branch trunk
— initial import
(user:
ovenpasta@pizzahack.eu
size: 1682)
#!r6rs
(library (srfi s0 cond-expand)
(export
cond-expand)
(import
(rnrs)
(for (srfi private registry) expand))
(define-syntax cond-expand
(lambda (stx)
(syntax-case stx (and or not else)
[(_)
(syntax-violation #f "Unfulfilled cond-expand" stx)]
[(_ (else body ...))
#'(begin body ...)]
[(_ ((and) body ...) more-clauses ...)
#'(begin body ...)]
[(_ ((and req1 req2 ...) body ...) more-clauses ...)
#'(cond-expand
(req1
(cond-expand
((and req2 ...) body ...)
more-clauses ...))
more-clauses ...)]
[(_ ((or) body ...) more-clauses ...)
#'(cond-expand more-clauses ...)]
[(_ ((or req1 req2 ...) body ...) more-clauses ...)
#'(cond-expand
(req1
(begin body ...))
(else
(cond-expand
((or req2 ...) body ...)
more-clauses ...)))]
[(_ ((not req) body ...) more-clauses ...)
#'(cond-expand
(req
(cond-expand more-clauses ...))
(else body ...))]
[(_ (feature-id body ...) more-clauses ...)
(if (member (syntax->datum #'feature-id) available-features)
#'(begin body ...)
#'(cond-expand more-clauses ...))])))
)