// A bare-bones Lua interpreter, in C. #include #include #include "lua.h" #include "lauxlib.h" #include "lualib.h" int main() { // Start our Lua run-time state and load the standard libraries. lua_State *L = luaL_newstate(); luaL_openlibs(L); // Read-parse(load)-evaluate(call). In a loop. char buff[2048]; while ((fgets(buff, sizeof(buff), stdin))) { luaL_loadstring(L, buff); lua_pcall(L, 0, 0, 0); } // Clean up the lua run-time state and exit. lua_close(L); return 0; }