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 Bug Fixes
- Arthur Maciel replaced high resolution code in the runtime to use `clock_gettime` instead of `gettimeofday`. - 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 ## 0.27 - March 5, 2021

View file

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