Merge pull request #1691 from jsmaniac/syntax-parse-regexp
Adds built-in syntax classes which match regular expressions
This commit is contained in:
parent
22a9b0cf35
commit
c618ec803a
|
@ -37,7 +37,9 @@ actually a valid expression.
|
|||
@defstxclass[integer]
|
||||
@defstxclass[exact-integer]
|
||||
@defstxclass[exact-nonnegative-integer]
|
||||
@defstxclass[exact-positive-integer])]{
|
||||
@defstxclass[exact-positive-integer]
|
||||
@defstxclass[regexp]
|
||||
@defstxclass[byte-regexp])]{
|
||||
|
||||
Match syntax satisfying the corresponding predicates.
|
||||
}
|
||||
|
@ -59,6 +61,7 @@ and bytes, respectively.
|
|||
@defstxclass[id]{ Alias for @racket[identifier]. }
|
||||
@defstxclass[nat]{ Alias for @racket[exact-nonnegative-integer]. }
|
||||
@defstxclass[str]{ Alias for @racket[string]. }
|
||||
@defstxclass[character]{ Alias for @racket[char]. }
|
||||
|
||||
@defstxclass[(static [predicate (-> any/c any/c)]
|
||||
[description (or/c string? #f)])]{
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
exact-integer
|
||||
exact-nonnegative-integer
|
||||
exact-positive-integer
|
||||
|
||||
|
||||
id
|
||||
nat
|
||||
char
|
||||
|
@ -38,6 +38,8 @@
|
|||
(define exact-integer-stx? (stxof exact-integer?))
|
||||
(define exact-nonnegative-integer-stx? (stxof exact-nonnegative-integer?))
|
||||
(define exact-positive-integer-stx? (stxof exact-positive-integer?))
|
||||
(define regexp-stx? (stxof regexp?))
|
||||
(define byte-regexp-stx? (stxof byte-regexp?))
|
||||
|
||||
|
||||
;; == Integrable syntax classes ==
|
||||
|
@ -59,10 +61,16 @@
|
|||
|
||||
(define-integrable-syntax-class -string (quote "string") string-stx?)
|
||||
(define-integrable-syntax-class -bytes (quote "bytes") bytes-stx?)
|
||||
(define-integrable-syntax-class -regexp (quote "regexp") regexp-stx?)
|
||||
(define-integrable-syntax-class -byte-regexp (quote "byte-regexp") byte-regexp-stx?)
|
||||
|
||||
;; Overloading the meaning of existing identifiers
|
||||
(begin-for-syntax
|
||||
(set-box! alt-stxclass-mapping
|
||||
(list (cons #'string (syntax-local-value #'-string))
|
||||
(cons #'bytes (syntax-local-value #'-bytes)))))
|
||||
(cons #'bytes (syntax-local-value #'-bytes))
|
||||
(cons #'regexp (syntax-local-value #'-regexp))
|
||||
(cons #'byte-regexp (syntax-local-value #'-byte-regexp)))))
|
||||
|
||||
;; Aliases
|
||||
(define-syntax id (make-rename-transformer #'identifier))
|
||||
|
|
Loading…
Reference in New Issue
Block a user