diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-04-05 19:30:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-04-05 19:30:57 +0800 |
commit | 5d2aee69ef5edd7e3890997cf652cc60737a330f (patch) | |
tree | 9f3e5aaa23d7ed1db71451526befccc2248d0f82 /server/src/parser/ast.lua | |
parent | 5ed7ded384aca2cff4d09401cc852f7943a1ea94 (diff) | |
download | lua-language-server-5d2aee69ef5edd7e3890997cf652cc60737a330f.zip |
更新Lua解析
Diffstat (limited to 'server/src/parser/ast.lua')
-rw-r--r-- | server/src/parser/ast.lua | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 1d4d6a23..57d88b0c 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -44,6 +44,36 @@ local RESERVED = { ['while'] = true, } +local VersionOp = { + ['&'] = {'Lua 5.3', 'Lua 5.4'}, + ['~'] = {'Lua 5.3', 'Lua 5.4'}, + ['|'] = {'Lua 5.3', 'Lua 5.4'}, + ['<<'] = {'Lua 5.3', 'Lua 5.4'}, + ['>>'] = {'Lua 5.3', 'Lua 5.4'}, + ['//'] = {'Lua 5.3', 'Lua 5.4'}, +} + +local function checkOpVersion(op, start) + local versions = VersionOp[op] + if not versions then + return + end + for i = 1, #versions do + if versions[i] == State.Version then + return + end + end + pushError { + type = 'UNSUPPORT_SYMBOL', + start = start, + finish = start + #op - 1, + version = versions, + info = { + version = State.Version, + } + } +end + local Exp local function expSplit(list, start, finish, level) @@ -71,6 +101,7 @@ local function binaryForward(list, start, finish, level) if not e2 then goto CONTINUE end + checkOpVersion(op, list[i-1]) return { type = 'binary', op = op, @@ -98,6 +129,7 @@ local function binaryBackward(list, start, finish, level) if not e2 then goto CONTINUE end + checkOpVersion(op, list[i-1]) return { type = 'binary', op = op, @@ -118,6 +150,7 @@ local function unary(list, start, finish, level) if info[op] then local e1 = expSplit(list, start+2, finish, level) if e1 then + checkOpVersion(op, list[start]) return { type = 'unary', op = op, @@ -1210,7 +1243,7 @@ local Defs = { return end pushError { - type = 'TOCLOSE', + type = 'UNSUPPORT_SYMBOL', start = start, finish = start + #'*toclose' - 1, version = 'Lua 5.4', |