! Copyright (C) 2011 John Benediktsson ! See http://factorcode.org/license.txt for BSD license USING: assocs combinators combinators.short-circuit formatting grouping hashtables io kernel make math math.parser sequences splitting strings unicode ; IN: txon : txon> ( string -- object ) parse-txon dup length 1 = [ first ] when ; GENERIC: >txon ( object -- string ) M: sequence >txon [ >txon ] map "\n" join ; M: assoc >txon >alist [ first2 [ encode-value ] [ >txon ] bi* "%s:`%s`" sprintf ] map "\n" join ; M: string >txon encode-value ; M: number >txon number>string >txon ;