]> gitweb.factorcode.org Git - factor.git/commitdiff
linked-assocs: give linked-hash "LH{ }" literal pprint.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 4 Nov 2015 16:36:24 +0000 (08:36 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 4 Nov 2015 16:36:24 +0000 (08:36 -0800)
basis/linked-assocs/linked-assocs.factor

index 3d3ce4942d553ffdb78941217ff522966f696ff3..8d06d393664e5fa476ff418f2afc4512cdce2a27 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov, James Cash.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs classes deques dlists fry kernel
-sequences sequences.private ;
+USING: accessors arrays assocs classes deques dlists fry
+hashtables kernel parser prettyprint.backend prettyprint.custom
+sequences.private ;
 IN: linked-assocs
 
 TUPLE: linked-assoc { assoc read-only } { dlist dlist read-only } ;
@@ -60,3 +61,16 @@ M: linked-assoc assoc-like
 
 M: linked-assoc equal?
     over linked-assoc? [ [ dlist>> ] bi@ = ] [ 2drop f ] if ;
+
+SYNTAX: LH{ \ } [ check-hashtable >linked-hash ] parse-literal ;
+
+PREDICATE: linked-hash < linked-assoc assoc>> hashtable? ;
+
+M: linked-hash pprint-delims drop \ LH{ \ } ;
+
+M: linked-hash >pprint-sequence >alist ;
+
+M: linked-hash pprint-narrow? drop t ;
+
+M: linked-hash pprint*
+    [ pprint-object ] with-extra-nesting-level ;