[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to load a very large table with more than 2^18 literal strings?
- From: Peter Cawley <lua@...>
- Date: Fri, 7 Aug 2009 12:35:03 +0100
On Fri, Aug 7, 2009 at 10:37 AM, Jerome Vuarand<jerome.vuarand@gmail.com> wrote:
> This can be done easily with a couple gsub in the file content:
>
> function dofile(filename, ...)
> return assert(loadstring(assert(assert(io.open(filename,
> "rb")):read("*a")):gsub("{", "(function() return {"):gsub("}", "}
> end)()")))(...)
> end
>
> Loading will be a bit slower, but this should remove the limit.
>
This will work fine until you have curly braces within string
literals. If you want to do the transformation automatically, I'd
write a minimal LPEG parser to detect string literals and only perform
the replacement outside of them.