 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs calendar.english combinators
 combinators.smart io.encodings.utf8 io.files kernel math.parser
-memoize namespaces sequences sorting splitting unicode ;
+memoize namespaces sequences sequences.extras sorting splitting
+unicode ;
 IN: zoneinfo
 
 CONSTANT: zoneinfo-paths

GENERIC: zone-matches? ( string rule -- ? )

M: raw-rule zone-matches? name>> = ;
M: raw-zone zone-matches? name>> = ;
M: raw-link zone-matches? from>> = ;
M: raw-leap zone-matches? 2drop f ;

: find-rules ( string -- rules )
    raw-rule-map

        [ 3 tail harvest ]
    } cleave raw-zone boa ;

: parse-line ( seq -- tuple )
    dup first >lower
    {
        { "rule" [ parse-rule ] }
        { "link" [ parse-link ] }
        { "leap" [ parse-leap ] }
        { "zone" [ parse-zone dup last-zone set ] }
        [ drop harvest parse-partial-zone ]
    } case ;

