** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and ** print any results. */
| 582 | ** print any results. |
| 583 | */ |
| 584 | static void doREPL (lua_State *L) { |
| 585 | int status; |
| 586 | const char *oldprogname = progname; |
| 587 | progname = NULL; /* no 'progname' on errors in interactive mode */ |
| 588 | lua_initreadline(L); |
| 589 | while ((status = loadline(L)) != -1) { |
| 590 | if (status == LUA_OK) |
| 591 | status = docall(L, 0, LUA_MULTRET); |
| 592 | if (status == LUA_OK) l_print(L); |
| 593 | else report(L, status); |
| 594 | } |
| 595 | lua_settop(L, 0); /* clear stack */ |
| 596 | lua_writeline(); |
| 597 | progname = oldprogname; |
| 598 | } |
| 599 | |
| 600 | /* }================================================================== */ |
| 601 |