about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2024-03-31 12:51:38 -0500
committerCase Duckworth2024-03-31 12:51:38 -0500
commitcec81107d4de26ee4247854f317b87f23a7165ab (patch)
tree0baf9470f76812e40232ee53a2d3f2f4453391bc
parentFix dotted list reading (diff)
downloadlam-cec81107d4de26ee4247854f317b87f23a7165ab.tar.gz
lam-cec81107d4de26ee4247854f317b87f23a7165ab.zip
Improve dotted-pair reads
Instead of getting the next token twice, read the next thing.
-rw-r--r--read.lua12
1 files 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)
141 if toktype == "close" then 141 if toktype == "close" then
142 return t.list(L) 142 return t.list(L)
143 elseif toktype == "dot" then 143 elseif toktype == "dot" then
144 local nxt, nxttype = port:next_token() 144 local fin = m.read(port)
145 if nxttype == "close" then 145 port:next_token() -- throw away ')'
146 error("Unexpected ')'") 146 return t.list(L, fin)
147 end
148 local fin, fintype = port:next_token()
149 if fintype ~= "close" then
150 error("Too many after dot")
151 end
152 return t.list(L, nxt)
153 else 147 else
154 table.insert(L, 148 table.insert(L,
155 read_ahead(tok, toktype)) 149 read_ahead(tok, toktype))