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
 | 
			
		||||
    [ 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 ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue