4 include term-colours.4th
6 include catch-throw.4th
28 make-type boolean-type
29 make-type character-type
35 make-type primitive-proc-type
36 make-type compound-proc-type
37 make-type fileport-type
38 : istype? ( obj type -- obj bool )
43 \ ---- Exceptions ---- {{{
45 variable nextexception
48 create nextexception @ ,
52 make-exception recoverable-exception
53 make-exception unrecoverable-exception
55 : display-exception-msg ( addr count -- )
68 ['] display-exception-msg ,
76 \ ---- List-structured memory ---- {{{
78 10000 constant scheme-memsize
80 create car-cells scheme-memsize allot
81 create car-type-cells scheme-memsize allot
82 create cdr-cells scheme-memsize allot
83 create cdr-type-cells scheme-memsize allot
85 create nextfrees scheme-memsize allot
96 nextfrees nextfree @ + @
99 nextfree @ scheme-memsize >= if
103 nextfree @ scheme-memsize >= if
104 unrecoverable-exception throw s" Out of memory!"
108 : cons ( car-obj cdr-obj -- pair-obj )
109 cdr-type-cells nextfree @ + !
110 cdr-cells nextfree @ + !
111 car-type-cells nextfree @ + !
112 car-cells nextfree @ + !
118 : car ( pair-obj -- car-obj )
120 dup car-cells + @ swap
124 : cdr ( pair-obj -- car-obj )
126 dup cdr-cells + @ swap
130 : set-car! ( obj pair-obj -- )
132 rot swap car-type-cells + !
136 : set-cdr! ( obj pair-obj -- )
138 rot swap cdr-type-cells + !
143 : nil? nil-type istype? ;
146 : none? none-type istype? ;
148 : objvar create nil swap , , ;
150 : value@ ( objvar -- val ) @ ;
151 : type@ ( objvar -- type ) 1+ @ ;
152 : value! ( newval objvar -- ) ! ;
153 : type! ( newtype objvar -- ) 1+ ! ;
154 : obj! ( newobj objvar -- ) dup rot swap 1+ ! ! ;
155 : obj@ ( objvar -- obj ) dup @ swap 1+ @ ;
157 : objeq? ( obj obj -- bool )
160 : 2rot ( a1 a2 b1 b2 c1 c2 -- b1 b2 c1 c2 a1 a2 )
161 >R >R ( a1 a2 b1 b2 )
162 2swap ( b1 b2 a1 a2 )
163 R> R> ( b1 b2 a1 a2 c1 c2 )
167 : -2rot ( a1 a2 b1 b2 c1 c2 -- c1 c2 a1 a2 b1 b2 )
168 2swap ( a1 a2 c1 c2 b1 b2 )
169 >R >R ( a1 a2 c1 c2 )
170 2swap ( c1 c2 a1 a2 )
176 \ ---- Port I/O ---- {{{
178 : fileport>fid ( fileport -- fid )
181 : fid>fileport ( fid -- fileport )
184 : open-input-file ( addr n -- fileport )
185 r/o open-file drop fid>fileport
188 : close-port ( fileport -- )
189 fileport>fid close-file drop
192 objvar console-i/o-port
193 0 fileport-type console-i/o-port obj!
195 objvar current-input-port
196 console-i/o-port obj@ current-input-port obj!
198 : read-port ( fileport -- obj )
199 current-input-port obj!
202 : read-console ( -- obj )
203 console-i/o-port obj@ read-port ;
207 \ ---- Pre-defined symbols ---- {{{
211 : duplicate-charlist ( charlist -- copy )
213 2dup car 2swap cdr recurse cons
216 : charlist-equiv ( charlist charlist -- bool )
225 2drop 2drop true exit
227 2drop 2drop false exit
232 2drop 2drop false exit
239 car drop -rot car drop = if
240 cdr 2swap cdr recurse
246 : charlist>symbol ( charlist -- symbol-obj )
265 drop symbol-type 2dup
266 symbol-table obj@ cons
271 : cstr>charlist ( addr n -- charlist )
275 2dup drop @ character-type 2swap
283 : create-symbol ( -- )
291 does> dup @ swap 1+ @
294 create-symbol quote quote-symbol
295 create-symbol quasiquote quasiquote-symbol
296 create-symbol unquote unquote-symbol
297 create-symbol unquote-splicing unquote-splicing-symbol
298 create-symbol define define-symbol
299 create-symbol define-macro define-macro-symbol
300 create-symbol set! set!-symbol
301 create-symbol ok ok-symbol
302 create-symbol if if-symbol
303 create-symbol lambda lambda-symbol
304 create-symbol λ λ-symbol
305 create-symbol begin begin-symbol
309 \ ---- Environments ---- {{{
311 : enclosing-env ( env -- env )
314 : first-frame ( env -- frame )
317 : make-frame ( vars vals -- frame )
320 : frame-vars ( frame -- vars )
323 : frame-vals ( frame -- vals )
326 : add-binding ( var val frame -- )
327 2swap 2over frame-vals cons
329 2swap 2over frame-vars cons
333 : extend-env ( vars vals env -- env )
343 : get-vars-vals-frame ( var frame -- bool )
344 2dup frame-vars vars obj!
348 vars obj@ nil objeq? false =
350 2dup vars obj@ car objeq? if
355 vars obj@ cdr vars obj!
356 vals obj@ cdr vals obj!
362 : get-vars-vals ( var env -- vars? vals? bool )
367 2over 2over first-frame
368 get-vars-vals-frame if
370 vars obj@ vals obj@ true
384 : lookup-var ( var env -- val )
388 recoverable-exception throw" Tried to read unbound variable."
392 : set-var ( var val env -- )
393 >R >R 2swap R> R> ( val var env )
395 2swap 2drop ( val vals )
398 recoverable-exception throw" Tried to set unbound variable."
404 : define-var ( var val env -- )
407 2over env obj@ ( var val var env )
409 2swap 2drop ( var val vals )
414 first-frame ( var val frame )
421 : make-procedure ( params body env -- proc )
424 drop compound-proc-type
428 nil nil nil extend-env
433 \ ---- Primitives ---- {{{
435 : make-primitive ( cfa -- )
442 rot primitive-proc-type ( var prim )
443 global-env obj@ define-var
446 : ensure-arg-count ( args n -- )
448 drop nil objeq? false = if
449 recoverable-exception throw" Too many arguments for primitive procedure."
453 recoverable-exception throw" Too few arguments for primitive procedure."
460 : ensure-arg-type-and-count ( tn tn-1 ... t2 t1 args n -- )
462 drop nil objeq? false = if
463 recoverable-exception throw" Too many arguments for primitive procedure."
467 recoverable-exception throw" Too few arguments for primitive procedure."
470 2dup cdr 2swap car ( ... t1 n args' arg1 )
471 2rot 1- swap 2swap rot ( ... args' n-1 arg1 t1 )
473 recoverable-exception throw" Incorrect type for primitive procedure."
481 : push-args-to-stack ( args -- arg1 arg2 ... argn )
491 : add-fa-checks ( cfa n -- cfa' )
492 here current @ 1+ dup @ , !
496 ['] 2dup , ['] lit , , ['] ensure-arg-count ,
497 ['] push-args-to-stack ,
498 ['] lit , , ['] execute ,
502 : add-fa-type-checks ( cfa t1 t2 ... tn n -- cfa' )
503 here current @ 1+ dup @ , !
510 dup ( cfa t1 t2 ... tn n m )
515 rot ['] lit , , ( cfa t1 t2 ... tn-1 n m )
521 ['] lit , , ['] ensure-arg-type-and-count ,
523 ['] push-args-to-stack ,
524 ['] lit , , ['] execute ,
530 : make-fa-primitive ( cfa n -- )
531 add-fa-checks make-primitive ;
533 : make-fa-type-primitive ( cfa t1 t2 ... tn n -- )
534 add-fa-type-checks make-primitive ;
537 bold fg red ." Incorrect argument type." reset-term cr
541 : ensure-arg-type ( arg type -- arg )
543 recoverable-exception throw" Incorrect argument type for primitive procedure."
550 \ ---- Macros ---- {{{
554 ( Look up macro in macro table. Returns nil if
556 : lookup-macro ( name_symbol -- proc )
575 : make-macro ( name_symbol params body env -- )
578 2swap ( proc name_symbol )
585 2over 2over ( proc name table name table )
587 2swap 2drop ( proc table )
599 macro-table obj@ cons
608 variable stored-parse-idx
609 create parse-str 161 allot
610 variable parse-str-span
612 create parse-idx-stack 10 allot
613 variable parse-idx-sp
614 parse-idx-stack parse-idx-sp !
617 parse-idx @ parse-idx-sp @ !
622 parse-idx-sp @ parse-idx-stack <= abort" Parse index stack underflow."
626 parse-idx-sp @ @ parse-idx ! ;
630 '\n' parse-str parse-str-span @ + !
631 1 parse-str-span +! ;
634 4 parse-str parse-str-span @ + !
635 1 parse-str-span +! ;
642 current-input-port obj@ console-i/o-port obj@ objeq? if
643 parse-str 160 expect cr
644 span @ parse-str-span !
646 parse-str 160 current-input-port obj@ fileport>fid read-line
647 drop swap parse-str-span !
649 parse-str-span @ 0= and if append-eof then
660 : charavailable? ( -- bool )
661 parse-str-span @ parse-idx @ > ;
663 : nextchar ( -- char )
664 charavailable? false = if getline then
665 parse-str parse-idx @ + @ ;
668 : whitespace? ( -- bool )
680 nextchar [char] ( = or
681 nextchar [char] ) = or
684 : commentstart? ( -- bool )
685 nextchar [char] ; = ;
689 false \ Indicates whether or not we're eating a comment
692 dup whitespace? or commentstart? or
694 dup nextchar '\n' = and if
695 invert \ Stop eating comment
697 dup false = commentstart? and if
698 invert \ Begin eating comment
713 nextchar [char] - = ;
716 nextchar [char] + = ;
718 : fixnum? ( -- bool )
744 : flonum? ( -- bool )
751 \ Record starting parse idx:
752 \ Want to detect whether any characters (following +/-) were eaten.
759 [char] . nextchar = if
766 [char] e nextchar = [char] E nextchar = or if
774 drop pop-parse-idx false exit
782 \ This is a real number if characters were
783 \ eaten and the next characer is a delimiter.
784 parse-idx @ < delim? and
789 : boolean? ( -- bool )
790 nextchar [char] # <> if false exit then
797 and if pop-parse-idx false exit then
809 : str-equiv? ( str -- bool )
826 delim? false = if drop false then
831 : character? ( -- bool )
832 nextchar [char] # <> if false exit then
837 nextchar [char] \ <> if pop-parse-idx false exit then
841 S" newline" str-equiv? if pop-parse-idx true exit then
842 S" space" str-equiv? if pop-parse-idx true exit then
843 S" tab" str-equiv? if pop-parse-idx true exit then
845 charavailable? false = if pop-parse-idx false exit then
851 nextchar [char] ( = ;
853 : string? ( -- bool )
854 nextchar [char] " = ;
856 : readfixnum ( -- fixnum )
867 10 * nextchar [char] 0 - +
876 : readflonum ( -- flonum )
880 [char] . netchar = if
883 nextchar [char] 0 - i->f over f/ f+
888 [char] e nextchar = [char] E nextchar = or if
896 : readbool ( -- bool-obj )
899 nextchar [char] f = if
910 : readchar ( -- char-obj )
914 S" newline" str-equiv? if 7 parse-idx +! '\n' character-type exit then
915 S" space" str-equiv? if 5 parse-idx +! bl character-type exit then
916 S" tab" str-equiv? if 3 parse-idx +! 9 character-type exit then
918 nextchar character-type
923 : readstring ( -- charlist )
924 nextchar [char] " = if
929 ." No delimiter following right double quote. Aborting." cr
938 nextchar [char] \ = if
941 [char] n of '\n' endof
942 [char] " of [char] " endof
948 inc-parse-idx character-type
955 : readsymbol ( -- charlist )
956 delim? if nil exit then
958 nextchar inc-parse-idx character-type
965 : readpair ( -- pairobj )
969 nextchar [char] ) = if
974 ." No delimiter following right paren. Aborting." cr
983 \ Read first pair element
988 nextchar [char] . = if
993 ." No delimiter following '.'. Aborting." cr
1007 \ Parse a scheme expression
1033 nextchar [char] " <> if
1034 bold red ." Missing closing double-quote." reset-term cr
1052 nextchar [char] ) <> if
1053 bold red ." Missing closing paren." reset-term cr
1062 nextchar [char] ' = if
1064 quote-symbol recurse nil cons cons exit
1067 nextchar [char] ` = if
1069 quasiquote-symbol recurse nil cons cons exit
1072 nextchar [char] , = if
1074 nextchar [char] @ = if
1076 unquote-splicing-symbol recurse nil cons cons exit
1078 unquote-symbol recurse nil cons cons exit
1088 \ Anything else is parsed as a symbol
1089 readsymbol charlist>symbol
1091 \ Replace λ with lambda
1092 2dup λ-symbol objeq? if
1101 \ ---- Eval ---- {{{
1103 : self-evaluating? ( obj -- obj bool )
1104 boolean-type istype? if true exit then
1105 fixnum-type istype? if true exit then
1106 character-type istype? if true exit then
1107 string-type istype? if true exit then
1108 nil-type istype? if true exit then
1109 none-type istype? if true exit then
1114 : tagged-list? ( obj tag-obj -- obj bool )
1116 pair-type istype? false = if
1122 : quote? ( obj -- obj bool )
1123 quote-symbol tagged-list? ;
1125 : quote-body ( quote-obj -- quote-body-obj )
1128 : quasiquote? ( obj -- obj bool )
1129 quasiquote-symbol tagged-list? ;
1131 : unquote? ( obj -- obj bool )
1132 unquote-symbol tagged-list? ;
1134 : unquote-splicing? ( obj -- obj bool )
1135 unquote-splicing-symbol tagged-list? ;
1137 : eval-unquote ( env obj -- res )
1141 recoverable-exception throw" no arguments to unquote."
1146 recoverable-exception throw" too many arguments to unquote."
1149 2drop car 2swap eval
1152 ( Create a new list from elements of l1 consed on to l2 )
1153 : join-lists ( l2 l1 -- l3 )
1154 nil? if 2drop exit then
1161 defer eval-quasiquote-item
1162 : eval-quasiquote-pair ( env obj -- res )
1163 2over 2over ( env obj env obj )
1165 cdr eval-quasiquote-item
1167 -2rot car ( cdritem env objcar )
1169 unquote-splicing? if
1170 eval-unquote ( cdritems caritem )
1178 eval-quasiquote-item ( cdritems caritem )
1193 pair-type istype? if
1194 eval-quasiquote-pair exit
1198 ; is eval-quasiquote-item
1200 : eval-quasiquote ( obj env -- res )
1201 2swap cdr ( env args )
1204 recoverable-exception throw" no arguments to quasiquote."
1207 2dup cdr ( env args args-cdr )
1209 recoverable-exception throw" too many arguments to quasiquote."
1212 2drop car ( env arg )
1214 eval-quasiquote-item
1217 : variable? ( obj -- obj bool )
1218 symbol-type istype? ;
1220 : definition? ( obj -- obj bool )
1221 define-symbol tagged-list? ;
1223 : make-lambda ( params body -- lambda-exp )
1224 lambda-symbol -2rot cons cons ;
1226 ( Handles iterative expansion of defines in
1227 terms of nested lambdas. Most Schemes only
1228 handle one iteration of expansion! )
1229 : definition-var-val ( obj -- var val )
1231 cdr 2dup cdr 2swap car ( val var )
1234 symbol-type istype? false =
1236 2dup cdr 2swap car ( val formals var' )
1237 -2rot 2swap ( var' formals val )
1238 make-lambda nil cons ( var' val' )
1245 : eval-definition ( obj env -- res )
1246 2dup 2rot ( env env obj )
1247 definition-var-val ( env env var val )
1248 2rot eval ( env var val )
1250 2rot ( var val env )
1256 : assignment? ( obj -- obj bool )
1257 set!-symbol tagged-list? ;
1259 : assignment-var ( obj -- var )
1262 : assignment-val ( obj -- val )
1265 : eval-assignment ( obj env -- res )
1267 2over 2over ( env obj env obj )
1268 assignment-val 2swap ( env obj valexp env )
1269 eval ( env obj val )
1271 2swap assignment-var 2swap ( env var val )
1273 2rot ( var val env )
1279 : macro-definition? ( obj -- obj bool )
1280 define-macro-symbol tagged-list? ;
1282 : macro-definition-name ( exp -- mname )
1285 : macro-definition-params ( exp -- params )
1288 : macro-definition-body ( exp -- body )
1292 : eval-define-macro ( obj env -- res )
1295 2dup macro-definition-name 2swap ( name obj )
1296 2dup macro-definition-params 2swap ( name params obj )
1297 macro-definition-body ( name params body )
1299 env obj@ ( name params body env )
1307 : if? ( obj -- obj bool )
1308 if-symbol tagged-list? ;
1310 : if-predicate ( ifobj -- pred )
1313 : if-consequent ( ifobj -- conseq )
1316 : if-alternative ( ifobj -- alt|none )
1324 : false? ( boolobj -- boolean )
1325 boolean-type istype? if
1326 false boolean-type objeq?
1332 : true? ( boolobj -- bool )
1335 : lambda? ( obj -- obj bool )
1336 lambda-symbol tagged-list? ;
1338 : lambda-parameters ( obj -- params )
1341 : lambda-body ( obj -- body )
1344 : begin? ( obj -- obj bool )
1345 begin-symbol tagged-list? ;
1347 : begin-actions ( obj -- actions )
1350 : eval-sequence ( explist env -- finalexp env )
1351 ( Evaluates all bar the final expressions in
1352 an an expression list. The final expression
1353 is returned to allow for tail optimization. )
1355 2swap ( env explist )
1357 \ Abort on empty list
1364 2dup cdr ( env explist nextexplist )
1367 -2rot car 2over ( nextexplist env exp env )
1369 2drop \ discard result
1370 2swap ( env nextexplist )
1373 2drop car 2swap ( finalexp env )
1376 : application? ( obj -- obj bool )
1379 : operator ( obj -- operator )
1382 : operands ( obj -- operands )
1385 : nooperands? ( operands -- bool )
1388 : first-operand ( operands -- operand )
1391 : rest-operands ( operands -- other-operands )
1394 : list-of-vals ( args env -- vals )
1400 2over 2over first-operand 2swap eval
1401 -2rot rest-operands 2swap recurse
1406 : procedure-params ( proc -- params )
1407 drop pair-type car ;
1409 : procedure-body ( proc -- body )
1410 drop pair-type cdr car ;
1412 : procedure-env ( proc -- body )
1413 drop pair-type cdr cdr car ;
1415 ( Ensure terminating symbol arg name is handled
1416 specially to allow for variadic procedures. )
1417 : flatten-proc-args ( argvals argnames -- argvals' argnames' )
1419 2over nil? false = if
1420 recoverable-exception throw" Too many arguments for compound procedure."
1427 symbol-type istype? if
1437 recoverable-exception throw" Too few arguments for compound procedure."
1444 recurse ( argvals argnames argvals'' argnames'' )
1445 2rot car 2swap cons ( argvals argvals'' argnames' )
1446 2rot car 2rot cons ( argnames' argvals' )
1450 : apply ( proc argvals -- result )
1452 primitive-proc-type of
1456 compound-proc-type of
1457 2dup procedure-body ( argvals proc body )
1458 -2rot 2dup procedure-params ( body argvals proc argnames )
1459 -2rot procedure-env ( body argnames argvals procenv )
1465 extend-env ( body env )
1469 R> drop ['] eval goto-deferred \ Tail call optimization
1472 recoverable-exception throw" Object not applicable."
1476 ( Simply evaluates the given procedure with expbody as its argument. )
1477 : macro-expand ( proc expbody -- result )
1479 2dup procedure-body ( expbody proc procbody )
1480 -2rot 2dup procedure-params ( procbody expbody proc argnames )
1481 -2rot procedure-env ( procbody argnames expbody procenv )
1487 extend-env eval-sequence eval
1490 :noname ( obj env -- result )
1505 2swap eval-quasiquote
1515 2swap eval-definition
1520 2swap eval-assignment
1524 macro-definition? if
1525 2swap eval-define-macro
1541 ['] eval goto-deferred
1545 2dup lambda-parameters
1554 ['] eval goto-deferred
1559 2over 2over ( env exp env exp )
1560 operator ( env exp env opname )
1562 2dup lookup-macro nil? false = if
1563 \ Macro function evaluation
1565 ( env exp env opname mproc )
1566 2swap 2drop -2rot 2drop cdr ( env mproc body )
1571 ['] eval goto-deferred
1573 \ Regular function application
1575 2drop ( env exp env opname )
1577 2swap eval ( env exp proc )
1579 -2rot ( proc env exp )
1580 operands 2swap ( proc operands env )
1581 list-of-vals ( proc argvals )
1588 recoverable-exception throw" Tried to evaluate object with unknown type."
1593 \ ---- Print ---- {{{
1595 : printfixnum ( fixnumobj -- ) drop 0 .R ;
1597 : printbool ( numobj -- )
1605 : printchar ( charobj -- )
1608 9 of ." #\tab" endof
1609 bl of ." #\space" endof
1610 '\n' of ." #\newline" endof
1616 : (printstring) ( stringobj -- )
1617 nil? if 2drop exit then
1621 '\n' of ." \n" drop endof
1622 [char] \ of ." \\" drop endof
1623 [char] " of [char] \ emit [char] " emit drop endof
1629 : printstring ( stringobj -- )
1634 : printsymbol ( symbolobj -- )
1635 nil-type istype? if 2drop exit then
1641 : printnil ( nilobj -- )
1644 : printpair ( pairobj -- )
1648 nil-type istype? if 2drop exit then
1649 pair-type istype? if space recurse exit then
1653 : printprim ( primobj -- )
1654 2drop ." <primitive procedure>" ;
1656 : printcomp ( primobj -- )
1657 2drop ." <compound procedure>" ;
1659 : printnone ( noneobj -- )
1660 2drop ." Unspecified return value" ;
1662 : printport ( port -- )
1666 fixnum-type istype? if printfixnum exit then
1667 boolean-type istype? if printbool exit then
1668 character-type istype? if printchar exit then
1669 string-type istype? if printstring exit then
1670 symbol-type istype? if printsymbol exit then
1671 nil-type istype? if printnil exit then
1672 pair-type istype? if ." (" printpair ." )" exit then
1673 primitive-proc-type istype? if printprim exit then
1674 compound-proc-type istype? if printcomp exit then
1675 none-type istype? if printnone exit then
1677 recoverable-exception throw" Tried to print object with unknown type."
1682 \ ---- Garbage Collection ---- {{{
1687 variable gc-stack-depth
1690 depth gc-stack-depth !
1694 false gc-enabled ! ;
1699 : pairlike? ( obj -- obj bool )
1700 pair-type istype? if true exit then
1701 string-type istype? if true exit then
1702 symbol-type istype? if true exit then
1703 compound-proc-type istype? if true exit then
1708 : pairlike-marked? ( obj -- obj bool )
1709 over nextfrees + @ 0=
1712 : mark-pairlike ( obj -- obj )
1713 over nextfrees + 0 swap !
1722 : gc-mark-obj ( obj -- )
1724 pairlike? invert if 2drop exit then
1725 pairlike-marked? if 2drop exit then
1736 scheme-memsize nextfree !
1737 0 scheme-memsize 1- do
1738 nextfrees i + @ 0<> if
1739 nextfree @ nextfrees i + !
1745 \ Following a GC, this gives the amount of free memory
1749 nextfrees i + @ 0= if 1+ then
1753 \ Debugging word - helps spot memory that is retained
1756 nextfrees i + @ 0<> if
1768 symbol-table obj@ gc-mark-obj
1769 macro-table obj@ gc-mark-obj
1770 global-env obj@ gc-mark-obj
1772 depth gc-stack-depth @ do
1781 \ ." (" gc-count-marked . ." pairs marked as used.)" cr
1782 ; is collect-garbage
1786 \ ---- Loading files ---- {{{
1788 : charlist>cstr ( charlist addr -- n )
1790 dup 2swap ( origaddr addr charlist )
1796 drop ( origaddr addr charlist char )
1797 -rot 2swap ( origaddr charlist addr char )
1799 1+ -rot ( origaddr nextaddr charlist )
1802 2drop ( origaddr finaladdr )
1806 : load ( addr n -- finalResult )
1811 ok-symbol ( port res )
1814 2over read-port ( port res obj )
1816 2dup EOF character-type objeq? if
1817 2drop 2swap close-port
1821 2swap 2drop ( port obj )
1823 global-env obj@ eval ( port res )
1829 \ ---- Standard Library ---- {{{
1831 include scheme-primitives.4th
1833 s" scheme-library.scm" load 2drop
1839 ( REPL calls REPL-BODY in a loop until repl-body returns true. )
1840 : repl-body ( -- bool )
1841 cr bold fg green ." > " reset-term
1845 2dup EOF character-type objeq? if
1847 bold fg blue ." Moriturus te saluto." reset-term cr
1851 global-env obj@ eval
1853 fg cyan ." ; " print reset-term
1859 cr ." Welcome to scheme.forth.jl!" cr
1860 ." Use Ctrl-D to exit." cr
1869 recoverable-exception of false endof
1870 unrecoverable-exception of true endof