summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/parser/ast.lua53
-rw-r--r--server/src/parser/grammar.lua2
-rw-r--r--server/src/service.lua2
-rw-r--r--server/test/completion/init.lua2
-rw-r--r--server/test/definition/init.lua2
-rw-r--r--server/test/diagnostics/init.lua2
-rw-r--r--server/test/document_symbol/init.lua2
-rw-r--r--server/test/find_lib/init.lua2
-rw-r--r--server/test/full/init.lua2
-rw-r--r--server/test/highlight/init.lua2
-rw-r--r--server/test/hover/init.lua2
-rw-r--r--server/test/references/init.lua2
-rw-r--r--server/test/rename/init.lua2
-rw-r--r--server/test/signature/init.lua2
-rw-r--r--server/test/type_inference/init.lua2
15 files changed, 55 insertions, 26 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index 645d10e9..74f69d3c 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -283,19 +283,36 @@ local Defs = {
end
return ''
end
- if v < 0 or v > 0x10ffff then
- pushError {
- type = 'UTF8_MAX',
- start = pos-3,
- finish = pos+#char,
- info = {
- min = '000000',
- max = '10ffff',
+ if State.Version == 'Lua 5.4' then
+ if v < 0 or v > 0x7FFFFFFF then
+ pushError {
+ type = 'UTF8_MAX',
+ start = pos-3,
+ finish = pos+#char,
+ info = {
+ min = '00000000',
+ max = '7FFFFFFF',
+ }
}
- }
- return ''
+ return ''
+ end
+ else
+ if v < 0 or v > 0x10FFFF then
+ pushError {
+ type = 'UTF8_MAX',
+ start = pos-3,
+ finish = pos+#char,
+ version = v <= 0x7FFFFFFF and 'Lua 5.4' or nil,
+ info = {
+ min = '000000',
+ max = '10FFFF',
+ }
+ }
+ return ''
+ end
+ return utf8_char(v)
end
- return utf8_char(v)
+ return ''
end,
Number = function (start, number, finish)
local n = tonumber(number)
@@ -1188,13 +1205,25 @@ local Defs = {
}
return rtn, action
end,
+ ToClose = function (start)
+ if State.Version == 'Lua 5.4' then
+ return
+ end
+ pushError {
+ type = 'TOCLOSE',
+ start = start,
+ finish = start + #'*toclose' - 1,
+ version = 'Lua 5.4',
+ }
+ end
}
-return function (self, lua, mode)
+return function (self, lua, mode, version)
Errs = {}
State= {
Break = 0,
Label = {{}},
+ Version = version,
}
local suc, res, err = pcall(self.grammar, lua, mode, Defs)
if not suc then
diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua
index 7066a9e6..a1be48db 100644
--- a/server/src/parser/grammar.lua
+++ b/server/src/parser/grammar.lua
@@ -212,7 +212,7 @@ ASSIGN <- Sp '='
Nothing <- {} -> Nothing
-TOCLOSE <- Sp '*toclose'
+TOCLOSE <- Sp ({} '*toclose' Cut) -> ToClose
DirtyBR <- BR {} / {} -> MissBR
DirtyTR <- TR {} / {} -> MissTR
diff --git a/server/src/service.lua b/server/src/service.lua
index bbac7b6d..fdeb926d 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -327,7 +327,7 @@ function mt:_markCompiled(uri, compiled)
end
function mt:compileAst(obj)
- local ast, err = parser:ast(obj.text)
+ local ast, err = parser:ast(obj.text, 'lua', config.config.runtime.version)
obj.astErr = err
if not ast then
if type(err) == 'string' then
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 2f965bcb..a36d0cd5 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -103,7 +103,7 @@ function TEST(script)
return function (expect)
local pos = script:find('@', 1, true) - 1
local new_script = script:gsub('@', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
local vm = buildVM(ast)
assert(vm)
local word = findWord(pos, new_script)
diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua
index f2b2833c..59cf6d3d 100644
--- a/server/test/definition/init.lua
+++ b/server/test/definition/init.lua
@@ -40,7 +40,7 @@ function TEST(script)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
assert(ast)
local vm = buildVM(ast)
assert(vm)
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index dc060ba4..e0893286 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -41,7 +41,7 @@ end
function TEST(script)
local new_script, target = catch_target(script)
local lsp = service()
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
assert(ast)
local lines = parser:lines(new_script)
local vm = buildVM(ast, lsp)
diff --git a/server/test/document_symbol/init.lua b/server/test/document_symbol/init.lua
index 929c2253..f14c5951 100644
--- a/server/test/document_symbol/init.lua
+++ b/server/test/document_symbol/init.lua
@@ -76,7 +76,7 @@ end
function TEST(script)
return function (expect)
- local ast = parser:ast(script)
+ local ast = parser:ast(script, 'lua', 'Lua 5.4')
local vm = buildVM(ast)
assert(vm)
local result = core.documentSymbol(vm)
diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua
index ea650970..5f7c5dce 100644
--- a/server/test/find_lib/init.lua
+++ b/server/test/find_lib/init.lua
@@ -10,7 +10,7 @@ function TEST(fullkey)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
assert(ast)
local vm = buildVM(ast)
assert(vm)
diff --git a/server/test/full/init.lua b/server/test/full/init.lua
index 145a2113..2c92e90b 100644
--- a/server/test/full/init.lua
+++ b/server/test/full/init.lua
@@ -4,7 +4,7 @@ local parser = require 'parser'
rawset(_G, 'TEST', true)
function TEST(script)
- local ast = parser:ast(script)
+ local ast = parser:ast(script, 'lua', 'Lua 5.4')
assert(ast)
local vm, err = buildVM(ast)
assert(vm, err)
diff --git a/server/test/highlight/init.lua b/server/test/highlight/init.lua
index 4e68de0c..e26b0ab3 100644
--- a/server/test/highlight/init.lua
+++ b/server/test/highlight/init.lua
@@ -39,7 +39,7 @@ function TEST(newName)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
assert(ast)
local vm = buildVM(ast)
assert(vm)
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 9e1d6ada..95be529f 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -10,7 +10,7 @@ function TEST(script)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
local vm = buildVM(ast)
assert(vm)
local source = core.findSource(vm, pos)
diff --git a/server/test/references/init.lua b/server/test/references/init.lua
index c512ca5d..6b53decb 100644
--- a/server/test/references/init.lua
+++ b/server/test/references/init.lua
@@ -38,7 +38,7 @@ function TEST(script)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
assert(ast)
local vm = buildVM(ast)
assert(vm)
diff --git a/server/test/rename/init.lua b/server/test/rename/init.lua
index 09900e3d..1ad8994a 100644
--- a/server/test/rename/init.lua
+++ b/server/test/rename/init.lua
@@ -39,7 +39,7 @@ function TEST(newName)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
assert(ast)
local vm = buildVM(ast)
assert(vm)
diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua
index 3e83b5ba..0910ab83 100644
--- a/server/test/signature/init.lua
+++ b/server/test/signature/init.lua
@@ -8,7 +8,7 @@ function TEST(script)
return function (expect)
local pos = script:find('@', 1, true)
local new_script = script:gsub('@', '')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
local vm = buildVM(ast)
assert(vm)
local hovers = core.signature(vm, pos)
diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua
index 4961b4b0..c966eb18 100644
--- a/server/test/type_inference/init.lua
+++ b/server/test/type_inference/init.lua
@@ -10,7 +10,7 @@ function TEST(res)
local finish = script:find('?>', 1, true)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- local ast = parser:ast(new_script)
+ local ast = parser:ast(new_script, 'lua', 'Lua 5.4')
local vm = buildVM(ast)
assert(vm)
local result = core.findSource(vm, pos)