PasteRack.org
Paste # 59739
2017-03-14 13:12:18

Fork as a new paste.

Paste viewed 148 times.


Embed:

  1. #lang racket/base
  2.  
  3. (require
  4.  (for-syntax
  5.   racket/base
  6.   syntax/parse
  7.   ))
  8.  
  9. (define-syntax (test stx)
  10.  
  11.   (define-splicing-syntax-class maybe
  12.     #:datum-literals (:thing)
  13.     (pattern (~seq :thing n:id))
  14.     (pattern (~seq ) #:attr n #'0))
  15.  
  16.   (syntax-parse stx
  17.     ((_ a:maybe (b:id ...))
  18.      #''(a.n b ...))))
  19.  
  20. (test (x y z))
  21. (test :thing v (x y z))
  22. (test :thung v (x y z))

=>

'(0 x y z)

'(v x y z)

eval:4.0: test: bad syntax

  in: (test :thung v (x y z))