Sink
New Coder
Hi, I'm attempting to write an interpreter in Lua, and the first idea was to make it able to run a simple print function. If anyone is able to answer what's wrong, i would appreciate it.
Here is my main code:
Note: numbers Is a module which i created.
Output: prt"hiworld!"
What i was expecting was for the output to be "hiworld", "hi world" or even "_hi world"
Here is my main code:
Code:
nm = require "numbers"
exec = false
function readAll(file)
local f = assert(io.open(file, "rb"))
local content = f:read("*all")
f:close()
return content
end
fc = readAll("main.i")
for i=1,#fc,1 do
if string.find(fc,"prt") and not exec then
fcs = nm.Trim(fc)
print(nm.Replace(fcs, 'prt', "_"))
exec = true
end
end
Note: numbers Is a module which i created.
Output: prt"hiworld!"
What i was expecting was for the output to be "hiworld", "hi world" or even "_hi world"