diff --git a/basis/regexp/classes/classes.factor b/basis/regexp/classes/classes.factor index 0990ac786b..978be2c369 100644 --- a/basis/regexp/classes/classes.factor +++ b/basis/regexp/classes/classes.factor @@ -2,7 +2,6 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel math math.order words combinators locals ascii unicode.categories combinators.short-circuit sequences ; -QUALIFIED-WITH: multi-methods m IN: regexp.classes SINGLETONS: any-char any-char-no-nl @@ -116,46 +115,40 @@ TUPLE: not-class class ; TUPLE: and-class seq ; -m:GENERIC: combine-and ( class1 class2 -- combined ? ) +GENERIC: combine-and ( class1 class2 -- combined ? ) : replace-if-= ( object object -- object ? ) over = ; -m:METHOD: combine-and { object object } replace-if-= ; +M: object combine-and replace-if-= ; -m:METHOD: combine-and { integer integer } - 2dup = [ drop t ] [ 2drop f t ] if ; - -m:METHOD: combine-and { t object } - nip t ; - -m:METHOD: combine-and { f object } +M: t combine-and drop t ; -m:METHOD: combine-and { not-class object } - [ class>> ] dip = [ f t ] [ f f ] if ; - -m:METHOD: combine-and { integer object } - 2dup class-member? [ drop t ] [ 2drop f t ] if ; - -m:GENERIC: combine-or ( class1 class2 -- combined ? ) - -m:METHOD: combine-or { object object } replace-if-= ; - -m:METHOD: combine-or { integer integer } - 2dup = [ drop t ] [ 2drop f f ] if ; - -m:METHOD: combine-or { t object } - drop t ; - -m:METHOD: combine-or { f object } +M: f combine-and nip t ; -m:METHOD: combine-or { not-class object } - [ class>> ] dip = [ t t ] [ f f ] if ; +M: not-class combine-and + class>> = [ f t ] [ f f ] if ; -m:METHOD: combine-or { integer object } - 2dup class-member? [ nip t ] [ 2drop f f ] if ; +M: integer combine-and + swap 2dup class-member? [ drop t ] [ 2drop f t ] if ; + +GENERIC: combine-or ( class1 class2 -- combined ? ) + +M: object combine-or replace-if-= ; + +M: t combine-or + drop f ; + +M: f combine-or + drop t ; + +M: not-class combine-or + class>> = [ t t ] [ f f ] if ; + +M: integer combine-or + 2dup swap class-member? [ drop t ] [ 2drop f f ] if ; : try-combine ( elt1 elt2 quot -- combined/f ? ) 3dup call [ [ 3drop ] dip t ] [ drop swapd call ] if ; inline diff --git a/basis/regexp/minimize/minimize-tests.factor b/basis/regexp/minimize/minimize-tests.factor index 5781e74634..ece7c8fd7c 100644 --- a/basis/regexp/minimize/minimize-tests.factor +++ b/basis/regexp/minimize/minimize-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test regexp.minimize assocs regexp regexp.syntax +USING: tools.test regexp.minimize assocs regexp accessors regexp.transition-tables ; IN: regexp.minimize.tests diff --git a/basis/regexp/regexp-docs.factor b/basis/regexp/regexp-docs.factor index 4a77f14561..9d3d86fa13 100644 --- a/basis/regexp/regexp-docs.factor +++ b/basis/regexp/regexp-docs.factor @@ -39,15 +39,11 @@ ARTICLE: { "regexp" "theory" } "The theory of regular expressions" "The Factor regular expression engine was built with the design decision to support negation and intersection at the expense of backreferences. This lets us have a guaranteed linear-time matching algorithm. Systems like Ragel and Lex also use this algorithm, but in the Factor regular expression engine, all other features of regexps are still present." ; ARTICLE: { "regexp" "operations" } "Matching operations with regular expressions" -{ $subsection match } { $subsection matches? } -{ $subsection match-at } -{ $subsection match-range } -{ $subsection first-match } -{ $subsection re-cut } +{ $subsection match-slice } +{ $subsection re-split1 } { $subsection re-split } { $subsection re-replace } -{ $subsection next-match } { $subsection all-matches } { $subsection count-matches } { $subsection re-replace } ;