lua-users home
lua-l archive

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


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.