summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-12-04 18:04:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-12-04 18:04:08 +0800
commit88b58826a4e84d5bc4c0cf99e544c5b4073cb198 (patch)
tree471174b237356472006bf461268be754d09fcb56 /script/parser
parent536c6148c4071ba4533da94948c81037322ae37d (diff)
downloadlua-language-server-88b58826a4e84d5bc4c0cf99e544c5b4073cb198.zip
fix #279 parser native supports negative number
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/compile.lua4
-rw-r--r--script/parser/grammar.lua5
-rw-r--r--script/parser/parse.lua2
3 files changed, 8 insertions, 3 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 56ce2489..1ba111ed 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -548,7 +548,9 @@ return function (self, lua, mode, version, options)
LocalCount = 0
Version = version
Root = state.ast
- Root.state = state
+ if Root then
+ Root.state = state
+ end
Options = options
state.ENVMode = ENVMode
if type(state.ast) == 'table' then
diff --git a/script/parser/grammar.lua b/script/parser/grammar.lua
index d0a0b252..ad107ef5 100644
--- a/script/parser/grammar.lua
+++ b/script/parser/grammar.lua
@@ -258,7 +258,7 @@ StringClose <- ']' =eq ']'
]]
grammar 'Number' [[
-Number <- Sp ({} {NumberDef} {}) -> Number
+Number <- Sp ({} {'-'? NumberDef} {}) -> Number
NumberSuffix?
ErrNumber?
NumberDef <- Number16 / Number10
@@ -534,6 +534,9 @@ return function (self, lua, mode)
local err = errorpos(pos)
return nil, err
end
+ if type(r) ~= 'table' then
+ return nil
+ end
return r
end
diff --git a/script/parser/parse.lua b/script/parser/parse.lua
index e4935e7a..909ce315 100644
--- a/script/parser/parse.lua
+++ b/script/parser/parse.lua
@@ -42,7 +42,7 @@ return function (self, lua, mode, version, options)
if not suc then
return nil, res
end
- if not res then
+ if not res and err then
state.pushError(err)
end
state.ast = res