mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Fix _._ operator not working with arbitrary expressions
This commit is contained in:
parent
f0ecfbb43b
commit
c43266260d
3 changed files with 37 additions and 13 deletions
|
|
@ -82,7 +82,7 @@ common = {
|
|||
--- split a string separated by .
|
||||
split = function(str)
|
||||
local address = {}
|
||||
for name in str:gmatch("[^%.]+") do
|
||||
for name in (str.."."):gmatch("(.-)%.") do
|
||||
table.insert(address, name)
|
||||
end
|
||||
return address
|
||||
|
|
@ -92,12 +92,14 @@ common = {
|
|||
-- returns value, fqm in case of success
|
||||
-- returns nil, err in case of error
|
||||
find = function(aliases, list, namespace, name)
|
||||
local ns = common.split(namespace)
|
||||
for i=#ns, 1, -1 do
|
||||
local current_namespace = table.concat(ns, ".", 1, i)
|
||||
local fqm = replace_aliases(aliases, current_namespace, name)
|
||||
if list[fqm] then
|
||||
return list[fqm], fqm
|
||||
if namespace ~= "" then
|
||||
local ns = common.split(namespace:gsub("%.$", ""))
|
||||
for i=#ns, 1, -1 do
|
||||
local current_namespace = table.concat(ns, ".", 1, i)
|
||||
local fqm = replace_aliases(aliases, current_namespace, name)
|
||||
if list[fqm] then
|
||||
return list[fqm], fqm
|
||||
end
|
||||
end
|
||||
end
|
||||
-- root namespace
|
||||
|
|
@ -111,12 +113,14 @@ common = {
|
|||
-- returns a list of fqm
|
||||
find_all = function(aliases, list, namespace, name)
|
||||
local l = {}
|
||||
local ns = common.split(namespace)
|
||||
for i=#ns, 1, -1 do
|
||||
local current_namespace = table.concat(ns, ".", 1, i)
|
||||
local fqm = replace_aliases(aliases, current_namespace, name)
|
||||
if list[fqm] then
|
||||
table.insert(l, fqm)
|
||||
if namespace ~= "" then
|
||||
local ns = common.split(namespace:gsub("%.$", ""))
|
||||
for i=#ns, 1, -1 do
|
||||
local current_namespace = table.concat(ns, ".", 1, i)
|
||||
local fqm = replace_aliases(aliases, current_namespace, name)
|
||||
if list[fqm] then
|
||||
table.insert(l, fqm)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- root namespace
|
||||
|
|
|
|||
6
test/tests/namespace operator arbitrary expression.ans
Normal file
6
test/tests/namespace operator arbitrary expression.ans
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:$ f
|
||||
:x = 5
|
||||
|
||||
:a = &f
|
||||
|
||||
{a.("x")}
|
||||
14
test/tests/namespace operator arbitrary expression.lua
Normal file
14
test/tests/namespace operator arbitrary expression.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={text="5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "5"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
Loading…
Add table
Add a link
Reference in a new issue