[regexp] simpler way to dispatch on 1st arg
This commit is contained in:
parent
f2c3b38fbb
commit
2b21f30aa7
|
@ -19,8 +19,6 @@
|
||||||
(define-syntax regexp-match!
|
(define-syntax regexp-match!
|
||||||
(syntax-parser
|
(syntax-parser
|
||||||
[(f pat-stx arg* ...)
|
[(f pat-stx arg* ...)
|
||||||
#:when (or (string? (syntax-e #'pat-stx))
|
|
||||||
(regexp? (syntax-e #'pat-stx)))
|
|
||||||
#:with num-groups (count-groups (format "~a" (syntax-e #'pat-stx)) #:src #'f)
|
#:with num-groups (count-groups (format "~a" (syntax-e #'pat-stx)) #:src #'f)
|
||||||
#:with ((index* . group-id*) ...)
|
#:with ((index* . group-id*) ...)
|
||||||
#`#,(for/list ([i (in-range (syntax-e #'num-groups))])
|
#`#,(for/list ([i (in-range (syntax-e #'num-groups))])
|
||||||
|
@ -37,7 +35,8 @@
|
||||||
(define-for-syntax (count-groups v #:src stx)
|
(define-for-syntax (count-groups v #:src stx)
|
||||||
(cond
|
(cond
|
||||||
[(string? v) (count-groups/string v #:src stx)]
|
[(string? v) (count-groups/string v #:src stx)]
|
||||||
[(regexp? v) (count-groups/regexp v #:src stx)]
|
;[(regexp? v) (count-groups/regexp v #:src stx)]
|
||||||
|
;[(pregexp? v) (count-groups/pregexp v #:src stx)]
|
||||||
[else (error 'regexp-match! "Internal error on input" v)]))
|
[else (error 'regexp-match! "Internal error on input" v)]))
|
||||||
|
|
||||||
;; Count the number of matched parentheses in a regexp pattern.
|
;; Count the number of matched parentheses in a regexp pattern.
|
||||||
|
@ -66,6 +65,9 @@
|
||||||
(define-for-syntax (count-groups/regexp rxp #:src stx)
|
(define-for-syntax (count-groups/regexp rxp #:src stx)
|
||||||
(error 'regexp-match! "Not implemented"))
|
(error 'regexp-match! "Not implemented"))
|
||||||
|
|
||||||
|
(define-for-syntax (count-groups/regexp pxp #:src stx)
|
||||||
|
(error 'regexp-match! "Not implemented"))
|
||||||
|
|
||||||
(define-for-syntax (group-error str reason)
|
(define-for-syntax (group-error str reason)
|
||||||
(raise-argument-error
|
(raise-argument-error
|
||||||
'regexp-match!
|
'regexp-match!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user