lists: simplify parse-list-literal to fix bootstrap issue.

flac
John Benediktsson 2020-02-22 20:37:10 -08:00 committed by Steve Ayerhart
parent d0bd59ad19
commit 75b1fbd6f4
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
1 changed files with 15 additions and 10 deletions

View File

@ -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! ;