From 22487ce1928236229e477ae7fde051b360c9497a Mon Sep 17 00:00:00 2001 From: Ram Krishnan Date: Sat, 10 Nov 2018 20:06:34 -0800 Subject: [PATCH] pcall the read, and skip calling clearstream for now --- lib/stdio.fnl | 8 +++++--- lib/stdio.lua | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/stdio.fnl b/lib/stdio.fnl index 3d2bb67..0f3f4d7 100644 --- a/lib/stdio.fnl +++ b/lib/stdio.fnl @@ -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)))))))) diff --git a/lib/stdio.lua b/lib/stdio.lua index 633a6a0..ee1bb22 100644 --- a/lib/stdio.lua +++ b/lib/stdio.lua @@ -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())