summaryrefslogtreecommitdiff
path: root/src/matcher/definition.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-10-11 10:57:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-10-11 10:57:28 +0800
commitbac22164fab3e3491af294f3357c8ba6d2e238ad (patch)
tree729cd28bfef050f4a9d92e572d89b760f8cc0468 /src/matcher/definition.lua
parente574b0b2ef33e8f456abe7d5c48c925701c9df8f (diff)
downloadlua-language-server-bac22164fab3e3491af294f3357c8ba6d2e238ad.zip
if和do
Diffstat (limited to 'src/matcher/definition.lua')
-rw-r--r--src/matcher/definition.lua42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/matcher/definition.lua b/src/matcher/definition.lua
index 35de5ab4..41ad9f8a 100644
--- a/src/matcher/definition.lua
+++ b/src/matcher/definition.lua
@@ -20,7 +20,7 @@ end
local function scopeGet(name)
for i = #scopes, 1, -1 do
- local scope = scopes[#scopes]
+ local scope = scopes[i]
local p = scope[name]
if p then
return p
@@ -29,6 +29,14 @@ local function scopeGet(name)
return nil
end
+local function scopePush()
+ scopes[#scopes+1] = {}
+end
+
+local function scopePop()
+ scopes[#scopes] = nil
+end
+
local function checkDifinition(name, p)
if pos < p or pos > p + #name then
return
@@ -58,6 +66,38 @@ function defs.Function(func)
return func
end
+function defs.DoStart()
+ scopePush()
+end
+
+function defs.Do()
+ scopePop()
+end
+
+function defs.IfStart()
+ scopePush()
+end
+
+function defs.If()
+ scopePop()
+end
+
+function defs.ElseIfStart()
+ scopePush()
+end
+
+function defs.ElseIf()
+ scopePop()
+end
+
+function defs.ElseStart()
+ scopePush()
+end
+
+function defs.Else()
+ scopePop()
+end
+
return function (buf, pos_)
pos = pos_
result = nil