commit 1ee830a59ef515eaa29988d899414c771913e7bd
parent 9db3ca62f835f76ccc818a55d7d8266d06f13dc9
Author: Georges Dupéron <georges.duperon@gmail.com>
Date: Mon, 23 Jan 2017 19:09:45 +0100
Fallback for v6.3 which lacks scribble/example
Diffstat:
2 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/info.rkt b/info.rkt
@@ -1,7 +1,9 @@
#lang info
(define collection "stxparse-info")
(define deps '("base"
- "rackunit-lib"))
+ "rackunit-lib"
+ ;; Because scribble/example is not available on v6.3:
+ "version-case"))
(define build-deps '("scribble-lib" "racket-doc"))
(define scribblings '(("scribblings/stxparse-info.scrbl" ())))
(define pkg-desc "Description Here")
diff --git a/scribblings/stxparse-info.scrbl b/scribblings/stxparse-info.scrbl
@@ -3,9 +3,15 @@
stxparse-info/current-pvars
racket/syntax
racket/base]
- scribble/example]
+ version-case
+ @for-syntax[racket/base]]
-@(define ev ((make-eval-factory '(racket))))
+@(version-case
+ [(version< (version) "6.4")
+ ]
+ [else
+ (require scribble/example)
+ (define ev ((make-eval-factory '(racket))))])
@title{stxparse-info : tracking bound syntax pattern variables with
@racketmodname[syntax/parse]}
@@ -60,15 +66,15 @@ know which syntax pattern variables are within scope.
(let-syntax ([v₁ (make-syntax-mapping depth (quote-syntax valvar))]
[v₂ (make-syntax-mapping depth (quote-syntax valvar))])
(with-pvars (v₁ v₂)
- code))]
+ code))]
instead of:
@racketblock[
(with-pvars (v₁ v₂)
- (let-syntax ([v₁ (make-syntax-mapping depth (quote-syntax valvar))]
- [v₂ (make-syntax-mapping depth (quote-syntax valvar))])
- code))]}
+ (let-syntax ([v₁ (make-syntax-mapping depth (quote-syntax valvar))]
+ [v₂ (make-syntax-mapping depth (quote-syntax valvar))])
+ code))]}
@defform[(define-pvars (pvar ...))
#:contracts ([pvar identifier?])]{
@@ -84,20 +90,37 @@ know which syntax pattern variables are within scope.
@racket[define/syntax-parse] or @racket[define/with-syntax], and have them
record the syntax pattern variables which they bind.
- @examples[#:eval ev
- #:hidden
- (require stxparse-info/parse
- stxparse-info/current-pvars
- racket/syntax
- (for-syntax racket/base))]
+ @(version-case
+ [(version< (version) "6.4")
+ @RACKETBLOCK[
+ (let ()
+ (code:comment "Alternate version of define/syntax-parse which")
+ (code:comment "contains (define-pvars (x)) in its expanded form.")
+ (define/syntax-parse x #'1)
+ (define/syntax-parse y #'2)
+ (define-syntax (get-pvars stx)
+ #`'#,(current-pvars))
+ (get-pvars))
+ (code:comment "=> '(y x)")]]
+ [else
+ @examples[
+ #:eval ev
+ #:hidden
+ (require stxparse-info/parse
+ stxparse-info/current-pvars
+ racket/syntax
+ (for-syntax racket/base))]
- @examples[#:eval ev
- #:escape UNSYNTAX
- (let ()
- (code:comment "Alternate version of define/syntax-parse which")
- (code:comment "contains (define-pvars (x)) in its expanded form.")
- (define/syntax-parse x #'1)
- (define/syntax-parse y #'2)
- (define-syntax (get-pvars stx)
- #`'#,(current-pvars))
- (get-pvars))]}
-\ No newline at end of file
+ @examples[
+ #:eval ev
+ #:escape UNSYNTAX
+ (eval:check
+ (let ()
+ (code:comment "Alternate version of define/syntax-parse which")
+ (code:comment "contains (define-pvars (x)) in its expanded form.")
+ (define/syntax-parse x #'1)
+ (define/syntax-parse y #'2)
+ (define-syntax (get-pvars stx)
+ #`'#,(current-pvars))
+ (get-pvars))
+ '(y x))]])}
+\ No newline at end of file