]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/txon/txon.factor
core: subseq-index? -> subseq-of?
[factor.git] / extra / txon / txon.factor
index 2575d4bb614ca8bab98edb1ec1debe2a6afbe12c..0e826b216536ff5a3e8c9c933ddc717bda504d3a 100644 (file)
@@ -3,7 +3,7 @@
 
 USING: assocs combinators combinators.short-circuit formatting
 grouping hashtables io kernel make math math.parser sequences
-splitting strings unicode.categories ;
+splitting strings unicode ;
 
 IN: txon
 
@@ -27,26 +27,26 @@ IN: txon
 DEFER: name/values
 
 : (parse-value) ( string -- values )
-    decode-value string-lines
+    decode-value split-lines
     [ "" ] [ dup length 1 = [ first ] when ] if-empty ;
 
 : parse-value ( string -- remain value )
     dup find-` [
         dup 1 - pick ?nth CHAR: : =
         [ drop name/values ] [ cut swap (parse-value) ] if
-        [ rest [ blank? ] trim-head ] dip
+        [ rest [ unicode:blank? ] trim-head ] dip
     ] [ f swap ] if* ;
 
 : (name=value) ( string -- remain term )
     parse-name [ parse-value ] dip associate ;
 
 : name=value ( string -- remain term )
-    [ blank? ] trim
-    ":`" over subseq? [ (name=value) ] [ f swap ] if ;
+    [ unicode:blank? ] trim
+    dup ":`" subseq-of? [ (name=value) ] [ f swap ] if ;
 
 : name/values ( string -- remain terms )
     [ dup { [ empty? not ] [ first CHAR: ` = not ] } 1&& ]
-    [ name=value ] produce assoc-combine ;
+    [ name=value ] produce assoc-union-all ;
 
 : parse-txon ( string -- objects )
     [ dup empty? not ] [ name=value ] produce nip ;
@@ -66,12 +66,12 @@ PRIVATE>
 GENERIC: >txon ( object -- string )
 
 M: sequence >txon
-    [ >txon ] map "\n" join ;
+    [ >txon ] map join-lines ;
 
 M: assoc >txon
     >alist [
         first2 [ encode-value ] [ >txon ] bi* "%s:`%s`" sprintf
-    ] map "\n" join ;
+    ] map join-lines ;
 
 M: string >txon
     encode-value ;