mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Fix empty list conversion to lua
This commit is contained in:
parent
14ba34f8fd
commit
861330475e
2 changed files with 6 additions and 6 deletions
|
|
@ -29,7 +29,7 @@ common = {
|
||||||
return nil, ("no formatter for type %q"):format(val.type)
|
return nil, ("no formatter for type %q"):format(val.type)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
-- lua value: if success
|
-- lua value: if success (may be nil!)
|
||||||
-- * nil, err: if error
|
-- * nil, err: if error
|
||||||
to_lua = function(val)
|
to_lua = function(val)
|
||||||
if atypes[val.type] and atypes[val.type].to_lua then
|
if atypes[val.type] and atypes[val.type].to_lua then
|
||||||
|
|
|
||||||
|
|
@ -102,13 +102,13 @@ types.anselme = {
|
||||||
for _, v in ipairs(val) do
|
for _, v in ipairs(val) do
|
||||||
if v.type == "pair" then
|
if v.type == "pair" then
|
||||||
local k, ke = to_lua(v.value[1])
|
local k, ke = to_lua(v.value[1])
|
||||||
if not k then return k, ke end
|
if not k and ke then return k, ke end
|
||||||
local x, xe = to_lua(v.value[2])
|
local x, xe = to_lua(v.value[2])
|
||||||
if not x then return x, xe end
|
if not x and xe then return x, xe end
|
||||||
l[k] = x
|
l[k] = x
|
||||||
else
|
else
|
||||||
local s, e = to_lua(v)
|
local s, e = to_lua(v)
|
||||||
if not s then return s, e end
|
if not s and e then return s, e end
|
||||||
table.insert(l, s)
|
table.insert(l, s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -125,9 +125,9 @@ types.anselme = {
|
||||||
end,
|
end,
|
||||||
to_lua = function(val)
|
to_lua = function(val)
|
||||||
local k, ke = to_lua(val[1])
|
local k, ke = to_lua(val[1])
|
||||||
if not k then return k, ke end
|
if not k and ke then return k, ke end
|
||||||
local v, ve = to_lua(val[2])
|
local v, ve = to_lua(val[2])
|
||||||
if not v then return v, ve end
|
if not v and ve then return v, ve end
|
||||||
return { [k] = v }
|
return { [k] = v }
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue