23 syntax-parse helpers
(require phc-toolkit/syntax-parse) | package: phc-toolkit |
syntax
syntax
(define-syntax/case (name . args) (literal-id ...) . body)
(define-syntax (name stx) (syntax-case stx (literal-id ...) [(_ . args) (let () . body)]))
Within body, the syntax parameter stx can be used to refer to the whole syntax given as an argument to name.
syntax
(define-syntax/parse (name . syntax-patterns) pattern-directive ... . body)
(define-syntax (name stx) (syntax-parse stx [(_ . syntax-patterns) pattern-directive ... . body]))
Within the syntax-patterns, the pattern-directive and the body, the syntax parameter stx can be used to refer to the whole syntax given as an argument to name.
syntax
(λ/syntax-parse (name . syntax-patterns) pattern-directive ... . body)
(λ (stx) (syntax-parse stx [(_ . syntax-patterns) pattern-directive ... . body]))
Within the syntax-patterns, the pattern-directive and the body, the syntax parameter stx can be used to refer to the whole syntax given as an argument to the function.
syntax
(define-for-syntax/case-args (name (pattern ...)) . body)
(define-for-syntax (name arg ...) (with-syntax ([pattern arg] ...) . body))
where each arg is a fresh identifier.
syntax
(λ/syntax-case patterns (literal ...) . body)
(λ (stx) (syntax-case stx (literal ...) [(_ . patterns) ... . body]))
Within the patterns, and the body, the syntax parameter stx can be used to refer to the whole syntax given as an argument to the function.
syntax
(define/case-args (name (pattern ...)) . body)
(define (name arg ...) (with-syntax ([pattern arg] ...) . body))
where each arg is a fresh identifier.
23.1 Pattern expanders
pattern expander
(~either alt ...)
pattern expander
(~lit alt ...)
pattern expander
(~with pat val)
pattern expander
(~attr attr-name val)
where name is derived from the keyword, so that ~optkw #:foo binds the pattern variable foo.
(~optional {~seq {~and name kw} pattern ...} #:name "the kw keyword")
where the occurrence of "kw" within the string is replaced by the actual kw keywords, and where the name is derived from the keyword, so that ~optkw #:foo binds the pattern variable foo, and uses the name "the #:foo keyword".
This form can only be used where an ellipsis-head pattern is allowed.
23.2 Untyped versions of syntax-parse helpers
(require phc-toolkit/untyped/syntax-parse) | |
package: phc-toolkit |
syntax
syntax
syntax