From 1a78d51e0580bfb19d07353bc7228bad37639839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 3 Dec 2018 20:29:02 +0800 Subject: =?UTF-8?q?=E6=8D=A2=E4=B8=AA=E6=96=B9=E6=B3=95=E5=AE=9E=E7=8E=B0m?= =?UTF-8?q?etatable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/definition.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'server/src/matcher/definition.lua') diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 41556745..794788e8 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -37,6 +37,26 @@ local function findResult(results, pos) return nil end +local function tryMeta(var) + local keys = {} + repeat + if var.childs.meta then + local metavar = var.childs.meta + for i = #keys, 1, -1 do + local key = keys[i] + metavar = metavar.childs[key] + if not metavar then + return nil + end + end + return metavar + end + keys[#keys+1] = var.key + var = var.parent + until not var + return nil +end + local function parseResult(result) local positions = {} local tp = result.type @@ -54,6 +74,14 @@ local function parseResult(result) positions[#positions+1] = {info.source.start, info.source.finish} end end + local metavar = tryMeta(var) + if metavar then + for _, info in ipairs(metavar) do + if info.type == 'set' then + positions[#positions+1] = {info.source.start, info.source.finish} + end + end + end else error('unknow var.type:' .. var.type) end -- cgit v1.2.3