** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and ** print any results. */
| 404 | ** print any results. |
| 405 | */ |
| 406 | static void doREPL (lua_State *L) { |
| 407 | int status; |
| 408 | const char *oldprogname = progname; |
| 409 | progname = NULL; /* no 'progname' on errors in interactive mode */ |
| 410 | while ((status = loadline(L)) != -1) { |
| 411 | if (status == LUA_OK) |
| 412 | status = docall(L, 0, LUA_MULTRET); |
| 413 | if (status == LUA_OK) l_print(L); |
| 414 | else report(L, status); |
| 415 | } |
| 416 | lua_settop(L, 0); /* clear stack */ |
| 417 | lua_writeline(); |
| 418 | progname = oldprogname; |
| 419 | } |
| 420 | |
| 421 | |
| 422 | /* |