Regexp uses sequences:map-find now
parent
177a895c09
commit
a28a80abcf
|
@ -20,11 +20,6 @@ GENERIC: match-index-from ( i string matcher -- index/f )
|
||||||
dupd match-index-head
|
dupd match-index-head
|
||||||
[ swap length = ] [ drop f ] if* ;
|
[ swap length = ] [ drop f ] if* ;
|
||||||
|
|
||||||
: map-find ( seq quot -- result elt )
|
|
||||||
[ f ] 2dip
|
|
||||||
'[ nip @ dup ] find
|
|
||||||
[ [ drop f ] unless ] dip ; inline
|
|
||||||
|
|
||||||
:: match-from ( i string matcher -- slice/f )
|
:: match-from ( i string matcher -- slice/f )
|
||||||
i string length [a,b)
|
i string length [a,b)
|
||||||
[ string matcher match-slice ] map-find drop ;
|
[ string matcher match-slice ] map-find drop ;
|
||||||
|
@ -40,7 +35,7 @@ GENERIC: match-index-from ( i string matcher -- index/f )
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
:: all-matches ( string matcher -- seq )
|
:: all-matches ( string matcher -- seq )
|
||||||
0 [ dup ] [ string matcher next-match ] [ ] produce nip but-last ;
|
0 [ dup ] [ string matcher next-match ] produce nip but-last ;
|
||||||
|
|
||||||
: count-matches ( string matcher -- n )
|
: count-matches ( string matcher -- n )
|
||||||
all-matches length ;
|
all-matches length ;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
USING: regexp tools.test kernel sequences regexp.parser
|
USING: regexp tools.test kernel sequences regexp.parser regexp.private
|
||||||
regexp.traversal eval strings multiline accessors regexp.matchers ;
|
regexp.traversal eval strings multiline accessors regexp.matchers ;
|
||||||
IN: regexp-tests
|
IN: regexp-tests
|
||||||
|
|
||||||
\ <regexp> must-infer
|
\ <regexp> must-infer
|
||||||
\ compile-regexp must-infer
|
\ compile-regexp must-infer
|
||||||
\ compile-dfa-quot must-infer
|
|
||||||
\ matches? must-infer
|
\ matches? must-infer
|
||||||
|
|
||||||
[ f ] [ "b" "a*" <regexp> matches? ] unit-test
|
[ f ] [ "b" "a*" <regexp> matches? ] unit-test
|
||||||
|
|
Loading…
Reference in New Issue