diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-29 15:07:19 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-29 15:07:19 +0800 |
commit | aadc150fc7d585fdb31d121e708acf1934dcf0e5 (patch) | |
tree | 6f82252f9165960015af6ab9ff20e827c6e27f1e /script/parser | |
parent | e4cc5406ee784e09d269abcc55488328a6c7e776 (diff) | |
download | lua-language-server-aadc150fc7d585fdb31d121e708acf1934dcf0e5.zip |
update parser
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/newparser.lua | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 8eb97b17..1b61cc39 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -367,6 +367,17 @@ local function skipNL() return false end +local function getSavePoint() + local index = Index + local line = Line + local lineOffset = LineOffset + return function () + Index = index + Line = line + LineOffset = lineOffset + end +end + local function fastForwardToken(offset) while true do local myOffset = Tokens[Index] @@ -1549,6 +1560,45 @@ 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() + 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 + savePoint() + end + local exp = parseExp(true) if exp then if wantSep then @@ -1565,33 +1615,6 @@ local function parseTable() exp.parent = tbl goto CONTINUE end - if exp.type == 'getlocal' - or exp.type == 'getglobal' then - skipSpace() - if expectAssign() then - local eqRight = lastRightPosition() - skipSpace() - local fvalue = parseExp() - local tfield = { - type = 'tablefield', - start = exp.start, - finish = fvalue and fvalue.finish or eqRight, - parent = tbl, - field = exp, - value = fvalue, - } - exp.type = 'field' - exp.parent = tfield - if fvalue then - fvalue.parent = tfield - else - missExp() - end - index = index + 1 - tbl[index] = tfield - goto CONTINUE - end - end index = index + 1 local texp = { type = 'tableexp', |