aboutsummaryrefslogtreecommitdiff
path: root/forth/printer.fs
diff options
context:
space:
mode:
Diffstat (limited to 'forth/printer.fs')
-rw-r--r--forth/printer.fs24
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 ;;