[racket] syntax-parse question

From: Kevin Forchione (lysseus at gmail.com)
Date: Thu Aug 7 18:48:57 EDT 2014

On Aug 7, 2014, at 12:43 PM, Alexander D. Knauth <alexander at knauth.org> wrote:

> (define-syntax-class (thing fs)
>   #:attributes (norm)
>   [pattern x #:when (empty? fs)
>            #:with norm #'x]
>   [pattern (x ...)
>            #:declare x (thing (rest fs))
>            #:with f (first fs)
>            #:with norm #'(f x.norm ...)]
>   [pattern x #:with norm #'x])
> (syntax-parse #'(x [f1 f2 f3] (1 2 3 4) (5 (6 7) 8))
>   [(_ [f ...] . x)
>    #:declare x (thing (syntax->list #'(f ...)))
>    #'x.norm])
> ; #<syntax (f1 (f2 1 2 3 4) (f2 5 (f3 6 7) 8))>

Fantastic! I’ll have to study syntax-class more closely. Quite fabulous. Thanks so much!

-Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140807/33680cd8/attachment.html>

Posted on the users mailing list.