diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-03 19:33:29 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-03 19:33:29 +0800 |
commit | 5edda40151d5eed6605009346217d1da3bcb9ae6 (patch) | |
tree | d9f17a2e89b8be6a589d13d8dbe1f9c4d74ef0fa /server/src/parser | |
parent | 289a780f38c24a7ee0f4ca9502214b41fe11fc30 (diff) | |
download | lua-language-server-5edda40151d5eed6605009346217d1da3bcb9ae6.zip |
更新语法解析
Diffstat (limited to 'server/src/parser')
-rw-r--r-- | server/src/parser/ast.lua | 53 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 2 |
2 files changed, 42 insertions, 13 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 645d10e9..74f69d3c 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -283,19 +283,36 @@ local Defs = { end return '' end - if v < 0 or v > 0x10ffff then - pushError { - type = 'UTF8_MAX', - start = pos-3, - finish = pos+#char, - info = { - min = '000000', - max = '10ffff', + if State.Version == 'Lua 5.4' then + if v < 0 or v > 0x7FFFFFFF then + pushError { + type = 'UTF8_MAX', + start = pos-3, + finish = pos+#char, + info = { + min = '00000000', + max = '7FFFFFFF', + } } - } - return '' + return '' + end + else + if v < 0 or v > 0x10FFFF then + pushError { + type = 'UTF8_MAX', + start = pos-3, + finish = pos+#char, + version = v <= 0x7FFFFFFF and 'Lua 5.4' or nil, + info = { + min = '000000', + max = '10FFFF', + } + } + return '' + end + return utf8_char(v) end - return utf8_char(v) + return '' end, Number = function (start, number, finish) local n = tonumber(number) @@ -1188,13 +1205,25 @@ local Defs = { } return rtn, action end, + ToClose = function (start) + if State.Version == 'Lua 5.4' then + return + end + pushError { + type = 'TOCLOSE', + start = start, + finish = start + #'*toclose' - 1, + version = 'Lua 5.4', + } + end } -return function (self, lua, mode) +return function (self, lua, mode, version) Errs = {} State= { Break = 0, Label = {{}}, + Version = version, } local suc, res, err = pcall(self.grammar, lua, mode, Defs) if not suc then diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 7066a9e6..a1be48db 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -212,7 +212,7 @@ ASSIGN <- Sp '=' Nothing <- {} -> Nothing -TOCLOSE <- Sp '*toclose' +TOCLOSE <- Sp ({} '*toclose' Cut) -> ToClose DirtyBR <- BR {} / {} -> MissBR DirtyTR <- TR {} / {} -> MissTR |