lua-users home
lua-l archive

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


On 12/14/18 3:12 AM, nobody wrote:
> I think something like 0x2000_0000 (or 0x2000 in case 16-bit ints are a thing)
> is better, because generated code is something people do.

I'm for 2GiB limit too.

> A simple way to include any piece of textual data in a generated Lua script is
> to put it in a long string.  (You don't have "%q" outside of Lua.)  The simplest
> way to do that is to count the largest sequence of ='s in it and add one more in
> the separator.

Finding longest "=" sequence is arguably simplest and not optimal. I prefer
finding shortest long closing quote: min(N): ("]" "=" ^ N "]") not in string.

This algorithm have no worst cases.

Sample implementation at
https://github.com/martin-eden/workshop/blob/master/formats/lua/quote_string/intact.lua#L16

-- Martin