summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/parser/ast.lua30
-rw-r--r--server/src/parser/grammar.lua9
2 files changed, 25 insertions, 14 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index f8a16c54..f2356531 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -290,25 +290,37 @@ local defs = {
name.type = 'goto'
return name
end,
- IfBlock = function (exp, ...)
- return {
+ IfBlock = function (exp, start, ...)
+ local obj = {
filter = exp,
+ start = start,
...
}
+ local max = #obj
+ obj.finish = obj[max]
+ obj[max] = nil
+ return obj
end,
- ElseIfBlock = function (exp, ...)
- return {
+ ElseIfBlock = function (exp, start, ...)
+ local obj = {
filter = exp,
+ start = start,
...
}
+ local max = #obj
+ obj.finish = obj[max]
+ obj[max] = nil
+ return obj
end,
- ElseBlock = function (...)
- if ... == '' then
- return {}
- end
- return {
+ ElseBlock = function (start, ...)
+ local obj = {
+ start = start,
...
}
+ local max = #obj
+ obj.finish = obj[max]
+ obj[max] = nil
+ return obj
end,
If = function (start, ...)
local obj = {
diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua
index 0e7fa608..d4a7f648 100644
--- a/server/src/parser/grammar.lua
+++ b/server/src/parser/grammar.lua
@@ -339,15 +339,14 @@ If <- Sp ({} IfBody {})
-> If
IfBody <- (IfPart -> IfBlock)
(ElseIfPart -> ElseIfBlock)*
- ElsePart?
+ (ElsePart -> ElseBlock)?
END
IfPart <- IF Exp THEN
- Action*
+ {} Action* {}
ElseIfPart <- ELSEIF Exp THEN
- Action*
+ {} Action* {}
ElsePart <- ELSE
- Action*
- -> ElseBlock
+ {} Action* {}
For <- Loop / In