defer read
: readpair ( -- obj )
- inc-parse-idx
eatspaces
\ Empty lists
reset-term abort
then
- nil-type exit
+ dec-parse-idx
+
+ 0 nil-type exit
then
\ Read first pair element
then
pair? if
+ inc-parse-idx
+
+ eatspaces
+
readpair
+
+ eatspaces
+
+ nextchar [char] ) <> if
+ bold red ." Missing closing paren." reset-term cr
+ abort
+ then
+
+ inc-parse-idx
+
exit
then
defer print
: printpair ( pairobj -- )
- ." ("
2dup
car print
cdr
nil-type istype? if 2drop ." )" exit then
- pair-type istype? if recurse ." )" exit then
- ." . " print ." )"
+ pair-type istype? if space recurse exit then
+ ." . " print
;
:noname ( obj -- )
boolean-type istype? if printbool exit then
character-type istype? if printchar exit then
nil-type istype? if printnil exit then
- pair-type istype? if printpair exit then
+ pair-type istype? if ." (" printpair ." )" exit then
bold fg red ." Error printing expression - unrecognized type. Aborting" reset-term cr
abort