www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

test-extend-structure-options.rkt (812B)


      1 #lang racket
      2 
      3 (require rackunit
      4          phc-toolkit/untyped
      5          (for-syntax extensible-parser-specifications
      6                      "test-structure-options.rkt"
      7                      syntax/parse))
      8 
      9 (define-syntax/parse+simple [foo foo-a :structure-kws]
     10   #''(foo-a field ...))
     11 
     12 (check-equal? (foo #:first-case  [f tf] [g tg])
     13               '(#:first-case f g))
     14 
     15 (begin-for-syntax
     16   (define-splicing-syntax-class structure-xyz-kws
     17     (pattern {~seq-no-order {~optional {~seq #:xyz xyz:id}}
     18                             {structure-kw-all-mixin}})))
     19 
     20 (define-syntax/parse [bar foo-a :structure-xyz-kws]
     21   #`'[(xyz foo-a field ...)
     22       #,(foo-forward-attributes)])
     23 
     24 (check-equal? (bar #:second-case #:xyz zyx [f tf] [g tg])
     25               '((zyx #:second-case f g)
     26                 (quote (#:second-case f g))))