extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
int main (int argc, char ** argv)
{
char * filename = "/test1.lua";
int result;
lua_State * L = luaL_newstate(); //lua_newstate(Lua :: alloc, 0);
if (L) {
luaL_openlibs(L);
// luaL_dofile(L, "/preload1.lua"); // *1*
if (luaL_loadfile (L, filename))
{
printf("luaL_loadfile error: %s", lua_tostring(L, -1));
printf("luaL_loadfile failed");
lua_pop(L, 1);
}
else
{
result = lua_resume(L, lua_gettop(L) - 1);
printf("lua_resume result %i\n", result);
}
} else {
printf("luaL_newstate failed\n");
}
return 0;
}
-- debug filter
local function IN(get,put)
put("IN init")
while true do
local line,token,value=get()
print(line,token,value)
put(line,token,value)
end
end
local function OUT(get,put)
put("OUT init")
while true do
local line,token,value=get()
print("",line,token,value)
put(line,token,value)
end
end
local function pipe(f,get,put)
put = put or coroutine.yield
local F=coroutine.wrap(f)
F(get,put)
return F
end
function FILTER(get,source) FILTER=pipe(OUT,pipe(IN,get)) end