syntax/parse: syntax-parse sets current-syntax-context
This commit is contained in:
parent
281df3221e
commit
883e9e9e6b
|
@ -8,6 +8,7 @@
|
|||
"rep.rkt"
|
||||
"kws.rkt"
|
||||
"txlift.rkt")
|
||||
racket/syntax
|
||||
racket/stxparam
|
||||
syntax/stx
|
||||
unstable/struct
|
||||
|
@ -242,9 +243,10 @@ Conventions:
|
|||
[es null]
|
||||
[cx x]
|
||||
[fh0 (syntax-patterns-fail ctx0)])
|
||||
(with ([fail-handler fh0]
|
||||
[cut-prompt fh0])
|
||||
(try alternative ...)))))))]))
|
||||
(parameterize ((current-syntax-context ctx0))
|
||||
(with ([fail-handler fh0]
|
||||
[cut-prompt fh0])
|
||||
(try alternative ...))))))))]))
|
||||
|
||||
;; ----
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
racket/syntax
|
||||
"rep-data.rkt"
|
||||
"rep.rkt")
|
||||
racket/syntax
|
||||
"parse.rkt"
|
||||
"keywords.rkt"
|
||||
"runtime.rkt"
|
||||
|
@ -163,14 +164,15 @@
|
|||
[(def ...) defs]
|
||||
[expr expr])
|
||||
#'(defattrs/unpack (a ...)
|
||||
(let* ([x expr]
|
||||
(let* ([x (datum->syntax #f expr)]
|
||||
[cx x]
|
||||
[pr (ps-empty x x)]
|
||||
[es null]
|
||||
[fh0 (syntax-patterns-fail x)])
|
||||
def ...
|
||||
(#%expression
|
||||
(with ([fail-handler fh0]
|
||||
[cut-prompt fh0])
|
||||
(parse:S x cx pattern pr es
|
||||
(list (attribute name) ...)))))))))]))
|
||||
(parameterize ((current-syntax-context x))
|
||||
def ...
|
||||
(#%expression
|
||||
(with ([fail-handler fh0]
|
||||
[cut-prompt fh0])
|
||||
(parse:S x cx pattern pr es
|
||||
(list (attribute name) ...))))))))))]))
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
scribble/struct
|
||||
scribble/decode
|
||||
scribble/eval
|
||||
"parse-common.rkt")
|
||||
"parse-common.rkt"
|
||||
(for-label racket/syntax))
|
||||
|
||||
@title{Parsing Syntax}
|
||||
|
||||
|
@ -58,7 +59,9 @@ The following options are supported:
|
|||
#:contracts ([context-expr syntax?])]{
|
||||
|
||||
When present, @racket[context-expr] is used in reporting parse
|
||||
failures; otherwise @racket[stx-expr] is used.
|
||||
failures; otherwise @racket[stx-expr] is used. The
|
||||
@racket[current-syntax-context] parameter is also set to the value of
|
||||
@racket[context-expr].
|
||||
|
||||
@(myexamples
|
||||
(syntax-parse #'(a b 3)
|
||||
|
|
Loading…
Reference in New Issue
Block a user