-- miniforth2.lua -- This is a rewrite of (find-angg "miniforth/miniforth1.lua") -- using empty captures to make the code cleaner. -- Author and version: Edrx, 2005nov29 -- License: GPL subj = "" pos = 0 getword = function () local _, _, word, newpos = string.find(subj, "^[ \t]*([^ \t\n\r]+)()", pos) if _ then pos = newpos; return word end end getnewline = function () local _, _, newpos = string.find(subj, "^[ \t]*\r?\n()", pos) if _ then pos = newpos; return "\n" end end geteof = function () local _, _, newpos = string.find(subj, "^[ \t]*()$", pos) if _ then pos = newpos; return "" end end getword1 = function () return getword() or getnewline() or geteof() end eval = function (luacode) return assert(loadstring(luacode))() end getuntillua = function () local _, _, luacode, newpos = string.find(subj, "^(.-)lua>()", pos) if _ then pos = newpos; return luacode end end forths = {} forths["\n"] = function () end forths[""] = function () interpret = nil end forths[" hello hello ]] -- PP(arg) -- (find-sh "lua -l miniforth2.lua -e runstr(demo)") -- (find-sh "lua -e print(\\\"foo\\\")")