diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-29 15:36:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-29 15:36:49 +0800 |
commit | 75a715f07b26f5a377dcb6d8daba1c8c118ae161 (patch) | |
tree | 8d78090fc411616a7452c51f731e492805a2127f /script/parser | |
parent | 17ed035be3da43e9039e70786db1665fd59b6736 (diff) | |
download | lua-language-server-75a715f07b26f5a377dcb6d8daba1c8c118ae161.zip |
fix incorrect syntax error
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/newparser.lua | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 1b61cc39..513868b0 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -371,10 +371,15 @@ local function getSavePoint() local index = Index local line = Line local lineOffset = LineOffset + local errs = State.errs + local errCount = #errs return function () Index = index Line = line LineOffset = lineOffset + for i = errCount + 1, #errs do + errs[i] = nil + end end end @@ -1560,41 +1565,43 @@ local function parseTable() end local lastRight = lastRightPosition() - local savePoint = getSavePoint() - local name = parseName() - if name then - skipSpace() - if Tokens[Index + 1] == '=' then - Index = Index + 2 - if wantSep then - pushError { - type = 'MISS_SEP_IN_TABLE', - start = lastRight, - finish = getPosition(Tokens[Index], 'left'), - } - end - wantSep = true - local eqRight = lastRightPosition() + if peekWord() then + local savePoint = getSavePoint() + local name = parseName() + if name then skipSpace() - local fvalue = parseExp() - local tfield = { - type = 'tablefield', - start = name.start, - finish = fvalue and fvalue.finish or eqRight, - parent = tbl, - field = name, - value = fvalue, - } - name.type = 'field' - name.parent = tfield - if fvalue then - fvalue.parent = tfield - else - missExp() + if Tokens[Index + 1] == '=' then + Index = Index + 2 + if wantSep then + pushError { + type = 'MISS_SEP_IN_TABLE', + start = lastRight, + finish = getPosition(Tokens[Index], 'left'), + } + end + wantSep = true + local eqRight = lastRightPosition() + skipSpace() + local fvalue = parseExp() + local tfield = { + type = 'tablefield', + start = name.start, + finish = fvalue and fvalue.finish or eqRight, + parent = tbl, + field = name, + value = fvalue, + } + name.type = 'field' + name.parent = tfield + if fvalue then + fvalue.parent = tfield + else + missExp() + end + index = index + 1 + tbl[index] = tfield + goto CONTINUE end - index = index + 1 - tbl[index] = tfield - goto CONTINUE end savePoint() end |