From 1e07791ab99b76f5f2b01b1ad1d470272cd662ae Mon Sep 17 00:00:00 2001 From: sumneko Date: Wed, 10 Apr 2019 09:49:46 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0LuaParser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/parser/ast.lua | 9 ++++++--- server/src/parser/grammar.lua | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'server/src') diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 508252ae..8bb12959 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -298,12 +298,15 @@ local Defs = { start = pos-1, finish = pos, } - return '' + return char end return string_char(tonumber(char, 16)) end, CharUtf8 = function (pos, char) - if State.Version ~= 'Lua 5.3' and State.Version ~= 'Lua 5.4' then + if State.Version ~= 'Lua 5.3' + and State.Version ~= 'Lua 5.4' + and State.Version ~= 'LuaJIT' + then pushError { type = 'ERR_ESC', start = pos-3, @@ -425,8 +428,8 @@ local Defs = { version = State.Version, } } - State.LastNumber[1] = 0 end + State.LastNumber[1] = 0 end, Name = function (start, str, finish) local isKeyWord diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 656f98da..d0a2baaf 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -255,10 +255,11 @@ StringClose <- ']' =eq ']' grammar 'Number' [[ Number <- Sp ({} {NumberDef} {}) -> Number NumberSuffix? + ErrNumber? NumberDef <- Number16 / Number10 NumberSuffix<- ({} {[uU]? [lL] [lL]}) -> FFINumber / ({} {[iI]}) -> ImaginaryNumber - / ({} {([0-9a-zA-Z] / '.')+}) -> UnknownSymbol +ErrNumber <- ({} {([0-9a-zA-Z] / '.')+}) -> UnknownSymbol Number10 <- Float10 Float10Exp? / Integer10 Float10? Float10Exp? -- cgit v1.2.3