summaryrefslogtreecommitdiff
path: root/script/parser/parse.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-14 16:59:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-14 16:59:55 +0800
commit2a29458c86628a2af20da4ebeb39a8f81d4ea53a (patch)
tree92d337224429ab516ec2271b117319c5d5916452 /script/parser/parse.lua
parent321fc84cabff0252f25e94df14746b8e9cb3d190 (diff)
downloadlua-language-server-2a29458c86628a2af20da4ebeb39a8f81d4ea53a.zip
update parser
Diffstat (limited to 'script/parser/parse.lua')
-rw-r--r--script/parser/parse.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/script/parser/parse.lua b/script/parser/parse.lua
index 9b8d5496..e7c7d177 100644
--- a/script/parser/parse.lua
+++ b/script/parser/parse.lua
@@ -1,6 +1,7 @@
-local ast = require 'parser.ast'
+local ast = require 'parser.ast'
+local grammar = require 'parser.grammar'
-return function (self, lua, mode, version, options)
+local function buildState(lua, version, options)
local errs = {}
local diags = {}
local comms = {}
@@ -36,9 +37,19 @@ return function (self, lua, mode, version, options)
comms[#comms+1] = comment
end
}
+ if version == 'Lua 5.1' or version == 'LuaJIT' then
+ state.ENVMode = '@fenv'
+ else
+ state.ENVMode = '_ENV'
+ end
+ return state
+end
+
+return function (lua, mode, version, options)
+ local state = buildState(lua, version, options)
local clock = os.clock()
ast.init(state)
- local suc, res, err = xpcall(self.grammar, debug.traceback, self, lua, mode)
+ local suc, res, err = xpcall(grammar, debug.traceback, lua, mode)
ast.close()
if not suc then
return nil, res