forth-stuff/ForthInterpreter.tl

25 lines
339 B
Plaintext
Raw Normal View History

2021-05-12 08:32:25 +00:00
-- helper functions
function isNumber(token: string): boolean
if tonumber(token) ~= nil then
return true
else
return false
end
end
for line in io.lines() do
local tokens = {}
for token in line:gmatch("%S+") do
table.insert(tokens, token)
end
for idx, val in ipairs(tokens) do
print(idx, val, isNumber(val))
end
end