diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-07 17:54:12 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-07 17:54:12 +0800 |
commit | 66efb393005836da8d94b2aeef9ab7204915b493 (patch) | |
tree | 88431eb0a327cd4e1ef9d6e9f3318712579ae4a6 /script/parser | |
parent | 6194e11b4153a4fba16a5ba15876581b8d3cde43 (diff) | |
download | lua-language-server-66efb393005836da8d94b2aeef9ab7204915b493.zip |
update semantic-tokens
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/newparser.lua | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index b7868646..33187ee2 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -926,6 +926,7 @@ local function parseShortString() Index = Index + 2 local stringIndex = 0 local currentOffset = startOffset + 1 + local escs = {} while true do local token = Tokens[Index + 1] if token == mark then @@ -954,13 +955,18 @@ local function parseShortString() if not Tokens[Index] then goto CONTINUE end + local escLeft = getPosition(currentOffset, 'left') -- has space? if Tokens[Index] - currentOffset > 1 then + local right = getPosition(currentOffset + 1, 'right') pushError { type = 'ERR_ESC', - start = getPosition(currentOffset, 'left'), - finish = getPosition(currentOffset + 1, 'right'), + start = escLeft, + finish = right, } + escs[#escs+1] = escLeft + escs[#escs+1] = right + escs[#escs+1] = 'err' goto CONTINUE end local nextToken = ssub(Tokens[Index + 1], 1, 1) @@ -969,6 +975,9 @@ local function parseShortString() stringPool[stringIndex] = EscMap[nextToken] currentOffset = Tokens[Index] + #nextToken Index = Index + 2 + escs[#escs+1] = escLeft + escs[#escs+1] = escLeft + 2 + escs[#escs+1] = 'normal' goto CONTINUE end if nextToken == mark then @@ -976,12 +985,18 @@ local function parseShortString() stringPool[stringIndex] = mark currentOffset = Tokens[Index] + #nextToken Index = Index + 2 + escs[#escs+1] = escLeft + escs[#escs+1] = escLeft + 2 + escs[#escs+1] = 'normal' goto CONTINUE end if nextToken == 'z' then Index = Index + 2 repeat until not skipNL() currentOffset = Tokens[Index] + escs[#escs+1] = escLeft + escs[#escs+1] = escLeft + 2 + escs[#escs+1] = 'normal' goto CONTINUE end if CharMapNumber[nextToken] then @@ -991,13 +1006,21 @@ local function parseShortString() end currentOffset = Tokens[Index] + #numbers fastForwardToken(currentOffset) + local right = getPosition(currentOffset - 1, 'right') local byte = tointeger(numbers) if byte <= 255 then stringIndex = stringIndex + 1 stringPool[stringIndex] = schar(byte) else - -- TODO pushError + pushError { + type = 'ERR_ESC', + start = escLeft, + finish = right, + } end + escs[#escs+1] = escLeft + escs[#escs+1] = right + escs[#escs+1] = 'byte' goto CONTINUE end if nextToken == 'x' then @@ -1016,6 +1039,10 @@ local function parseShortString() finish = getPosition(currentOffset + 1, 'right'), } end + local right = getPosition(currentOffset + 1, 'right') + escs[#escs+1] = escLeft + escs[#escs+1] = right + escs[#escs+1] = 'byte' if State.version == 'Lua 5.1' then pushError { type = 'ERR_ESC', @@ -1038,6 +1065,10 @@ local function parseShortString() end currentOffset = newOffset fastForwardToken(currentOffset - 1) + local right = getPosition(currentOffset + 1, 'right') + escs[#escs+1] = escLeft + escs[#escs+1] = right + escs[#escs+1] = 'unicode' goto CONTINUE end if NLMap[nextToken] then @@ -1045,13 +1076,21 @@ local function parseShortString() stringPool[stringIndex] = '\n' currentOffset = Tokens[Index] + #nextToken skipNL() + local right = getPosition(currentOffset + 1, 'right') + escs[#escs+1] = escLeft + escs[#escs+1] = right + escs[#escs+1] = 'normal' goto CONTINUE end + local right = getPosition(currentOffset + 1, 'right') pushError { type = 'ERR_ESC', - start = getPosition(currentOffset, 'left'), - finish = getPosition(currentOffset + 1, 'right'), + start = escLeft, + finish = right, } + escs[#escs+1] = escLeft + escs[#escs+1] = right + escs[#escs+1] = 'err' end Index = Index + 2 ::CONTINUE:: @@ -1061,6 +1100,7 @@ local function parseShortString() type = 'string', start = startPos, finish = lastRightPosition(), + escs = #escs > 0 and escs or nil, [1] = stringResult, [2] = mark, } |