summaryrefslogtreecommitdiff
path: root/server/src/parser/ast.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/parser/ast.lua')
-rw-r--r--server/src/parser/ast.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index 6b555e07..cb3597fd 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -545,6 +545,20 @@ local Defs = {
finish = start + 2,
}
end,
+ DotsAsArg = function (obj)
+ State.Dots[#State.Dots] = true
+ return obj
+ end,
+ DotsAsExp = function (obj)
+ if not State.Dots[#State.Dots] then
+ pushError {
+ type = 'UNEXPECT_DOTS',
+ start = obj.start,
+ finish = obj.finish,
+ }
+ end
+ return obj
+ end,
COLON = function (start)
return {
type = ':',
@@ -982,12 +996,14 @@ local Defs = {
-- 不能jump到另一个局部变量的作用域
-- 函数会切断goto与label
-- 不能从block外jump到block内,但是可以从block内jump到block外
- LabelStart = function ()
+ BlockStart = function ()
State.Label[#State.Label+1] = {}
+ State.Dots[#State.Dots+1] = false
end,
- LabelEnd = function ()
+ BlockEnd = function ()
local labels = State.Label[#State.Label]
State.Label[#State.Label] = nil
+ State.Dots[#State.Dots] = nil
for i = 1, #labels do
local name = labels[i]
local str = name[1]
@@ -1567,6 +1583,7 @@ return function (self, lua, mode, version)
State= {
Break = 0,
Label = {{}},
+ Dots = {true},
Version = version,
}
local suc, res, err = xpcall(self.grammar, debug.traceback, self, lua, mode, Defs)