diff options
author | sumneko <sumneko@hotmail.com> | 2019-05-15 20:46:58 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-05-15 20:46:58 +0800 |
commit | e15d9d2c66da5d49b7ff5c389475ee552f372a6a (patch) | |
tree | 3a4679fc1a7f7863841f547793bfe10b57ba271f /server/src/parser/ast.lua | |
parent | 4c8343180670d2d36cd68bddd2941f942d39e311 (diff) | |
download | lua-language-server-e15d9d2c66da5d49b7ff5c389475ee552f372a6a.zip |
更新语法检查
Diffstat (limited to 'server/src/parser/ast.lua')
-rw-r--r-- | server/src/parser/ast.lua | 21 |
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) |