1
0
Fork 0
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:
Étienne Fildadut 2022-09-16 21:40:45 +09:00
parent f0ecfbb43b
commit c43266260d
3 changed files with 37 additions and 13 deletions

View file

@ -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,7 +92,8 @@ 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)
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)
@ -100,6 +101,7 @@ common = {
return list[fqm], fqm
end
end
end
-- root namespace
name = replace_aliases(aliases, "", name)
if list[name] then
@ -111,7 +113,8 @@ common = {
-- returns a list of fqm
find_all = function(aliases, list, namespace, name)
local l = {}
local ns = common.split(namespace)
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)
@ -119,6 +122,7 @@ common = {
table.insert(l, fqm)
end
end
end
-- root namespace
name = replace_aliases(aliases, "", name)
if list[name] then

View file

@ -0,0 +1,6 @@
:$ f
:x = 5
:a = &f
{a.("x")}

View 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" }
]]--