diff options
| author | Chouser <chouser@n01se.net> | 2015-02-07 10:01:31 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-02-21 13:22:44 -0500 |
| commit | 2e78e94eb894e511e583db03286a3c13b9ecc780 (patch) | |
| tree | e74193c142d3efd8486329458f7ed639943afc19 /forth/printer.fs | |
| parent | 168fb5dc56fee6653816ee8236259940e575c7ec (diff) | |
| download | mal-2e78e94eb894e511e583db03286a3c13b9ecc780.tar.gz mal-2e78e94eb894e511e583db03286a3c13b9ecc780.zip | |
forth: Finished step 1
Diffstat (limited to 'forth/printer.fs')
| -rw-r--r-- | forth/printer.fs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/forth/printer.fs b/forth/printer.fs index 243780a..1244c08 100644 --- a/forth/printer.fs +++ b/forth/printer.fs @@ -70,17 +70,18 @@ MalNil drop s" nil" str-append ;; drop +: pr-buf-list-item ( list str-addr str-len -- list str-addr str-len) + rot dup MalList/cdr @ swap MalList/car @ 2swap rot pr-buf ; + : pr-buf-list ( list str-addr str-len -- str-addr str-len) - rot dup MalList/cdr @ swap MalList/car @ 2swap rot pr-buf + pr-buf-list-item begin ( list str-addr str-len ) 2 pick mal-nil <> while - a-space - rot dup MalList/cdr @ swap MalList/car @ 2swap rot pr-buf + a-space pr-buf-list-item repeat rot drop ; - MalList extend pr-buf -rot s" (" str-append ( list str-addr str-len ) @@ -96,6 +97,21 @@ MalVector s" ]" str-append ;; drop +MalMap + extend pr-buf + MalMap/list @ + -rot s" {" str-append ( list str-addr str-len ) + pr-buf-list-item a-space pr-buf-list-item + begin ( list str-addr str-len ) + 2 pick mal-nil <> + while + s" , " str-append + pr-buf-list-item a-space pr-buf-list-item + repeat + rot drop + s" }" str-append ;; +drop + MalInt extend pr-buf MalInt/int @ int>str str-append ;; |
