From 5edda40151d5eed6605009346217d1da3bcb9ae6 Mon Sep 17 00:00:00 2001 From: sumneko Date: Wed, 3 Apr 2019 19:33:29 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=AD=E6=B3=95=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/parser/ast.lua | 53 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'server/src/parser/ast.lua') 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 -- cgit v1.2.3