luaL_newstate(); //create new stack L
lua_pushcfunction(L, &pmain); //push pmin into L
lua_pushinteger(L, argc); //push argc into L
lua_pushlightuserdata(L, argv); //push argv into L
status = lua_pcall(L, 2, 1, 0); //call top function from L
result = lua_toboolean(L, -1); //get function result form L
report(L, status); //print error from Lwhen result not ok
lua_close(L); //clear all inL
lua.c:553 pmain()
int argc = (int)lua_tointeger(L, 1); //get argc from Lchar **argv = (char **)lua_touserdata(L, 2); //get argv from Lint args = collectargs(argv, &script); //decode argv to args(mask with [error,-i,-v,-e,-E])
args == has_error //when argv has error
args & has_v //-v to show lua version
args & has_E //-E to ignore env vars(use std lib)
runargs(L, argv, script) //check -e and -l
handle_script(L, argv + script) //run script from L
args & has_i //-i to do read-eval-print loop
lua_stdin_is_tty() //run from shell
dofile(L, NULL) //run from file
lua_pushboolean(L, 1) //write ok/error to L
lua.c:436 handle_script()
constchar *fname = argv[0]; //script file name
status = luaL_loadfile(L, fname); //read file and push into Lint n = pushargs(L); //push arguments to script in L
status = docall(L, n, LUA_MULTRET); //run code from L