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
(prompt)
(set input "")
(let [(ok ast) (read)]
(let [(ok ast) (pcall read)]
(if (not ok)
(do
(display (.. "Error:" (view ast) "\n"))
(clearstream))
(display (.. "Parse error:" ast "\n"))
;; fixme: not sure why the following fails
;; (clearstream)
)
(do
(love.event.push event input)
(display (: channel :demand))))))))

View file

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