|
|
@ -3,28 +3,35 @@
|
|
|
|
(provide splicing-syntax-parameterize
|
|
|
|
(provide splicing-syntax-parameterize
|
|
|
|
define-syntax-parameters
|
|
|
|
define-syntax-parameters
|
|
|
|
define-language-variables
|
|
|
|
define-language-variables
|
|
|
|
|
|
|
|
define-language-variable
|
|
|
|
inject-language-variables
|
|
|
|
inject-language-variables
|
|
|
|
(rename-out [br:define-syntax-parameter define-syntax-parameter]))
|
|
|
|
(rename-out [br:define-syntax-parameter define-syntax-parameter]))
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (br:define-syntax-parameter stx)
|
|
|
|
(define-syntax (br:define-syntax-parameter stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ ID STX)
|
|
|
|
[(_ ID STX) #'(define-syntax-parameter ID STX)]
|
|
|
|
#'(define-syntax-parameter ID STX)]
|
|
|
|
[(_ [ID VAL]) #'(define-syntax-parameter ID (λ (stx) #'VAL))]
|
|
|
|
[(_ ID)
|
|
|
|
[(_ ID) #'(define-syntax-parameter ID
|
|
|
|
#'(define-syntax-parameter ID (λ (stx)
|
|
|
|
(λ (stx) (raise-syntax-error (syntax-e stx) "parameter not set")))]))
|
|
|
|
(raise-syntax-error (syntax-e stx) "parameter not set")))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (define-syntax-parameters ID ...)
|
|
|
|
(define-syntax-rule (define-syntax-parameters ID ...)
|
|
|
|
(begin (br:define-syntax-parameter ID) ...))
|
|
|
|
(begin (br:define-syntax-parameter ID) ...))
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax define-language-variables (make-rename-transformer #'define-syntax-parameters))
|
|
|
|
(define-syntax-rule (define-language-variable ID VAL)
|
|
|
|
|
|
|
|
(br:define-syntax-parameter [ID VAL]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (define-language-variables [ID VAL] ...)
|
|
|
|
|
|
|
|
(begin (define-language-variable ID VAL) ...))
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (inject-language-variables stx)
|
|
|
|
(define-syntax (inject-language-variables stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ ([VAR-PARAM INITIAL-VALUE] ...) LANG-CODE ...)
|
|
|
|
[(_ (VAR-PARAM ...) LANG-CODE ...)
|
|
|
|
(with-syntax ([(INTERNAL-NAME ...) (generate-temporaries #'(VAR-PARAM ...))])
|
|
|
|
(with-syntax ([(HOLDS-ORIG-PARAM-VALUE ...) (generate-temporaries #'(VAR-PARAM ...))]
|
|
|
|
#'(splicing-syntax-parameterize ;; need to use splicing version in a module-begin to compose with requires etc. that might be in lang code
|
|
|
|
[(INTERNAL-NAME ...) (generate-temporaries #'(VAR-PARAM ...))])
|
|
|
|
([VAR-PARAM (make-rename-transformer #'INTERNAL-NAME)] ...)
|
|
|
|
;; need to use splicing expressions in a module-begin to compose with requires etc. that might be in lang code
|
|
|
|
(define INTERNAL-NAME INITIAL-VALUE) ...
|
|
|
|
#'(splicing-let ([HOLDS-ORIG-PARAM-VALUE VAR-PARAM] ...)
|
|
|
|
(provide (rename-out [INTERNAL-NAME VAR-PARAM] ...))
|
|
|
|
(splicing-syntax-parameterize
|
|
|
|
LANG-CODE ...))]))
|
|
|
|
([VAR-PARAM (make-rename-transformer #'INTERNAL-NAME)] ...)
|
|
|
|
|
|
|
|
(define INTERNAL-NAME HOLDS-ORIG-PARAM-VALUE) ...
|
|
|
|
|
|
|
|
(provide (rename-out [INTERNAL-NAME VAR-PARAM] ...))
|
|
|
|
|
|
|
|
LANG-CODE ...)))]))
|
|
|
|