From cec81107d4de26ee4247854f317b87f23a7165ab Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 31 Mar 2024 12:51:38 -0500 Subject: Improve dotted-pair reads Instead of getting the next token twice, read the next thing. --- read.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/read.lua b/read.lua index f50fa40..a41816f 100644 --- a/read.lua +++ b/read.lua @@ -141,15 +141,9 @@ function m.read (port) if toktype == "close" then return t.list(L) elseif toktype == "dot" then - local nxt, nxttype = port:next_token() - if nxttype == "close" then - error("Unexpected ')'") - end - local fin, fintype = port:next_token() - if fintype ~= "close" then - error("Too many after dot") - end - return t.list(L, nxt) + local fin = m.read(port) + port:next_token() -- throw away ')' + return t.list(L, fin) else table.insert(L, read_ahead(tok, toktype)) -- cgit 1.4.1-21-gabe81