lua-users home
lua-l archive

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

Thanks HyperHacker,

Yes, your example will work in general, but it won't work for me.
The source code data is not stored contiguously in memory, it's in
I need to serialise the data for the parser with a lua_Reader.

The other thing is that checking for "near <eof>" on the return stack
looks a bit ugly to me, since the "<eof>" actually comes from a static
array in llex.c.
See my OP.


-- Steve

> local code = ''
> while true do
>     code = code .. readSomeData()
>     if loadstring(code) then break --parse was successful
>     else print("Incomplete or invalid code")
>     end
> end
> If you need to detect unfinished source specifically, I suppose you
could look
> at the error message from loadstring() for key words like "near
<eof>". (And
> then, you have to ask yourself if there's a risk of someone messing
things up
> by sending a string like [[ x "near <eof> ]]; note the missing end
> --
> Sent from my toaster.