summaryrefslogtreecommitdiff
path: root/script/parser/compile.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-12-16 02:52:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-12-16 02:52:27 +0800
commit420197c19e223cf1c3ce33534abb38bba304896b (patch)
treec20350e1e5f138c466a868cc0d21e747f2255399 /script/parser/compile.lua
parent3c45587f84aee06d280ca1d5223cf49068a62fb7 (diff)
downloadlua-language-server-420197c19e223cf1c3ce33534abb38bba304896b.zip
new tracer
Diffstat (limited to 'script/parser/compile.lua')
-rw-r--r--script/parser/compile.lua45
1 files changed, 17 insertions, 28 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 73aef048..b8040382 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -3136,22 +3136,6 @@ local function parseGoTo()
return action
end
-local function parseFilter()
- local exp = parseExp()
- if exp then
- local filter = {
- type = 'filter',
- start = exp.start,
- finish = exp.finish,
- exp = exp,
- }
- exp.parent = filter
- return filter
- else
- missExp()
- end
-end
-
local function parseIfBlock(parent)
local ifLeft = getPosition(Tokens[Index], 'left')
local ifRight = getPosition(Tokens[Index] + 1, 'right')
@@ -3167,11 +3151,13 @@ local function parseIfBlock(parent)
}
}
skipSpace()
- local filter = parseFilter()
+ local filter = parseExp()
if filter then
ifblock.filter = filter
ifblock.finish = filter.finish
filter.parent = ifblock
+ else
+ missExp()
end
skipSpace()
local thenToken = Tokens[Index + 1]
@@ -3224,11 +3210,13 @@ local function parseElseIfBlock(parent)
}
Index = Index + 2
skipSpace()
- local filter = parseFilter()
+ local filter = parseExp()
if filter then
elseifblock.filter = filter
elseifblock.finish = filter.finish
filter.parent = elseifblock
+ else
+ missExp()
end
skipSpace()
local thenToken = Tokens[Index + 1]
@@ -3536,16 +3524,15 @@ local function parseWhile()
skipSpace()
local nextToken = Tokens[Index + 1]
- if nextToken == 'do'
- or nextToken == 'then' then
- missExp()
+ local filter = nextToken ~= 'do'
+ and nextToken ~= 'then'
+ and parseExp()
+ if filter then
+ action.filter = filter
+ action.finish = filter.finish
+ filter.parent = action
else
- local filter = parseFilter()
- if filter then
- action.filter = filter
- action.finish = filter.finish
- filter.parent = action
- end
+ missExp()
end
skipSpace()
@@ -3624,10 +3611,12 @@ local function parseRepeat()
Index = Index + 2
skipSpace()
- local filter = parseFilter()
+ local filter = parseExp()
if filter then
action.filter = filter
filter.parent = action
+ else
+ missExp()
end
else