diff options
| author | Chouser <chouser@n01se.net> | 2015-02-18 19:57:39 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-02-21 13:22:44 -0500 |
| commit | 224e09ed42325f000ee9a31a500bebe03a1ba97c (patch) | |
| tree | f71681f3f9e54a6c13f5063363befecbec916d37 /forth/printer.fs | |
| parent | 580c4eef9d61f39264813b662fe5335c3c3c4ee5 (diff) | |
| download | mal-224e09ed42325f000ee9a31a500bebe03a1ba97c.tar.gz mal-224e09ed42325f000ee9a31a500bebe03a1ba97c.zip | |
forth: Finish step 9
Diffstat (limited to 'forth/printer.fs')
| -rw-r--r-- | forth/printer.fs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/forth/printer.fs b/forth/printer.fs index 645e5da..85f88a0 100644 --- a/forth/printer.fs +++ b/forth/printer.fs @@ -5,7 +5,6 @@ require types.fs def-protocol-method pr-buf ( readably? str-addr str-len this -- str-addr str-len ) def-protocol-method pr-seq-buf ( readably? str-addr str-len this -- str-addr str-len ) -def-protocol-method pr-pairs-buf ( readably? str-addr str-len this -- str-addr str-len ) : pr-str { obj } true new-str obj pr-buf rot drop ; @@ -39,15 +38,6 @@ MalList start i cells + @ pr-buf loop endif ;; - extend pr-pairs-buf { list } - list MalList/start @ { start } - start @ pr-buf a-space start cell+ @ pr-buf - list MalList/count @ 2 / 1 ?do - s" , " str-append - a-space - start i 2 * cells + @ pr-buf a-space - start i 2 * 1+ cells + @ pr-buf - loop ;; drop MalVector @@ -62,7 +52,17 @@ MalMap extend pr-buf MalMap/list @ -rot s" {" str-append ( list str-addr str-len ) - rot pr-pairs-buf + rot { list } + list MalList/count @ { count } + count 0 > if + list MalList/start @ { start } + start @ pr-buf a-space start cell+ @ pr-buf + count 2 / 1 ?do + s" , " str-append + start i 2 * cells + @ pr-buf a-space + start i 2 * 1+ cells + @ pr-buf + loop + endif s" }" str-append ;; drop @@ -105,3 +105,10 @@ MalString str-append endif ;; drop + +Atom + extend pr-buf { this } + s" (atom " str-append + this Atom/val @ pr-buf + s" )" str-append ;; +drop
\ No newline at end of file |
