summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-02-10 15:46:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-02-10 15:46:38 +0800
commitd4583feec1c19476428fce5cc8a8cf570db88ffd (patch)
tree890d8d70f4e822f414373e236befcb0720ae9b50 /script/parser
parent0dafb45dbbbd57d8f0938dfa7dc764884b1de388 (diff)
downloadlua-language-server-d4583feec1c19476428fce5cc8a8cf570db88ffd.zip
special goto for LuaJIT
fix #1895
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/compile.lua22
1 files changed, 17 insertions, 5 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index f563c6d0..9af8abf1 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -1379,12 +1379,24 @@ local function parseNumber()
return result
end
-local function isKeyWord(word)
+local function isKeyWord(word, nextToken)
if KeyWord[word] then
return true
end
if word == 'goto' then
- return State.version ~= 'Lua 5.1'
+ if State.version == 'Lua 5.1' then
+ return false
+ end
+ if State.version == 'LuaJIT' then
+ if not nextToken then
+ return true
+ end
+ if CharMapWord[ssub(nextToken, 1, 1)] then
+ return true
+ end
+ return false
+ end
+ return true
end
return false
end
@@ -1410,7 +1422,7 @@ local function parseName(asAction)
finish = finishPos,
}
end
- if isKeyWord(word) then
+ if isKeyWord(word, Tokens[Index]) then
pushError {
type = 'KEYWORD',
start = startPos,
@@ -1491,7 +1503,7 @@ local function parseExpList(mini)
break
end
local nextToken = peekWord()
- if isKeyWord(nextToken)
+ if isKeyWord(nextToken, Tokens[Index + 2])
and nextToken ~= 'function'
and nextToken ~= 'true'
and nextToken ~= 'false'
@@ -2223,7 +2235,7 @@ local function parseParams(params)
finish = getPosition(Tokens[Index] + #token - 1, 'right'),
}
end
- if isKeyWord(token) then
+ if isKeyWord(token, Tokens[Index + 2]) then
pushError {
type = 'KEYWORD',
start = getPosition(Tokens[Index], 'left'),