Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
res = {} re = function( res, name, def ) if res[name] then return res[name] end res[name] = regex(def) return res[name] end re(res, "getline", "^([^\n]*)(\n?)") re(res, "getspaces", "^([^ \t]*)") re(res, "getword", "^[ \t]*([^ \t\n]*)") program = {} program.string = readfile(arg[1]) program.pos = 0 getword = function( ) local _, mall, m1 = regmatch(res.getword, program.string, program.pos) program.pos = program.pos + strlen(mall) return m1 end getline = function( ) local _, mall, m1, nl = regmatch(res.getline, program.string, program.pos) program.pos = program.pos + strlen(mall) if mall ~= "" then return m1 end end getuntilre = function( delimre ) local offset, mdelim = regmatch(re(res, delimre, delimre), program.string, program.pos) local m1 = strsub(program.string, program.pos+1, program.pos+offset) program.pos = program.pos+offset+strlen(mdelim) return m1 end dict = {} dict[""] = function( ) getline() end dict["lua-until"] = function( ) dostring(getuntilre(getword())) end while 1 do dict[getword()]() end