pcall the read, and skip calling clearstream for now

This commit is contained in:
Ram Krishnan 2018-11-10 20:06:34 -08:00
parent dd418aa196
commit 22487ce192
2 changed files with 7 additions and 6 deletions

View file

@ -30,11 +30,13 @@
(while true (while true
(prompt) (prompt)
(set input "") (set input "")
(let [(ok ast) (read)] (let [(ok ast) (pcall read)]
(if (not ok) (if (not ok)
(do (do
(display (.. "Error:" (view ast) "\n")) (display (.. "Parse error:" ast "\n"))
(clearstream)) ;; fixme: not sure why the following fails
;; (clearstream)
)
(do (do
(love.event.push event input) (love.event.push event input)
(display (: channel :demand)))))))) (display (: channel :demand))))))))

View file

@ -32,11 +32,10 @@ local function _0_(...)
prompt() prompt()
input = "" input = ""
do do
local ok, ast = read() local ok, ast = pcall(read)
local function _1_(...) local function _1_(...)
if not ok then if not ok then
display(("Error:" .. view(ast) .. "\n")) return display(("Parse error:" .. ast .. "\n"))
return clearstream()
else else
love.event.push(event, input) love.event.push(event, input)
return display(channel:demand()) return display(channel:demand())