summaryrefslogtreecommitdiff
path: root/script/parser/compile.lua
diff options
context:
space:
mode:
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