summaryrefslogtreecommitdiff
path: root/script/parser/newparser.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-18 17:28:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-18 17:28:21 +0800
commitb45a90132438bb2d84b7376066e5ff409833a13f (patch)
treeb87782402cd4c5f275aa880d1c9bd82b5b5b1103 /script/parser/newparser.lua
parenta7fcbe21fa6e06c46875fd8abb6d2eacb1db844e (diff)
downloadlua-language-server-b45a90132438bb2d84b7376066e5ff409833a13f.zip
update
Diffstat (limited to 'script/parser/newparser.lua')
-rw-r--r--script/parser/newparser.lua41
1 files changed, 23 insertions, 18 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua
index e0144dcd..99518261 100644
--- a/script/parser/newparser.lua
+++ b/script/parser/newparser.lua
@@ -207,21 +207,7 @@ local LocalLimit = 200
local parseExp, parseAction
-local function pushError(err)
- local errs = State.errs
- if err.finish < err.start then
- err.finish = err.start
- end
- local last = errs[#errs]
- if last then
- if last.start <= err.start and last.finish >= err.finish then
- return
- end
- end
- err.level = err.level or 'error'
- errs[#errs+1] = err
- return err
-end
+local pushError
local function addSpecial(name, obj)
local root = State.ast
@@ -3537,7 +3523,7 @@ local function initState(lua, version, options)
Chunk = {}
Tokens = tokens(lua)
Index = 1
- State = {
+ local state = {
version = version,
lua = lua,
ast = {},
@@ -3549,11 +3535,30 @@ local function initState(lua, version, options)
},
options = options or {},
}
+ State = state
if version == 'Lua 5.1' or version == 'LuaJIT' then
- State.ENVMode = '@fenv'
+ state.ENVMode = '@fenv'
else
- State.ENVMode = '_ENV'
+ state.ENVMode = '_ENV'
end
+
+ pushError = function (err)
+ local errs = state.errs
+ if err.finish < err.start then
+ err.finish = err.start
+ end
+ local last = errs[#errs]
+ if last then
+ if last.start <= err.start and last.finish >= err.finish then
+ return
+ end
+ end
+ err.level = err.level or 'error'
+ errs[#errs+1] = err
+ return err
+ end
+
+ state.pushError = pushError
end
return function (lua, mode, version, options)