summaryrefslogtreecommitdiff
path: root/script/parser/parse.lua
diff options
context:
space:
mode:
authorArcanox <arcanox@arcanox.me>2021-09-25 18:00:15 -0500
committerArcanox <arcanox@arcanox.me>2021-09-25 18:00:15 -0500
commitdc685d1addad2f2e57f55a20bb6cca79c222c130 (patch)
treeabb200fd7f217460a4543cb6f32af7ebac308bc0 /script/parser/parse.lua
parenta465b35d5eefc11c1daf3c29b41ce95ee098a782 (diff)
parent1f0a2d0e9283a4cb7f7b3fc72258eb1c5ba4e5dd (diff)
downloadlua-language-server-dc685d1addad2f2e57f55a20bb6cca79c222c130.zip
Merge branch 'master' into improve-semantic-highlighting
# Conflicts: # script/core/semantic-tokens.lua
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