diff options
| author | Chouser <chouser@n01se.net> | 2015-02-06 23:58:41 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-02-21 13:22:44 -0500 |
| commit | 168fb5dc56fee6653816ee8236259940e575c7ec (patch) | |
| tree | f3207b32946453028ce9477726b4f7150b12cc5d /forth/printer.fs | |
| parent | 50e417ffe32c238189e61c9701696602d40bb7f3 (diff) | |
| download | mal-168fb5dc56fee6653816ee8236259940e575c7ec.tar.gz mal-168fb5dc56fee6653816ee8236259940e575c7ec.zip | |
forth: Add step 1, but not maps
Diffstat (limited to 'forth/printer.fs')
| -rw-r--r-- | forth/printer.fs | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/forth/printer.fs b/forth/printer.fs index 8882e13..243780a 100644 --- a/forth/printer.fs +++ b/forth/printer.fs @@ -70,9 +70,7 @@ MalNil drop s" nil" str-append ;; drop -MalList - extend pr-buf - -rot s" (" str-append ( list str-addr str-len ) +: pr-buf-list ( list str-addr str-len -- str-addr str-len) rot dup MalList/cdr @ swap MalList/car @ 2swap rot pr-buf begin ( list str-addr str-len ) 2 pick mal-nil <> @@ -80,7 +78,22 @@ MalList a-space rot dup MalList/cdr @ swap MalList/car @ 2swap rot pr-buf repeat - s" )" str-append rot drop ;; + rot drop ; + + +MalList + extend pr-buf + -rot s" (" str-append ( list str-addr str-len ) + pr-buf-list + s" )" str-append ;; +drop + +MalVector + extend pr-buf + MalVector/list @ + -rot s" [" str-append ( list str-addr str-len ) + pr-buf-list + s" ]" str-append ;; drop MalInt @@ -112,19 +125,27 @@ MalString s\" \"" str-append 0 ( i ) begin + dup len < + while dup addr + c@ ( i char ) dup [char] " = over [char] \ = or if ( i char ) drop dup addr len rot insert-\ to len to addr 1+ else - 10 = if ( i ) \ newline? - dup addr len rot insert-\ to len to addr + dup 10 = if ( i ) \ newline? + drop dup addr len rot insert-\ to len to addr dup addr + 1+ [char] n swap c! 1+ + else + 13 = if ( i ) \ return? + dup addr len rot insert-\ to len to addr + dup addr + 1+ [char] r swap c! + 1+ + endif endif endif 1+ - dup len = until + repeat drop addr len str-append s\" \"" str-append ;; drop |
