]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/tr/tr.factor
basis: use lint.vocabs tool to trim using lists
[factor.git] / basis / tr / tr.factor
index 66c0276055d460bc94242032f00289082e6f30b7..8244a26da62552ae2214aa52e5e7dcbed188d57c 100644 (file)
@@ -1,7 +1,7 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: byte-arrays strings sequences sequences.private ascii
-fry kernel words parser lexer assocs math math.order summary ;
+USING: ascii assocs byte-arrays fry hints kernel lexer math
+parser sequences sequences.private strings summary words ;
 IN: tr
 
 ERROR: bad-tr ;
@@ -17,33 +17,32 @@ M: bad-tr summary
     [ [ ascii? ] all? ] both? [ bad-tr ] unless ;
 
 : compute-tr ( quot from to -- mapping )
-    [ 128 ] 3dip zip
+    [ 128 <iota> ] 3dip zip
     '[ [ _ call( x -- y ) _ at ] keep or ] B{ } map-as ; inline
 
 : tr-hints ( word -- )
-    { { byte-array } { string } } "specializer" set-word-prop ;
+    { { byte-array } { string } } set-specializer ;
 
 : create-tr ( token -- word )
-    create-in dup tr-hints ;
+    create-word-in dup tr-hints ;
 
 : tr-quot ( mapping -- quot )
     '[ [ dup ascii? [ _ tr-nth ] when ] map ] ;
 
 : define-tr ( word mapping -- )
-    tr-quot (( seq -- translated )) define-declared ;
+    tr-quot ( seq -- translated ) define-declared ;
 
 : fast-tr-quot ( mapping -- quot )
-    '[ [ _ tr-nth ] change-each ] ;
+    '[ [ _ tr-nth ] map! drop ] ;
 
 : define-fast-tr ( word mapping -- )
-    fast-tr-quot (( seq -- )) define-declared ;
+    fast-tr-quot ( seq -- ) define-declared ;
 
 PRIVATE>
 
-: TR:
-    scan parse-definition
+SYNTAX: TR:
+    scan-token parse-definition
     unclip-last [ unclip-last ] dip compute-tr
     [ check-tr ]
     [ [ create-tr ] dip define-tr ]
     [ [ "-fast" append create-tr ] dip define-fast-tr ] 2tri ;
-    parsing