summaryrefslogtreecommitdiff
path: root/src/matcher
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-10-11 11:23:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-10-11 11:23:39 +0800
commit6ca08827d3e4e509841ffad2a57f179348ef65c6 (patch)
tree0287695631ce1116e05542991c9f727c526e3ded /src/matcher
parentbac22164fab3e3491af294f3357c8ba6d2e238ad (diff)
downloadlua-language-server-6ca08827d3e4e509841ffad2a57f179348ef65c6.zip
for
Diffstat (limited to 'src/matcher')
-rw-r--r--src/matcher/definition.lua47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/matcher/definition.lua b/src/matcher/definition.lua
index 41ad9f8a..91b5090f 100644
--- a/src/matcher/definition.lua
+++ b/src/matcher/definition.lua
@@ -13,9 +13,9 @@ local function scopeInit()
scopes = {{}}
end
-local function scopeSet(name, p)
+local function scopeSet(name)
local scope = scopes[#scopes]
- scope[name] = p
+ scope[name[1]] = name[2]
end
local function scopeGet(name)
@@ -50,23 +50,22 @@ function defs.Name(p, str)
end
function defs.LocalVar(name)
- scopeSet(name[1], name[2])
+ scopeSet(name)
end
function defs.LocalSet(name)
- scopeSet(name[1], name[2])
+ scopeSet(name)
end
function defs.Function(func)
local names = func.name
if names and #names == 1 then
- local name = names[1]
- scopeSet(name[1], name[2])
+ scopeSet(names[1])
end
return func
end
-function defs.DoStart()
+function defs.DoDef()
scopePush()
end
@@ -74,7 +73,7 @@ function defs.Do()
scopePop()
end
-function defs.IfStart()
+function defs.IfDef()
scopePush()
end
@@ -82,7 +81,7 @@ function defs.If()
scopePop()
end
-function defs.ElseIfStart()
+function defs.ElseIfDef()
scopePush()
end
@@ -90,7 +89,7 @@ function defs.ElseIf()
scopePop()
end
-function defs.ElseStart()
+function defs.ElseDef()
scopePush()
end
@@ -98,6 +97,34 @@ function defs.Else()
scopePop()
end
+function defs.LoopDef(name)
+ scopePush()
+ scopeSet(name)
+end
+
+function defs.Loop()
+ scopePop()
+end
+
+function defs.LoopStart(name, exp)
+ return name
+end
+
+function defs.InList(...)
+ return {...}
+end
+
+function defs.InDef(names)
+ scopePush()
+ for _, name in ipairs(names) do
+ scopeSet(name)
+ end
+end
+
+function defs.In()
+ scopePop()
+end
+
return function (buf, pos_)
pos = pos_
result = nil