lua-users home
lua-l archive

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


On May 15, 2012, at 3:55 PM, Luiz Henrique de Figueiredo wrote:

>> I think I'm looking for some insight on how lua.c, for example, passes fragments of lua in and can tell they aren't complete chunks yet.
> 
> See http://www.lua.org/source/5.2/lua.c.html#loadline
> 
Ok, thanks. I'm trying to get my head around it - new to lua and the stack etc. The way I see it, it accumulates lines, adding them together along with a newline between them. And it runs lua_loadbuffer on them?

The key, AFAICT, is the 'incomplete' function, which checks the status of the load buffer call, and looks for '<eof>' at the end of the status, in which case it buffers it.

Is that about right?

So if in my code I run loadbuffer (or luaL_loadstring) and check it's status, then only run pcall when there is not an <eof> I should be OK?

Is there some sort of reset for that? So if the user messes up I could start over, not get trapped evaluating a broken buffer for ever?

Bruce