Fixed issue with λ/syntax-parse, now we can use stx in the body to refer to the whole syntax object.
This commit is contained in:
parent
6d88845985
commit
a0187b5136
|
@ -1,7 +1,8 @@
|
||||||
#lang typed/racket
|
#lang typed/racket
|
||||||
(require "typed-untyped.rkt")
|
(require "typed-untyped.rkt")
|
||||||
(define-typed/untyped-modules #:no-test
|
(define-typed/untyped-modules #:no-test
|
||||||
(provide define-syntax/parse
|
(provide stx
|
||||||
|
define-syntax/parse
|
||||||
λ/syntax-parse
|
λ/syntax-parse
|
||||||
~maybe
|
~maybe
|
||||||
~lit
|
~lit
|
||||||
|
@ -15,8 +16,10 @@
|
||||||
(require syntax/parse
|
(require syntax/parse
|
||||||
syntax/parse/define
|
syntax/parse/define
|
||||||
syntax/parse/experimental/template
|
syntax/parse/experimental/template
|
||||||
(for-syntax racket/base
|
(for-syntax racket/syntax
|
||||||
racket/syntax))
|
racket/stxparam)
|
||||||
|
(for-meta 2 racket/base)
|
||||||
|
racket/stxparam)
|
||||||
|
|
||||||
(define-syntax ~maybe
|
(define-syntax ~maybe
|
||||||
(pattern-expander
|
(pattern-expander
|
||||||
|
@ -51,29 +54,32 @@
|
||||||
#`(#,(s #'~and) name (#,(s #'~seq) (#,(s #'~literal) lit)))
|
#`(#,(s #'~and) name (#,(s #'~seq) (#,(s #'~literal) lit)))
|
||||||
#`(#,(s #'~seq) (#,(s #'~literal) lit)))]))))
|
#`(#,(s #'~seq) (#,(s #'~literal) lit)))]))))
|
||||||
|
|
||||||
(begin-for-syntax
|
(module m-stx-identifier racket
|
||||||
(require (for-syntax racket/base
|
(require racket/stxparam)
|
||||||
racket/stxparam)
|
|
||||||
racket/stxparam)
|
|
||||||
|
|
||||||
(provide stx)
|
(provide stx)
|
||||||
|
|
||||||
(define-syntax-parameter stx
|
(define-syntax-parameter stx
|
||||||
(lambda (stx)
|
(lambda (call-stx)
|
||||||
(raise-syntax-error (syntax-e stx)
|
(raise-syntax-error
|
||||||
"Can only be used in define-syntax/parse"))))
|
(syntax-e call-stx)
|
||||||
|
"Can only be used in define-syntax/parse or λ/syntax-parse"
|
||||||
|
call-stx))))
|
||||||
|
|
||||||
|
(require 'm-stx-identifier
|
||||||
|
(for-syntax 'm-stx-identifier))
|
||||||
|
|
||||||
(define-simple-macro (define-syntax/parse (name . args) body0 . body)
|
(define-simple-macro (define-syntax/parse (name . args) body0 . body)
|
||||||
(define-syntax (name stx2)
|
(define-syntax (name stx2)
|
||||||
(syntax-parameterize ([stx (make-rename-transformer #'stx2)])
|
(syntax-parameterize ([stx (make-rename-transformer #'stx2)])
|
||||||
(syntax-parse stx2
|
(syntax-parse stx2
|
||||||
[(_ . args) body0 . body]))))
|
[(_ . args) body0 . body]))))
|
||||||
|
|
||||||
(define-simple-macro (λ/syntax-parse args . body)
|
(define-simple-macro (λ/syntax-parse args . body)
|
||||||
(λ (stx2)
|
(λ (stx2)
|
||||||
;(syntax-parameterize ([stx (make-rename-transformer #'stx2)])
|
(syntax-parameterize ([stx (make-rename-transformer #'stx2)])
|
||||||
(syntax-parse stx2
|
(syntax-parse stx2
|
||||||
[args . body])))
|
[args . body]))))
|
||||||
|
|
||||||
;; λstx
|
;; λstx
|
||||||
(begin
|
(begin
|
||||||
|
|
Loading…
Reference in New Issue
Block a user