]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/tools/scaffold/scaffold.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / tools / scaffold / scaffold.factor
index 6a705e63ac46d0f163e6c031b8ec7007ae913193..7cf5b1471715e77026ee4e6d52473fc30c7b3bb6 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien arrays assocs calendar classes
-combinators combinators.short-circuit fry hashtables interpolate
-io io.directories io.encodings.utf8 io.files io.pathnames
-io.streams.string kernel math math.parser namespaces prettyprint
-quotations sequences sets sorting splitting strings system
-timers unicode.categories urls vocabs vocabs.loader
-vocabs.metadata words words.symbol ;
+USING: accessors alien arrays assocs byte-arrays calendar
+classes combinators combinators.short-circuit fry hashtables
+help.markup interpolate io io.directories io.encodings.utf8
+io.files io.pathnames io.streams.string kernel math math.parser
+namespaces prettyprint quotations sequences sets sorting
+splitting strings system timers unicode.categories urls vocabs
+vocabs.loader vocabs.metadata words words.symbol ;
 FROM: sets => members ;
 IN: tools.scaffold
 
@@ -115,9 +115,11 @@ ERROR: vocab-name-contains-dot path ;
     ] if* ;
 
 : lookup-type ( string -- object/string ? )
+    "/f" ?tail swap
     "new" ?head drop [ { [ CHAR: ' = ] [ digit? ] } 1|| ] trim-tail
     H{
-        { "object" object } { "obj" object }
+        { "object" object }
+        { "obj" object }
         { "quot" quotation }
         { "string" string }
         { "str" string }
@@ -127,12 +129,14 @@ ERROR: vocab-name-contains-dot path ;
         { "ch" "a character" }
         { "word" word }
         { "array" array }
-        { "timers" timer }
+        { "byte-array" byte-array }
+        { "timer" timer }
         { "duration" duration }
         { "path" "a pathname string" }
         { "vocab" "a vocabulary specifier" }
         { "vocab-root" "a vocabulary root string" }
         { "c-ptr" c-ptr }
+        { "sequence" sequence }
         { "seq" sequence }
         { "exemplar" object }
         { "assoc" assoc }
@@ -140,9 +144,15 @@ ERROR: vocab-name-contains-dot path ;
         { "keys" sequence } { "values" sequence }
         { "class" class } { "tuple" tuple }
         { "url" url }
-    } at* ;
+    } at* [ swap [ \ $maybe swap 2array ] when ] dip ;
 
-: add-using ( object -- )
+GENERIC: add-using ( object -- )
+
+M: array add-using [ add-using ] each ;
+
+M: string add-using drop ;
+
+M: object add-using ( object -- )
     vocabulary>> using get [ adjoin ] [ drop ] if* ;
 
 : 4bl ( -- )
@@ -156,7 +166,7 @@ ERROR: vocab-name-contains-dot path ;
             dup array? [ first ] when
             dup lookup-type [
                 [ unparse write bl ]
-                [ [ pprint ] [ dup string? [ drop ] [ add-using ] if ] bi ] bi*
+                [ [ pprint ] [ add-using ] bi ] bi*
             ] [
                 drop unparse write bl null pprint
                 null add-using
@@ -206,7 +216,7 @@ ERROR: vocab-name-contains-dot path ;
 
 : interesting-words ( vocab -- array )
     words
-    [ { [ "help" word-prop ] [ predicate? ] } 1|| not ] filter
+    [ { [ "help" word-prop ] [ predicate? ] } 1|| ] reject
     natural-sort ;
 
 : interesting-words. ( vocab -- )