]> gitweb.factorcode.org Git - factor.git/commitdiff
core: Add TH{ for making assoc tuples.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 31 May 2017 01:14:29 +0000 (20:14 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 31 May 2017 01:14:29 +0000 (20:14 -0500)
See #1449.
https://github.com/factor/factor/issues/1449

core/bootstrap/syntax.factor
core/classes/tuple/parser/parser.factor
core/syntax/syntax.factor

index eccd30c4a1999c69da3c76356a22cfc3e56d4c32..f2fef33f7b8f21b4a4bc4d66944f69fdbad513e1 100644 (file)
@@ -48,6 +48,7 @@ IN: bootstrap.syntax
         "final"
         "SLOT:"
         "T{"
+        "TH{"
         "UNION:"
         "INTERSECTION:"
         "USE:"
index 202214770b7cdfeff4c00380fddd589fac0b1ea3..90a34ae860433ecb138ee223d270ee6df62527c5 100644 (file)
@@ -115,5 +115,15 @@ M: tuple-class boa>object
         [ bad-literal-tuple ]
     } case ;
 
+: parse-tuple-hash-literal-slots ( class slots -- tuple )
+    scan-token {
+        { "{" [ 2dup parse-slot-values assoc>object ] }
+        { "}" [ drop new ] }
+        [ bad-literal-tuple ]
+    } case ;
+
 : parse-tuple-literal ( -- tuple )
     scan-word dup all-slots parse-tuple-literal-slots ;
+
+: parse-tuple-hash-literal ( -- tuple )
+    scan-word dup all-slots parse-tuple-hash-literal-slots ;
index a0908b704040445add2934b36ed1c1435416a9dc..bd5baa3c4005262c86bbf4fcdfdfda3a46a945ab 100644 (file)
@@ -105,6 +105,7 @@ IN: bootstrap.syntax
     "BV{" [ \ } [ >byte-vector ] parse-literal ] define-core-syntax
     "H{" [ \ } [ parse-hashtable ] parse-literal ] define-core-syntax
     "T{" [ parse-tuple-literal suffix! ] define-core-syntax
+    "TH{" [ parse-tuple-hash-literal suffix! ] define-core-syntax
     "W{" [ \ } [ first <wrapper> ] parse-literal ] define-core-syntax
     "HS{" [ \ } [ >hash-set ] parse-literal ] define-core-syntax