Debian Codegraph @

%3a0/cond-expand.sls

raw
1 #!r6rs
2 ;; Copyright 2009 Derick Eddington. My MIT-style license is in the file named
3 ;; LICENSE from the original collection this file is distributed with.
4
5 (library (srfi :0 cond-expand)
6 (export
7 cond-expand)
8 (import
9 (rnrs)
10 (for (only (srfi private registry) expand-time-features) expand))
11
12 (define-syntax cond-expand
13 (lambda (stx)
14 (syntax-case stx (and or not else)
15 ((_)
16 (syntax-violation #F "unfulfilled cond-expand" stx))
17 ((_ (else body ...))
18 #'(begin body ...))
19 ((_ ((and) body ...) more-clauses ...)
20 #'(begin body ...))
21 ((_ ((and req1 req2 ...) body ...) more-clauses ...)
22 #'(cond-expand
23 (req1
24 (cond-expand
25 ((and req2 ...) body ...)
26 more-clauses ...))
27 more-clauses ...))
28 ((_ ((or) body ...) more-clauses ...)
29 #'(cond-expand more-clauses ...))
30 ((_ ((or req1 req2 ...) body ...) more-clauses ...)
31 #'(cond-expand
32 (req1
33 (begin body ...))
34 (else
35 (cond-expand
36 ((or req2 ...) body ...)
37 more-clauses ...))))
38 ((_ ((not req) body ...) more-clauses ...)
39 #'(cond-expand
40 (req
41 (cond-expand more-clauses ...))
42 (else body ...)))
43 ((_ (feature-id body ...) more-clauses ...)
44 (if (member (syntax->datum #'feature-id) expand-time-features)
45 #'(begin body ...)
46 #'(cond-expand more-clauses ...))))))
47
48 )