]> gitweb.factorcode.org Git - factor.git/commitdiff
lists: simplify parse-list-literal to fix bootstrap issue.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 23 Feb 2020 04:37:10 +0000 (20:37 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 23 Feb 2020 04:37:10 +0000 (20:37 -0800)
basis/lists/lists.factor

index 0251f95c50cabcfdecefb79de46b6443c8e304cb..c47b0b3d26c4d5d178d2dc0dd8b3e6352a555f2a 100644 (file)
@@ -105,23 +105,28 @@ M: list >list ;
 
 M: sequence >list sequence>list ;
 
-: items>list ( seq -- cons-pair )
-    dup empty? [ drop +nil+ ] [
-        reverse unclip swap [ swap cons ] each
-    ] if ;
-
-:: (parse-list-literal) ( accum right-of-dot? -- accum )
-    accum scan-token {
-        { "}" [ +nil+ , ] }
-        { "." [ t (parse-list-literal) ] }
+<PRIVATE
+
+: items>list ( sequence -- list )
+    [ +nil+ ] [
+        <reversed> unclip-slice [ swons ] reduce
+    ] if-empty ;
+
+: (parse-list-literal) ( right-of-dot? -- )
+    scan-token {
+        { "}" [ drop +nil+ , ] }
+        { "." [ drop t (parse-list-literal) ] }
         [
             parse-datum dup parsing-word? [
                 V{ } clone swap execute-parsing first
             ] when
-            , right-of-dot? [ "}" expect ] [ f (parse-list-literal) ] if ]
+            , [ "}" expect ] [ f (parse-list-literal) ] if
+        ]
     } case ;
 
-: parse-list-literal ( accum -- accum object )
+: parse-list-literal ( -- list )
     [ f (parse-list-literal) ] { } make items>list ;
 
+PRIVATE>
+
 SYNTAX: L{ parse-list-literal suffix! ;