Issue #453 - Proper handing of EOF at the REPL

Finally handle EOF correctly and do not exit REPL if an expression evaluates to the EOF object. However, allow CTRL-d to exit the REPL.
This commit is contained in:
Justin Ethier 2021-03-28 22:18:10 -04:00
parent a9438b5c07
commit fd4aa4fae6
2 changed files with 10 additions and 8 deletions

View file

@ -22,6 +22,7 @@ Features
Bug Fixes
- Arthur Maciel replaced high resolution code in the runtime to use `clock_gettime` instead of `gettimeofday`.
- Fixed the REPL to no longer automatically exit if an expression evaluates to EOF. However, the REPL will exit as a special case if the EOF character is entered directly, for example via CTRL-D on Linux.
## 0.27 - March 5, 2021

View file

@ -47,11 +47,12 @@
(newline)
(repl))
(display "cyclone> ")
(let ((c (eval (read))))
(cond
((not (eof-object? c))
(write c)
(let ((obj (read)))
(if (eof-object? obj)
(newline) ;; Quick way to exit REPL
(let ((c (eval obj)))
(if (eof-object? c)
(display "<EOF>")
(write c))
(newline)
(repl))
(else
(display "\n"))))))))
(repl))))))))