lists: simplify parse-list-literal to fix bootstrap issue.
parent
d0bd59ad19
commit
75b1fbd6f4
|
@ -105,23 +105,28 @@ M: list >list ;
|
||||||
|
|
||||||
M: sequence >list sequence>list ;
|
M: sequence >list sequence>list ;
|
||||||
|
|
||||||
: items>list ( seq -- cons-pair )
|
<PRIVATE
|
||||||
dup empty? [ drop +nil+ ] [
|
|
||||||
reverse unclip swap [ swap cons ] each
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
:: (parse-list-literal) ( accum right-of-dot? -- accum )
|
: items>list ( sequence -- list )
|
||||||
accum scan-token {
|
[ +nil+ ] [
|
||||||
{ "}" [ +nil+ , ] }
|
<reversed> unclip-slice [ swons ] reduce
|
||||||
{ "." [ t (parse-list-literal) ] }
|
] if-empty ;
|
||||||
|
|
||||||
|
: (parse-list-literal) ( right-of-dot? -- )
|
||||||
|
scan-token {
|
||||||
|
{ "}" [ drop +nil+ , ] }
|
||||||
|
{ "." [ drop t (parse-list-literal) ] }
|
||||||
[
|
[
|
||||||
parse-datum dup parsing-word? [
|
parse-datum dup parsing-word? [
|
||||||
V{ } clone swap execute-parsing first
|
V{ } clone swap execute-parsing first
|
||||||
] when
|
] when
|
||||||
, right-of-dot? [ "}" expect ] [ f (parse-list-literal) ] if ]
|
, [ "}" expect ] [ f (parse-list-literal) ] if
|
||||||
|
]
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
: parse-list-literal ( accum -- accum object )
|
: parse-list-literal ( -- list )
|
||||||
[ f (parse-list-literal) ] { } make items>list ;
|
[ f (parse-list-literal) ] { } make items>list ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
SYNTAX: L{ parse-list-literal suffix! ;
|
SYNTAX: L{ parse-list-literal suffix! ;
|
||||||
|
|
Loading…
Reference in New Issue