lua-users home
lua-l archive

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


On 16-06-30 06:53 PM, Hisham wrote:
> On 1 July 2016 at 07:34, Martin <eden_martin_fuhrspam@gmx.de> wrote:
>> In lua key-value pair in table may be defined as
>>
>>   "[" <expr> "]" "=" <expr>
>>
>> How you this is correctly to handle cases like "[[[\]]] = [[\\]]"
>> (mapping backspace to quoted version)? For me it looks like syntax flaw.
> 
> You can avoid this by adding a space:
> 
> t = { [ [[\]] ] = [[\\]] }

Surely, when writing by hand. By I'm writing serializer. In recursive
function serialize(node) key-vals serialization is like

io.write("[", serialize(key), "]", " = ", serialize(value), ",", "\n")

Of course I may change "[" to "[ " but spaces will be added for all
indexed keys and result will be really ugly. So I had to change code and
pass additional silly flag "guy, you're inside indexed key. If your data
first char is '[', write space before writing it".