regexps return a slice instead of a range now

db4
Doug Coleman 2008-11-22 17:30:16 -06:00
parent e110bac51a
commit 09969a5fc2
2 changed files with 7 additions and 4 deletions

View File

@ -33,9 +33,9 @@ IN: regexp
: matches? ( string regexp -- ? )
dupd match
[ [ length ] [ length>> 1- ] bi* = ] [ drop f ] if* ;
[ [ length ] bi@ = ] [ drop f ] if* ;
: match-head ( string regexp -- end/f ) match [ length>> 1- ] [ f ] if* ;
: match-head ( string regexp -- end/f ) match [ length ] [ f ] if* ;
: match-at ( string m regexp -- n/f finished? )
[

View File

@ -144,7 +144,10 @@ M: capture-group-off flag-action ( dfa-traverser flag -- )
[ increment-state do-match ] when*
] unless ;
: return-match ( dfa-traverser -- interval/f )
: return-match ( dfa-traverser -- slice/f )
dup matches>>
[ drop f ]
[ [ start-index>> ] [ peek ] bi* 1 <range> ] if-empty ;
[
[ [ text>> ] [ start-index>> ] bi ]
[ peek ] bi* rot <slice>
] if-empty ;