Regexp uses sequences:map-find now

db4
Daniel Ehrenberg 2009-03-03 12:41:50 -06:00
parent 177a895c09
commit a28a80abcf
2 changed files with 2 additions and 8 deletions

View File

@ -20,11 +20,6 @@ GENERIC: match-index-from ( i string matcher -- index/f )
dupd match-index-head
[ 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 )
i string length [a,b)
[ string matcher match-slice ] map-find drop ;
@ -40,7 +35,7 @@ GENERIC: match-index-from ( i string matcher -- index/f )
PRIVATE>
:: 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 )
all-matches length ;

View File

@ -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 ;
IN: regexp-tests
\ <regexp> must-infer
\ compile-regexp must-infer
\ compile-dfa-quot must-infer
\ matches? must-infer
[ f ] [ "b" "a*" <regexp> matches? ] unit-test