create parse-str 161 allot
variable parse-str-span
-
create parse-idx-stack 10 allot
variable parse-idx-sp
parse-idx-stack parse-idx-sp !
boolean-type
;
+: readchar ( -- char-atom )
+ inc-parse-idx
+ inc-parse-idx
+
+ S" newline" str-equiv? if '\n' character-type exit then
+ S" space" str-equiv? if bl character-type exit then
+ S" tab" str-equiv? if 9 character-type exit then
+
+ nextchar character-type
+
+ inc-parse-idx
+;
+
\ Parse a scheme expression
: read ( -- obj )
exit
then
+ character? if
+ readchar
+ exit
+ then
+
eof? if
bold fg blue ." Moriturus te saluto." reset-term ." ok" cr
quit
then
;
+: printchar ( charobj -- )
+ drop
+ case
+ 9 of ." #\tab" endof
+ bl of ." #\space" endof
+ '\n' of ." #\newline" endof
+ endcase
+;
+
: print ( obj -- )
." ; "
number-type istype? if printnum exit then
boolean-type istype? if printbool exit then
+ character-type istype? if printchar exit then
;
\ ---- REPL ----