lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, 1 Jul 2013 17:39:39 -0700
Milind Gupta <milind.gupta@gmail.com> wrote:

> 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.)

lua-repl (https://github.com/hoelzro/lua-repl) which Harley was so
kind to mention handles this case for you.  It also provides other
features, so I recommend you give it a shot!  If you have problems or
questions about it, please feel free to e-mail me or ask on #lua (I'm
usually there).

-Rob

Attachment: signature.asc
Description: PGP signature