File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 11#lang racket/base
22
3- (provide (except-out (all-from-out macrotypes/typecheck)
3+ (provide (except-out (all-from-out macrotypes/typecheck)
44 -define-typed-syntax -define-syntax-category)
55 define-typed-syntax define-syntax-category
6+ define-typed-variable-syntax
67 (rename-out [define-typed-syntax define-typerule]
78 [define-typed-syntax define-syntax/typecheck])
89 (for-syntax syntax-parse/typecheck
527528 [current-tag 'key1 ])
528529 (syntax-parse/typecheck stx kw-stuff (... ... )
529530 rule (... ... ))))])))]))
531+
532+ (define-syntax define-typed-variable-syntax
533+ (syntax-parser
534+ [(_ (NAME:id orig-var-pat . props-pat)
535+ (~and (~seq kw-stuff ... ) :stxparse-kws)
536+ rule ...+)
537+ #:with ((~seq tag:id _ ) ... ) #'props-pat
538+ #:with make-transformer (generate-temporary #'name )
539+ #:with invalid-invok-str (format "invalid invocation of var, expected tags: ~a "
540+ (syntax->datum #'(tag ... )))
541+ #'(begin-for-syntax
542+ (define (make-transformer stx)
543+ (syntax-parse stx
544+ #:datum-literals (tag ... )
545+ [(orig-var-pat . props-pat)
546+ (make-set!-transformer
547+ (syntax-parser
548+ [(~var _ identifier)
549+ (syntax-parse/typecheck this-syntax
550+ kw-stuff ...
551+ rule ... )]
552+ [(id . args)
553+ #:with ap (datum->syntax this-syntax '#%app )
554+ (syntax/loc this-syntax (ap id . args))]))]
555+ [_
556+ (raise-syntax-error #f 'invalid-invok-str this-syntax)]))
557+ (define-syntax (NAME stx)
558+ (syntax-case stx ()
559+ [(_ . args)
560+ #'(make-transformer #'args )])))]))
You can’t perform that action at this time.
0 commit comments