Thanks for the reply. I looked at the Lua source code already. But since that is in C it runs a lua state and effectively when the code is executed the lua state is in pause at least that is how I understood it which means that if you write an incomplete statement and execute it with pcall the lua state is still waiting for the remaining statement but if you are already in a lua state you load a string and that returns you a function so there is no direct way to know if you are ready to execute the input or not i.e. whether the input is a complete statement or incomplete. Any simple work arounds?
Thanks,
Milind
On Monday, July 01, 2013 05:15:35 PM Milind Gupta wrote:
> Hi,
> I have a Lua program and I want to provide a terminal to the user which
> can be used as a lua interpreter command line, so that the user can control
> the program using that command line and lua code from that terminal. How do
> I make the interpreter command line in Lua to accommodate incomplete lines?
>
> Thanks,
> Milin
What it kind of sounds like you're wanting is a Lua REPL (Read–eval–print
loop) similar to running lua without any arguments. If that's the case, you
may want to look at https://github.com/hoelzro/lua-repl as well (it's under a
permissive license.) Otherwise, you can look directly at the lua source code
to see how it's implemented (in src/lua.c if memory serves.)