PasteRack.org
Paste # 21889
2019-06-08 21:39:19

Fork as a new paste.

Paste viewed 231 times.


Embed:

  1. #lang racket
  2.  
  3. (define-struct cfg (srcloc expr) #:transparent)
  4.  
  5. (define-syntax (config stx)
  6.   (syntax-parse stx
  7.     [(_ e:expr)
  8.      #'(cfg-with-srclocs (quasiquote e) #'e)]))
  9.  
  10. (define (cfg-with-srclocs expr stx)
  11.   (if (list? expr)
  12.       (let* [(stx-list (syntax-e stx))
  13.              (config-list (map cfg-with-srclocs expr stx-list))]
  14.         (cfg (build-source-location stx) config-list))
  15.       (cfg (build-source-location stx) expr)))
  16.  

=>