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