#lang scheme/base
(require (for-syntax scheme/base))
(define-syntax (+:os stx)
(syntax-case stx (:windows :macosx :unix else)
((~ (:windows exp) rest ...)
(equal? (system-type 'os) 'windows)
#'exp)
((~ (:windows exp) rest ...)
#'(~ rest ...))
((~ (:macosx exp) rest ...)
(equal? (system-type 'os) 'macosx)
#'exp)
((~ (:macosx exp) rest ...)
#'(~ (rest ...)))
((~ (:unix exp) rest ...)
(equal? (system-type 'os) 'unix)
#'exp)
((~ (:unix exp) rest ...)
#'(~ rest ...))
((~ (else exp))
#'exp)
((~)
#'(void))))
(define-syntax +:windows
(syntax-rules ()
((~ exp exp2)
(+:os (:windows exp) (else exp2)))
((~ exp)
(+:os (:windows exp)))))
(define-syntax +:macosx
(syntax-rules ()
((~ exp exp2)
(+:os (:macosx exp) (else exp2)))
((~ exp)
(+:os (:macosx exp)))))
(define-syntax +:unix
(syntax-rules ()
((~ exp exp2)
(+:os (:unix exp) (else exp2)))
((~ exp)
(+:os (:unix exp)))))
(provide +:os +:windows +:unix +:macosx)