Added ~mixin, which checs that its argument is indeed a mixin. Mixins can still be used by themeselves, but there's always the risk that they'll be seen as a pattern variable, if for some reason their identifier is not bound to a mixin (forgot to export, wrong scopes…)
This commit is contained in:
parent
a7dd0c0759
commit
1d45a9ea62
2
main.rkt
2
main.rkt
|
@ -6,6 +6,7 @@
|
||||||
"private/post.rkt"
|
"private/post.rkt"
|
||||||
"private/global.rkt"
|
"private/global.rkt"
|
||||||
"private/optional.rkt"
|
"private/optional.rkt"
|
||||||
|
"private/mixin.rkt"
|
||||||
(for-template "private/define-syntax+simple-api.rkt"))
|
(for-template "private/define-syntax+simple-api.rkt"))
|
||||||
|
|
||||||
(provide #;define-splicing-syntax-class-with-eh-mixins
|
(provide #;define-splicing-syntax-class-with-eh-mixins
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
(expander-out eh-mixin)
|
(expander-out eh-mixin)
|
||||||
~seq-no-order
|
~seq-no-order
|
||||||
~no-order
|
~no-order
|
||||||
|
~mixin
|
||||||
~post-check
|
~post-check
|
||||||
~post-fail
|
~post-fail
|
||||||
~nop
|
~nop
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
(define (name stx2)
|
(define (name stx2)
|
||||||
(syntax-parameterize ([stx (make-rename-transformer #'stx2)])
|
(syntax-parameterize ([stx (make-rename-transformer #'stx2)])
|
||||||
(syntax-parse stx2
|
(syntax-parse stx2
|
||||||
[(name . colon-stxclass) . body])))
|
[(_ . colon-stxclass) . body])))
|
||||||
(define (private-simple-api stx/arg attr-name/arg …)
|
(define (private-simple-api stx/arg attr-name/arg …)
|
||||||
(syntax-parameterize ([stx (make-rename-transformer #'stx/arg)])
|
(syntax-parameterize ([stx (make-rename-transformer #'stx/arg)])
|
||||||
(syntax-parse #'nothing
|
(syntax-parse #'nothing
|
||||||
|
|
11
private/mixin.rkt
Normal file
11
private/mixin.rkt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#lang racket
|
||||||
|
|
||||||
|
(require "no-order.rkt"
|
||||||
|
(for-syntax syntax/parse))
|
||||||
|
|
||||||
|
(provide ~mixin)
|
||||||
|
|
||||||
|
(define-eh-mixin-expander ~mixin
|
||||||
|
(syntax-parser
|
||||||
|
[(_ (~var mixin (static eh-mixin-expander? "an eh-mixin expander")))
|
||||||
|
#'(mixin)]))
|
|
@ -73,11 +73,11 @@
|
||||||
{structure-kw-predicate-mixin}
|
{structure-kw-predicate-mixin}
|
||||||
{structure-kw-fields-mixin}}))
|
{structure-kw-fields-mixin}}))
|
||||||
|
|
||||||
;; ---------
|
|
||||||
|
|
||||||
(define-splicing-syntax-class structure-kws
|
(define-splicing-syntax-class structure-kws
|
||||||
(pattern {~seq-no-order {structure-kw-all-mixin}}))
|
(pattern {~seq-no-order {structure-kw-all-mixin}}))
|
||||||
|
|
||||||
|
;; ---------
|
||||||
|
|
||||||
(check-equal? (syntax-parse #'(#:instance #:? p)
|
(check-equal? (syntax-parse #'(#:instance #:? p)
|
||||||
[(:structure-kws)
|
[(:structure-kws)
|
||||||
(list* (attribute instance)
|
(list* (attribute instance)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user