diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-18 17:28:21 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-18 17:28:21 +0800 |
commit | b45a90132438bb2d84b7376066e5ff409833a13f (patch) | |
tree | b87782402cd4c5f275aa880d1c9bd82b5b5b1103 /script/parser | |
parent | a7fcbe21fa6e06c46875fd8abb6d2eacb1db844e (diff) | |
download | lua-language-server-b45a90132438bb2d84b7376066e5ff409833a13f.zip |
update
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/guide.lua | 2 | ||||
-rw-r--r-- | script/parser/newparser.lua | 41 |
2 files changed, 24 insertions, 19 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index af623753..4a0ca21f 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -781,7 +781,7 @@ function m.offsetToPosition(state, offset) end break end - local start = lines[row] + local start = lines[row] - 1 if start > offset then right = row else 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) |