Initial pass at stx def transformer
This commit is contained in:
parent
38c4108281
commit
297a6d5c92
10
remix/README
10
remix/README
|
@ -187,7 +187,7 @@ TODO @docs
|
|||
DONE [] for Rec def blocks or def* for let* behavior
|
||||
and Search for def in block and trans to local-def which sees body
|
||||
|
||||
TODO [] for def & def* transformer
|
||||
DONE [] for def & def* transformer
|
||||
|
||||
TODO Meta def & def* trans for more expansion (docs and test), static
|
||||
info (types), and def transformers (types), maybe syntax ---
|
||||
|
@ -204,3 +204,11 @@ https://github.com/greghendershott/def-jambda
|
|||
|
||||
DONE nest form like def* for things like parameterize that would look
|
||||
weird as def* transformers
|
||||
|
||||
TODO stx def transfomer
|
||||
|
||||
TODO mac def transformer (simple-macro)
|
||||
|
||||
TODO mac def+ transformer (syntax-parser)
|
||||
|
||||
TODO parameterize def* transformer
|
||||
|
|
|
@ -69,11 +69,8 @@
|
|||
(syntax/loc stx
|
||||
(let () . body))]))
|
||||
|
||||
(define-syntax (#%brackets stx)
|
||||
(syntax-parse stx
|
||||
[(_ . body:expr)
|
||||
(syntax/loc stx
|
||||
(remix-block . body))]))
|
||||
(define-syntax #%brackets
|
||||
(make-rename-transformer #'remix-block))
|
||||
|
||||
(begin-for-syntax
|
||||
(define-generics binary-operator
|
||||
|
@ -185,10 +182,17 @@
|
|||
#:attr λ-arg (syntax x)
|
||||
#:attr λ-bind '())
|
||||
;; xxx write a test for this
|
||||
(pattern (~and def-lhs:expr (#%brackets . _))
|
||||
(pattern (~and def-lhs:expr (#%brackets dt . _))
|
||||
#:declare dt (static def-transformer? "def transformer")
|
||||
#:with x (generate-temporary #'def-lhs)
|
||||
#:attr λ-arg #'x
|
||||
#:attr λ-bind (list #'(def def-lhs x))))
|
||||
#:attr λ-bind (list #'(def def-lhs x)))
|
||||
;; xxx write a test for this
|
||||
(pattern (~and def-lhs:expr (#%brackets dt . _))
|
||||
#:declare dt (static def*-transformer? "def* transformer")
|
||||
#:with x (generate-temporary #'def-lhs)
|
||||
#:attr λ-arg #'x
|
||||
#:attr λ-bind (list #'(def* def-lhs x))))
|
||||
(define-syntax-class remix-λ-maybe-def-arg
|
||||
#:attributes (λ-arg λ-bind)
|
||||
(pattern x:remix-λ-raw-arg
|
||||
|
@ -269,6 +273,8 @@
|
|||
(remix-cond . more))))]))
|
||||
|
||||
(provide def def*
|
||||
(for-syntax gen:def-transformer
|
||||
gen:def*-transformer)
|
||||
(rename-out [def ≙]
|
||||
[def* ≙*]
|
||||
[def* nest])
|
||||
|
@ -282,6 +288,7 @@
|
|||
binary-operator?
|
||||
binary-operator-precedence)
|
||||
#%dot
|
||||
(for-syntax gen:dot-transformer)
|
||||
#%app
|
||||
#%datum
|
||||
quote
|
||||
|
@ -289,4 +296,21 @@
|
|||
module
|
||||
module*
|
||||
module+
|
||||
for-syntax
|
||||
provide)
|
||||
|
||||
(define-syntax stx
|
||||
(singleton-struct
|
||||
#:property prop:procedure
|
||||
(λ (stx)
|
||||
(raise-syntax-error 'stx "Illegal outside def" stx))
|
||||
#:methods gen:def-transformer
|
||||
[(define (def-transform _ stx)
|
||||
(syntax-parse stx
|
||||
#:literals (#%brackets)
|
||||
[(_def (#%brackets _stx x:id) . body:expr)
|
||||
(syntax/loc stx
|
||||
;; xxx this "let ()" should be remix-block
|
||||
(define-syntax x (let () . body)))]))]))
|
||||
|
||||
(provide stx)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
remix/num/gen0)
|
||||
(module+ test
|
||||
;; This introduces ≡ as a testing form
|
||||
;; XXX Maybe drop this and add a test macro like rackunit/chk
|
||||
(require remix/test0))
|
||||
|
||||
;; define is replaced with def
|
||||
|
@ -186,3 +187,5 @@
|
|||
{(f-rest-args 1) ≡ 42}
|
||||
{(f-rest-args 1 2 3) ≡ 42})
|
||||
|
||||
(require (for-syntax remix/stx0))
|
||||
(def [stx stx42] 42)
|
||||
|
|
Loading…
Reference in New Issue
Block a user