]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/unicode/script/script.factor
factor: trim some using lists
[factor.git] / basis / unicode / script / script.factor
index 103beb4d2a0d1c24c5865d15ee94870366f2d506..7d7f7a6946868bfaa37f3325783af957207963df 100644 (file)
@@ -1,48 +1,8 @@
-USING: accessors values kernel sequences assocs io.files
-io.encodings ascii math.ranges io splitting math.parser 
-namespaces make byte-arrays locals math sets io.encodings.ascii
-words compiler.units arrays interval-maps unicode.data ;
+! Copyright (C) 2008 Daniel Ehrenberg.
+! See http://factorcode.org/license.txt for BSD license.
+USING: literals simple-flat-file ;
 IN: unicode.script
 
-<PRIVATE
-VALUE: script-table
-SYMBOL: interned
-
-: parse-script ( stream -- assoc )
-    ! assoc is code point/range => name
-    lines filter-comments [ split-; ] map ;
-
-: range, ( value key -- )
-    swap interned get
-    [ name>> = ] with find nip 2array , ;
-
-: expand-ranges ( assoc -- interval-map )
-    [
-        [
-            CHAR: . pick member? [
-                swap ".." split1 [ hex> ] bi@ 2array
-            ] [ swap hex> ] if range,
-        ] assoc-each
-    ] { } make <interval-map> ;
-
-: >symbols ( strings -- symbols )
-    [
-        [ "unicode.script" create dup define-symbol ] map
-    ] with-compilation-unit ;
-
-: process-script ( ranges -- )
-    dup values prune >symbols interned [
-        expand-ranges to: script-table
-    ] with-variable ;
-
-: load-script ( -- )
-    "resource:basis/unicode/script/Scripts.txt"
-    ascii <file-reader> parse-script process-script ;
-
-load-script
-PRIVATE>
-
-SYMBOL: Unknown
-
-: script-of ( char -- script )
-    script-table interval-at [ Unknown ] unless* ;
+CONSTANT: script-table $[
+    "vocab:unicode/UCD/Scripts.txt" load-interval-file
+]