]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorDaniel Ehrenberg <littledan@Macintosh-122.local>
Thu, 12 Mar 2009 00:39:55 +0000 (19:39 -0500)
committerDaniel Ehrenberg <littledan@Macintosh-122.local>
Thu, 12 Mar 2009 00:39:55 +0000 (19:39 -0500)
18 files changed:
basis/delegate/delegate-tests.factor
basis/help/definitions/definitions-tests.factor
basis/inspector/inspector-tests.factor
basis/locals/locals-tests.factor
basis/macros/macros-tests.factor
basis/memoize/memoize-tests.factor
basis/opengl/textures/textures-tests.factor
basis/regexp/regexp-docs.factor
basis/regexp/regexp-tests.factor
basis/regexp/regexp.factor
basis/ui/gadgets/panes/panes-tests.factor
core/classes/singleton/singleton-tests.factor
core/classes/tuple/tuple-tests.factor
core/classes/union/union-tests.factor
core/generic/standard/standard-tests.factor
core/kernel/kernel-docs.factor
extra/descriptive/descriptive-tests.factor
extra/multi-methods/tests/syntax.factor

index e2bea82e6819fe7b7cb7d110c97c3c4d6d0d7f77..9bf07a5330a556dad88bbb3cb5ed8a65d333e187 100644 (file)
@@ -1,7 +1,7 @@
 USING: delegate kernel arrays tools.test words math definitions
 compiler.units parser generic prettyprint io.streams.string
 accessors eval multiline generic.standard delegate.protocols
-delegate.private assocs ;
+delegate.private assocs see ;
 IN: delegate.tests
 
 TUPLE: hello this that ;
index d95f6988a208f71392e7f4fa26e0b769d0944431..5d83afae8886d91bd3e8a483bd9eb7a3b84d64f9 100644 (file)
@@ -1,6 +1,6 @@
 USING: math definitions help.topics help tools.test
 prettyprint parser io.streams.string kernel source-files
-assocs namespaces words io sequences eval accessors ;
+assocs namespaces words io sequences eval accessors see ;
 IN: help.definitions.tests
 
 [ ] [ \ + >link see ] unit-test
index 4ce549ac83854e9ff6463d63084091e49807abc6..3f3e7f13dfa48bb5947bd88f66649e76633fd006 100644 (file)
@@ -8,7 +8,7 @@ f describe
 H{ } describe
 H{ } describe
 
-[ "fixnum instance\n" ] [ [ 3 describe ] with-string-writer ] unit-test
+[ "fixnum instance\n\n" ] [ [ 3 describe ] with-string-writer ] unit-test
 
 [ ] [ H{ } clone inspect ] unit-test
 
index 923f890adf373c7166085fb292a4230dced67f60..558fa78494bd1eb34143bc614092d78b54792955 100644 (file)
@@ -2,7 +2,7 @@ USING: locals math sequences tools.test hashtables words kernel
 namespaces arrays strings prettyprint io.streams.string parser
 accessors generic eval combinators combinators.short-circuit
 combinators.short-circuit.smart math.order math.functions
-definitions compiler.units fry lexer words.symbol ;
+definitions compiler.units fry lexer words.symbol see ;
 IN: locals.tests
 
 :: foo ( a b -- a a ) a a ;
index 7b061ab2f5c2c768f2982cf72da4ee0002540f75..7d93ce8a9ea4b83eb98ca66d1ca43819f77bc64d 100644 (file)
@@ -1,6 +1,6 @@
 IN: macros.tests
 USING: tools.test macros math kernel arrays
-vectors io.streams.string prettyprint parser eval ;
+vectors io.streams.string prettyprint parser eval see ;
 
 MACRO: see-test ( a b -- c ) + ;
 
index 168a0061e320ea9bd251c328814a1f00dfc349cc..54378bd37e9bb00f8b0f4cb056afb67520e47c97 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel memoize tools.test parser generalizations
-prettyprint io.streams.string sequences eval namespaces ;
+prettyprint io.streams.string sequences eval namespaces see ;
 IN: memoize.tests
 
 MEMO: fib ( m -- n )
index 45b1d8f7068522ec65385938f92509b97b1f3ed9..7141caa67d03adafb8ce356ade68f5ea25246f63 100644 (file)
@@ -5,15 +5,19 @@ images kernel namespaces ;
 IN: opengl.textures.tests
 
 [ ] [
-    { 3 5 }
-    RGB
-    B{
-        1 2 3 4 5 6 7 8 9
-        10 11 12 13 14 15 16 17 18
-        19 20 21 22 23 24 25 26 27
-        28 29 30 31 32 33 34 35 36
-        37 38 39 40 41 42 43 44 45
-    } image boa "image" set
+    T{ image
+       { dim { 3 5 } }
+       { component-order RGB }
+       { bitmap
+         B{
+             1 2 3 4 5 6 7 8 9
+             10 11 12 13 14 15 16 17 18
+             19 20 21 22 23 24 25 26 27
+             28 29 30 31 32 33 34 35 36
+             37 38 39 40 41 42 43 44 45
+         }
+       }
+    } "image" set
 ] unit-test
 
 [
index d31b185b2f5b508eb14a18ce1ffa6da9e780050a..adbeb341bb37272de2245f13d57e7247adb89d2f 100644 (file)
@@ -42,8 +42,8 @@ ARTICLE: { "regexp" "operations" } "Matching operations with regular expressions
 { $subsection matches? }
 { $subsection re-contains? }
 { $subsection first-match }
-{ $subsection all-matches }
-{ $subsection re-split1 }
+{ $subsection all-matching-slices }
+{ $subsection all-matching-subseqs }
 { $subsection re-split }
 { $subsection re-replace }
 { $subsection count-matches } ;
@@ -67,25 +67,21 @@ HELP: matches?
 { $values { "string" string } { "regexp" regexp } { "?" "a boolean" } }
 { $description "Tests if the string as a whole matches the given regular expression." } ;
 
-HELP: re-split1
-{ $values { "string" string } { "regexp" regexp } { "before" string } { "after/f" string } }
-{ $description "Searches the string for a substring which matches the pattern. If found, the input string is split on the leftmost and longest occurence of the match, and the two halves are given as output. If no match is found, then the input string and " { $link f } " are output." } ;
-
-HELP: all-matches
+HELP: all-matching-slices
 { $values { "string" string } { "regexp" regexp } { "seq" "a sequence of slices of the input" } }
 { $description "Finds a sequence of disjoint substrings which each match the pattern. It chooses this by finding the leftmost longest match, and then the leftmost longest match which starts after the end of the previous match, and so on." } ;
 
 HELP: count-matches
 { $values { "string" string } { "regexp" regexp } { "n" integer } }
-{ $description "Counts how many disjoint matches the regexp has in the string, as made unambiguous by " { $link all-matches } "." } ;
+{ $description "Counts how many disjoint matches the regexp has in the string, as made unambiguous by " { $link all-matching-slices } "." } ;
 
 HELP: re-split
 { $values { "string" string } { "regexp" regexp } { "seq" "a sequence of slices of the input" } }
-{ $description "Splits the input string into chunks separated by the regular expression. Each chunk contains no match of the regexp. The chunks are chosen by the strategy of " { $link all-matches } "." } ;
+{ $description "Splits the input string into chunks separated by the regular expression. Each chunk contains no match of the regexp. The chunks are chosen by the strategy of " { $link all-matching-slices } "." } ;
 
 HELP: re-replace
 { $values { "string" string } { "regexp" regexp } { "replacement" string } { "result" string } }
-{ $description "Replaces substrings which match the input regexp with the given replacement text. The boundaries of the substring are chosen by the strategy used by " { $link all-matches } "." } ;
+{ $description "Replaces substrings which match the input regexp with the given replacement text. The boundaries of the substring are chosen by the strategy used by " { $link all-matching-slices } "." } ;
 
 HELP: first-match
 { $values { "string" string } { "regexp" regexp } { "slice/f" "the match, if one exists" } }
index eedbcbbc4f0702e55e335ea4b74e9eea49f210c9..a449b3e2f0b0891bbaa01aecdf68cc1642d90784 100644 (file)
@@ -287,7 +287,7 @@ IN: regexp-tests
 [ { "a" "" } ] [ "a=" R/ =/ re-split [ >string ] map ] unit-test
 
 [ { "ABC" "DEF" "GHI" } ]
-[ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matches [ >string ] map ] unit-test
+[ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matching-subseqs ] unit-test
 
 [ 3 ]
 [ "1ABC2DEF3GHI4" R/ [A-Z]+/ count-matches ] unit-test
@@ -431,7 +431,7 @@ IN: regexp-tests
 [ f ] [ "a bar b" R/ foo/ re-contains? ] unit-test
 [ t ] [ "foo" R/ foo/ re-contains? ] unit-test
 
-[ { "foo" "fxx" "fab" } ] [ "fab fxx foo" R/ f../r all-matches [ >string ] map ] unit-test
+[ { "foo" "fxx" "fab" } ] [ "fab fxx foo" R/ f../r all-matching-subseqs ] unit-test
 
 [ t ] [ "foo" "\\bfoo\\b" <regexp> re-contains? ] unit-test
 [ t ] [ "afoob" "\\Bfoo\\B" <regexp> re-contains? ] unit-test
index a7f2fa4e12839d679e33b4e7c17fe4c3ec055f48..29f7e3e84e079bfe2e62d5430b3e7a498c75355f 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel math sequences strings sets
-assocs prettyprint.backend prettyprint.custom make lexer
-namespaces parser arrays fry locals regexp.parser splitting
-sorting regexp.ast regexp.negation regexp.compiler words
-call call.private math.ranges ;
+USING: accessors combinators kernel kernel.private math sequences
+sequences.private strings sets assocs prettyprint.backend
+prettyprint.custom make lexer namespaces parser arrays fry locals
+regexp.parser splitting sorting regexp.ast regexp.negation
+regexp.compiler words call call.private math.ranges ;
 IN: regexp
 
 TUPLE: regexp
@@ -44,93 +44,82 @@ M: reverse-regexp end/start drop length 1- -1 swap ;
 PRIVATE>
 
 : matches? ( string regexp -- ? )
-    [ end/start ] 2keep
     [ check-string ] dip
+    [ end/start ] 2keep
     match-index-from
-    [ swap = ] [ drop f ] if* ;
+    [ = ] [ drop f ] if* ;
 
 <PRIVATE
 
-TUPLE: match { i read-only } { j read-only } { seq read-only } ;
-
-: match-slice ( i string quot -- match/f )
-    [ 2dup ] dip call
-    [ swap match boa ] [ 2drop f ] if* ; inline
+:: (next-match) ( i string regexp quot: ( i string regexp -- j ) reverse? -- i start end ? )
+    i string regexp quot call dup [| j |
+        j i j
+        reverse? [ swap [ 1+ ] bi@ ] when
+        string
+    ] [ drop f f f f ] if ; inline
 
 : search-range ( i string reverse? -- seq )
-    [ drop 0 [a,b] ] [ length [a,b) ] if ; inline
-
-: match>result ( match reverse? -- i start end string )
-    over [
-        [ [ i>> ] [ j>> tuck ] [ seq>> ] tri ] dip
-        [ [ swap [ 1+ ] bi@ ] dip ] when
-    ] [ 2drop f f f f ] if ; inline
+    [ drop dup 1+ -1 ] [ length 1 ] if range boa ; inline
 
-:: next-match ( i string quot reverse? -- i start end string )
+:: next-match ( i string regexp quot: ( i string regexp -- j ) reverse? -- i start end ? )
+    f f f f
     i string reverse? search-range
-    [ string quot match-slice ] map-find drop
-    reverse? match>result ; inline
+    [ [ 2drop 2drop ] dip string regexp quot reverse? (next-match) dup ] find 2drop ; inline
 
-: do-next-match ( i string regexp -- i start end string )
+: do-next-match ( i string regexp -- i start end ? )
     dup next-match>>
-    execute-unsafe( i string regexp -- i start end string ) ;
+    execute-unsafe( i string regexp -- i start end ? ) ; inline
 
-: next-slice ( i string regexp -- i/f slice/f )
-    do-next-match
-    [ slice boa ] [ drop ] if* ; inline
+:: (each-match) ( i string regexp quot: ( start end string -- ) -- )
+    i string regexp do-next-match [| i' start end |
+        start end string quot call
+        i' string regexp quot (each-match)
+    ] [ 3drop ] if ; inline recursive
 
-PRIVATE>
+: prepare-match-iterator ( string regexp -- i string regexp )
+    [ check-string ] dip [ end/start nip ] 2keep ; inline
 
-TUPLE: match-iterator
-    { string read-only }
-    { regexp read-only }
-    { i read-only }
-    { value read-only } ;
+PRIVATE>
 
-: iterate ( iterator -- iterator'/f )
-    dup
-    [ i>> ] [ string>> ] [ regexp>> ] tri next-slice
-    [ [ [ string>> ] [ regexp>> ] bi ] 2dip match-iterator boa ]
-    [ 2drop f ] if* ;
+: each-match ( string regexp quot: ( start end string -- ) -- )
+    [ prepare-match-iterator ] dip (each-match) ; inline
 
-: value ( iterator/f -- value/f )
-    dup [ value>> ] when ;
+: map-matches ( string regexp quot: ( start end string -- obj ) -- seq )
+    accumulator [ each-match ] dip >array ; inline
 
-: <match-iterator> ( string regexp -- match-iterator )
-    [ check-string ] dip
-    2dup end/start nip f
-    match-iterator boa
-    iterate ; inline
+: all-matching-slices ( string regexp -- seq )
+    [ slice boa ] map-matches ;
 
-: all-matches ( string regexp -- seq )
-    <match-iterator> [ iterate ] follow [ value ] map ;
+: all-matching-subseqs ( string regexp -- seq )
+    [ subseq ] map-matches ;
 
 : count-matches ( string regexp -- n )
-    all-matches length ;
+    [ 0 ] 2dip [ 3drop 1+ ] each-match ;
 
 <PRIVATE
 
-:: split-slices ( string slices -- new-slices )
-    slices [ to>> ] map 0 prefix
-    slices [ from>> ] map string length suffix
-    [ string <slice> ] 2map ;
+:: (re-split) ( string regexp quot -- new-slices )
+    0 string regexp [| end start end' string |
+        end' ! leave it on the stack for the next iteration
+        end start string quot call
+    ] map-matches
+    ! Final chunk
+    swap string length string quot call suffix ; inline
 
 PRIVATE>
 
 : first-match ( string regexp -- slice/f )
-    <match-iterator> value ;
+    [ prepare-match-iterator do-next-match ] [ drop ] 2bi
+    '[ _ slice boa nip ] [ 3drop f ] if ;
 
 : re-contains? ( string regexp -- ? )
-    first-match >boolean ;
-
-: re-split1 ( string regexp -- before after/f )
-    dupd first-match [ 1array split-slices first2 ] [ f ] if* ;
+    prepare-match-iterator do-next-match [ 3drop ] dip >boolean ;
 
 : re-split ( string regexp -- seq )
-    dupd all-matches split-slices ;
+    [ slice boa ] (re-split) ;
 
 : re-replace ( string regexp replacement -- result )
-    [ re-split ] dip join ;
+    [ [ subseq ] (re-split) ] dip join ;
 
 <PRIVATE
 
@@ -162,8 +151,8 @@ DEFER: compile-next-match
 : compile-next-match ( regexp -- regexp )
     dup '[
         dup \ next-initial-word = [
-            drop _ [ compile-regexp dfa>> ] [ reverse-regexp? ] bi
-            '[ _ '[ _ _ execute ] _ next-match ]
+            drop _ [ compile-regexp dfa>> def>> ] [ reverse-regexp? ] bi
+            '[ { array-capacity string regexp } declare _ _ next-match ]
             (( i string regexp -- i start end string )) simple-define-temp
         ] when
     ] change-next-match ;
index e486bffd383f2f73be0244c2449411293fdae93a..2947ce242d14f451cc9517052482319762ca80e3 100644 (file)
@@ -2,7 +2,7 @@ USING: alien ui.gadgets.panes ui.gadgets namespaces
 kernel sequences io io.styles io.streams.string tools.test
 prettyprint definitions help help.syntax help.markup
 help.stylesheet splitting tools.test.ui models math summary
-inspector accessors help.topics ;
+inspector accessors help.topics see ;
 IN: ui.gadgets.panes.tests
 
 : #children "pane" get children>> length ;
index 10ddde75ae606bab3ece01d4ab69f883d0de1c86..d9011ad776b61710d371b83f9bc338df00fbbc57 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel classes.singleton tools.test prettyprint io.streams.string ;
+USING: kernel classes.singleton tools.test prettyprint io.streams.string see ;
 IN: classes.singleton.tests
 
 [ ] [ SINGLETON: bzzt ] unit-test
index d221d28da94bd70c2f73d46a5038d079f38cef0a..f27d24e39dfeb04daabf67e23d0e0c7e20940e40 100644 (file)
@@ -4,7 +4,7 @@ namespaces quotations sequences.private classes continuations
 generic.standard effects classes.tuple classes.tuple.private
 arrays vectors strings compiler.units accessors classes.algebra
 calendar prettyprint io.streams.string splitting summary
-columns math.order classes.private slots slots.private eval ;
+columns math.order classes.private slots slots.private eval see ;
 IN: classes.tuple.tests
 
 TUPLE: rect x y w h ;
index 97baf08874a754f43d3b95ab8e9c67a682c45698..0802c0a2d9d0d28d31b1dbdce6d8a17bd69d437d 100644 (file)
@@ -4,7 +4,7 @@ tools.test vectors words quotations classes
 classes.private classes.union classes.mixin classes.predicate
 classes.algebra vectors definitions source-files
 compiler.units kernel.private sorting vocabs io.streams.string
-eval ;
+eval see ;
 IN: classes.union.tests
 
 ! DEFER: bah
index 516d40893388d0ed662aac74bfbf7795e7eaf82b..2cd64ac9f4f7b06c06408c057fd83db4f7472a7d 100644 (file)
@@ -5,7 +5,7 @@ specialized-arrays.double byte-arrays bit-arrays parser
 namespaces make quotations stack-checker vectors growable
 hashtables sbufs prettyprint byte-vectors bit-vectors
 specialized-vectors.double definitions generic sets graphs assocs
-grouping ;
+grouping see ;
 
 GENERIC: lo-tag-test ( obj -- obj' )
 
index 9c5d6f56ea22a4642683575dd715dba38e0afaed..c178573a0a4d9390d78f343989800df26a01e05d 100644 (file)
@@ -684,7 +684,7 @@ $nl
 "This operation is efficient and does not copy the quotation." }
 { $examples
     { $example "USING: kernel prettyprint ;" "5 [ . ] curry ." "[ 5 . ]" }
-    { $example "USING: kernel prettyprint ;" "\\ = [ see ] curry ." "[ \\ = see ]" }
+    { $example "USING: kernel prettyprint see ;" "\\ = [ see ] curry ." "[ \\ = see ]" }
     { $example "USING: kernel math prettyprint sequences ;" "{ 1 2 3 } 2 [ - ] curry map ." "{ -1 0 1 }" }
 } ;
 
index 1582ca895d0a9255573d79418b6b5a8df6be3c5c..755c57cedaee74534efdc1ceeb600fa2ee3b617d 100755 (executable)
@@ -1,4 +1,4 @@
-USING: descriptive kernel math tools.test continuations prettyprint io.streams.string ;\r
+USING: descriptive kernel math tools.test continuations prettyprint io.streams.string see ;\r
 IN: descriptive.tests\r
 \r
 DESCRIPTIVE: divide ( num denom -- fraction ) / ;\r
index 597a1cebebd636980f5181949b114e42a1a175a1..9d9c80b21416ea976e98e0e6bda5da0c39c4c7b1 100644 (file)
@@ -1,7 +1,7 @@
 IN: multi-methods.tests
 USING: multi-methods tools.test math sequences namespaces system
 kernel strings definitions prettyprint debugger arrays
-hashtables continuations classes assocs accessors ;
+hashtables continuations classes assocs accessors see ;
 
 GENERIC: first-test