lua-users home
lua-l archive

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


Thanks Pierre,

I started with the standalone interpreter code.  It's nice but..
the example interactive terminal is very "line based".  I want
the code to execute whenever it can be executed.

To get a touchy-feely for it, imagine the existing interpreter (lua.c)
being -- force fed -- data from a named pipe.  It would work, but
it would also add imo unnecessary overhead with all the search
for <LF>, parse to <LF>, execute if parsed ok, etc. etc. stuff in lua.c

I essentially want a streamable parse-and-run interface, but it looks like the
lua parser is not geared up for that.  I'm not sure how to express this
but the "and-run" bit is basically "execute the stack is whenever it becomes "runnable"
The parser-tokeniser would feed the stack and as soon as the stack gets to an
executable state, the lua runtime would execute it.

Now I may be barking up the wrong tree here (being a noob)!!
So I'm really open to suggestions. :-)

I'm resisting the urge to retrofit this support to Lua, which is a very tidy piece of work btw!

I will revert to this line-by-line approach if I have to...
but this means that I'll be repeating part of the Lua parser in my comms stack,
which seems dumb to me.

I hope you guys understand.

-- Steve

> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Pierre-Yves Gérardy
> Sent: Thursday, 2 February 2012 4:36 a.m.
> To: Lua mailing list
> Subject: Re: Lua 5.2 - How do I resume an interrupted parse?
> 
> On Mon, Jan 30, 2012 at 01:00, <StephenSimpson@eaton.com> wrote:
> >
> > Typical telnet daemons are terminal centric, ie. the daemon responds
> > to data "committed" by a user hitting  <Enter>.
> > I want the daemon to handle this traditional line-by-line input, AND
> > big but potentially syntactically incomplete blocks from eg. a pipe
> > directed to a ptty.
> >
> > Is it possible to drive the Lua API so that a parse can be "put on ice"
> > while waiting for the arrival of new data from the comms stack.
> >
> > ...
> >
> > Is there some "approved" way of detecting the "incomplete source"
> > syntax error AND storing the mid-parse Lua state so that I can simply
> > resume once more data arrives???
> 
>  You may want to have a look at how the standalone interpreter does it.
> 
> http://www.lua.org/source/5.2/lua.c.html
> 
> -- Pierre-Yves