|
|
@ -8,6 +8,7 @@
|
|
|
|
racket/format
|
|
|
|
racket/format
|
|
|
|
syntax/stx
|
|
|
|
syntax/stx
|
|
|
|
syntax/strip-context
|
|
|
|
syntax/strip-context
|
|
|
|
|
|
|
|
syntax/parse
|
|
|
|
br/define
|
|
|
|
br/define
|
|
|
|
br/private/syntax-flatten)
|
|
|
|
br/private/syntax-flatten)
|
|
|
|
(provide (all-defined-out)
|
|
|
|
(provide (all-defined-out)
|
|
|
@ -35,13 +36,20 @@
|
|
|
|
#:when result)
|
|
|
|
#:when result)
|
|
|
|
result)))
|
|
|
|
result)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (syntax-parse/easy STX LITS . EXPS)
|
|
|
|
|
|
|
|
(with-syntax ([(BOUND-LITS UNBOUND-LITS) (generate-bound-and-unbound-literals #'LITS)])
|
|
|
|
|
|
|
|
#'(syntax-parse (syntax-case STX () [any #'any])
|
|
|
|
|
|
|
|
#:literals BOUND-LITS
|
|
|
|
|
|
|
|
#:datum-literals UNBOUND-LITS
|
|
|
|
|
|
|
|
. EXPS)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro-cases pattern-case
|
|
|
|
(define-macro-cases pattern-case
|
|
|
|
[(_ STX-ARG
|
|
|
|
[(_ STX-ARG
|
|
|
|
[PAT . BODY] ...
|
|
|
|
[PAT . BODY] ...
|
|
|
|
[else . ELSEBODY]) (with-syntax ([(LITERAL ...) (generate-literals #'(PAT ...))])
|
|
|
|
[else . ELSEBODY]) #'(syntax-parse/easy STX-ARG (PAT ...)
|
|
|
|
#'(syntax-case STX-ARG (LITERAL ...)
|
|
|
|
|
|
|
|
[PAT . BODY] ...
|
|
|
|
[PAT . BODY] ...
|
|
|
|
[else . ELSEBODY]))]
|
|
|
|
[else . ELSEBODY])]
|
|
|
|
[(_ STX-ARG PAT+BODY ...)
|
|
|
|
[(_ STX-ARG PAT+BODY ...)
|
|
|
|
#'(pattern-case STX-ARG
|
|
|
|
#'(pattern-case STX-ARG
|
|
|
|
PAT+BODY ...
|
|
|
|
PAT+BODY ...
|
|
|
@ -51,11 +59,10 @@
|
|
|
|
(define-macro-cases with-pattern
|
|
|
|
(define-macro-cases with-pattern
|
|
|
|
[(_ () . BODY) #'(begin . BODY)]
|
|
|
|
[(_ () . BODY) #'(begin . BODY)]
|
|
|
|
[(_ ([PAT0 STX0] PAT+STX ...) . BODY)
|
|
|
|
[(_ ([PAT0 STX0] PAT+STX ...) . BODY)
|
|
|
|
(with-syntax ([(LITERAL ...) (generate-literals #'PAT0)])
|
|
|
|
#'(syntax-parse/easy STX0 PAT0
|
|
|
|
#'(syntax-case STX0 (LITERAL ...)
|
|
|
|
|
|
|
|
[PAT0 (with-pattern (PAT+STX ...) (let () . BODY))]
|
|
|
|
[PAT0 (with-pattern (PAT+STX ...) (let () . BODY))]
|
|
|
|
[else (raise-syntax-error 'with-pattern
|
|
|
|
[else (raise-syntax-error 'with-pattern
|
|
|
|
(format "unable to match pattern ~a" 'PAT0) STX0)]))])
|
|
|
|
(format "unable to match pattern ~a" 'PAT0) STX0)])])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-macro (format-string FMT ID0 ID ...)
|
|
|
|
(define-macro (format-string FMT ID0 ID ...)
|
|
|
|