Skip to content

Instantly share code, notes, and snippets.

@LeifAndersen
Created December 13, 2018 18:12
Show Gist options
  • Select an option

  • Save LeifAndersen/861fc5babb2b2ccb5d4d7973993a5de9 to your computer and use it in GitHub Desktop.

Select an option

Save LeifAndersen/861fc5babb2b2ccb5d4d7973993a5de9 to your computer and use it in GitHub Desktop.
#lang racket
(require syntax/parse/define
(for-syntax syntax/parse
racket/base
racket/syntax))
(define-syntax-parser foo
[(_ headers ... body ...)
#:when (for/fold ([good? #t])
([i (in-list (attribute headers))])
(define still-good?
(or (identifier? i)
(and (string? (syntax-e i))
(regexp-match "^ $" (syntax-e i)))))
(and good? still-good?))
(writeln (attribute headers))
(writeln (attribute body))
#'42])
(foo a " " b "\n" c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment