[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Lua 5.2 - How do I resume an interrupted parse?
- From: <StephenSimpson@...>
- Date: Mon, 30 Jan 2012 15:12:51 -0500
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
blocks.
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.
Taa
-- 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
quote.)
>
> --
> Sent from my toaster.