diff options
-rw-r--r-- | server/src/parser/ast.lua | 46 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 7 |
2 files changed, 48 insertions, 5 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 3e8bc22a..508252ae 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -366,24 +366,66 @@ local Defs = { Number = function (start, number, finish) local n = tonumber(number) if n then - return { + State.LastNumber = { type = 'number', start = start, finish = finish - 1, [1] = n, } + return State.LastNumber else pushError { type = 'MALFORMED_NUMBER', start = start, finish = finish - 1, } - return { + State.LastNumber = { type = 'number', start = start, finish = finish - 1, [1] = 0, } + return State.LastNumber + end + end, + FFINumber = function (start, symbol) + if math.type(State.LastNumber[1]) == 'float' then + pushError { + type = 'UNKNOWN_SYMBOL', + start = start, + finish = start + #symbol - 1, + info = { + symbol = symbol, + } + } + State.LastNumber[1] = 0 + return + end + if State.Version ~= 'LuaJIT' then + pushError { + type = 'UNSUPPORT_SYMBOL', + start = start, + finish = start + #symbol - 1, + version = 'LuaJIT', + info = { + version = State.Version, + } + } + State.LastNumber[1] = 0 + end + end, + ImaginaryNumber = function (start, symbol) + if State.Version ~= 'LuaJIT' then + pushError { + type = 'UNSUPPORT_SYMBOL', + start = start, + finish = start + #symbol - 1, + version = 'LuaJIT', + info = { + version = State.Version, + } + } + State.LastNumber[1] = 0 end end, Name = function (start, str, finish) diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 9185b5b6..656f98da 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -254,10 +254,11 @@ StringClose <- ']' =eq ']' grammar 'Number' [[ Number <- Sp ({} {NumberDef} {}) -> Number - ErrNumber? + NumberSuffix? NumberDef <- Number16 / Number10 -ErrNumber <- ({} {([0-9a-zA-Z] / '.')+}) - -> UnknownSymbol +NumberSuffix<- ({} {[uU]? [lL] [lL]}) -> FFINumber + / ({} {[iI]}) -> ImaginaryNumber + / ({} {([0-9a-zA-Z] / '.')+}) -> UnknownSymbol Number10 <- Float10 Float10Exp? / Integer10 Float10? Float10Exp? |