about summary refs log tree commit diff stats
path: root/read.lua
diff options
context:
space:
mode:
Diffstat (limited to 'read.lua')
-rw-r--r--read.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/read.lua b/read.lua index 226af51..f50fa40 100644 --- a/read.lua +++ b/read.lua
@@ -97,7 +97,6 @@ function m.scan (cs)
97 while true do 97 while true do
98 if m.readtable[cs[1]] then 98 if m.readtable[cs[1]] then
99 token, toktype, cs = m.readtable[cs[1]](cs) 99 token, toktype, cs = m.readtable[cs[1]](cs)
100 -- return { v = token, u = toktype }, cs
101 return token, toktype, cs 100 return token, toktype, cs
102 elseif cs[1]:match("%s") then 101 elseif cs[1]:match("%s") then
103 _, cs = consume_whitespace(cs) 102 _, cs = consume_whitespace(cs)
@@ -108,20 +107,16 @@ function m.scan (cs)
108 local token, cs = consume_token(cs) 107 local token, cs = consume_token(cs)
109 if token:match("[-+]") or token == "..." then 108 if token:match("[-+]") or token == "..." then
110 return token, "symbol", cs 109 return token, "symbol", cs
111 -- return { v = token, u = "symbol" }, cs
112 elseif token == "." then 110 elseif token == "." then
113 return token, "dot", cs 111 return token, "dot", cs
114 -- return { v = token, u = "dot" }, cs
115 else 112 else
116 local n = tonumber(token) 113 local n = tonumber(token)
117 assert (n ~= nil, "Bad number: "..n) 114 assert (n ~= nil, "Bad number: "..n)
118 return n, "number", cs 115 return n, "number", cs
119 -- return { v = n, u = "number" }, cs
120 end 116 end
121 else 117 else
122 token, cs = consume_token(cs) 118 token, cs = consume_token(cs)
123 return token, "symbol", cs 119 return token, "symbol", cs
124 -- return { v = token, u = "symbol" }, cs
125 end 120 end
126 end 121 end
127 end 122 end
@@ -145,6 +140,16 @@ function m.read (port)
145 local tok, toktype = port:next_token() 140 local tok, toktype = port:next_token()
146 if toktype == "close" then 141 if toktype == "close" then
147 return t.list(L) 142 return t.list(L)
143 elseif toktype == "dot" then
144 local nxt, nxttype = port:next_token()
145 if nxttype == "close" then
146 error("Unexpected ')'")
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)
148 else 153 else
149 table.insert(L, 154 table.insert(L,
150 read_ahead(tok, toktype)) 155 read_ahead(tok, toktype))