** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and ** print any results. */
| 550 | ** print any results. |
| 551 | */ |
| 552 | static void doREPL (lua_State *L) { |
| 553 | int status; |
| 554 | const char *oldprogname = progname; |
| 555 | progname = NULL; /* no 'progname' on errors in interactive mode */ |
| 556 | lua_initreadline(L); |
| 557 | while ((status = loadline(L)) != -1) { |
| 558 | if (status == LUA_OK) |
| 559 | status = docall(L, 0, LUA_MULTRET); |
| 560 | if (status == LUA_OK) l_print(L); |
| 561 | else report(L, status); |
| 562 | } |
| 563 | lua_settop(L, 0); /* clear stack */ |
| 564 | lua_writeline(); |
| 565 | progname = oldprogname; |
| 566 | } |
| 567 | |
| 568 | /* }================================================================== */ |
| 569 |