Improve Parser:block readability
@@ -316,10 +316,12 @@ function Parser:block_follow()
end
function Parser:Block(start)
+ local loc = start and start.loc or false
local stats = {}
- while true do
- while self:try(";") do --[[skip empty statement]] end
- if self:block_follow() then break end
+ while not self:block_follow() do
+ if self:try(";") then
+ -- skip empty statement
+ else
local stat = self:Stat()
local _ = self:try(";")
table.insert(stats, stat)
@@ -327,7 +329,7 @@ function Parser:Block(start)
break
end
end
- local loc = start and start.loc or false
+ end
return ast.Stat.Block(loc, stats)
end
