summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/signature.lua2
-rw-r--r--server/src/parser/ast.lua5
-rw-r--r--server/src/parser/grammar.lua13
-rw-r--r--server/test/signature/init.lua2
4 files changed, 13 insertions, 9 deletions
diff --git a/server/src/core/signature.lua b/server/src/core/signature.lua
index 14d05b8b..8e4e9f8f 100644
--- a/server/src/core/signature.lua
+++ b/server/src/core/signature.lua
@@ -1,7 +1,7 @@
local hover = require 'core.hover'
local function isContainPos(obj, pos)
- if obj.start <= pos and obj.finish + 1 >= pos then
+ if obj.start <= pos and obj.finish >= pos then
return true
end
return false
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index 291d93c6..ae46e660 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -306,7 +306,7 @@ local defs = {
key, value,
}
end,
- NewIndex = function (key, value)
+ NewIndex = function (start, key, finish, value)
key.index = true
return {
type = 'pair',
@@ -639,6 +639,7 @@ local defs = {
symbol = '}',
}
}
+ return pos + 1
end,
MissBR = function (pos)
pushError {
@@ -649,6 +650,7 @@ local defs = {
symbol = ']',
}
}
+ return pos + 1
end,
MissPR = function (pos)
pushError {
@@ -659,6 +661,7 @@ local defs = {
symbol = ')',
}
}
+ return pos + 1
end,
ErrEsc = function (pos)
pushError {
diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua
index 3bff2e31..907a5754 100644
--- a/server/src/parser/grammar.lua
+++ b/server/src/parser/grammar.lua
@@ -61,6 +61,7 @@ defs.NotReserved = function (_, _, str)
end
return true, str
end
+defs.np = m.Cp() / function (n) return n+1 end
local eof = re.compile '!. / %{SYNTAX_ERROR}'
@@ -192,9 +193,9 @@ Nothing <- {} -> Nothing
TOCLOSE <- Sp '*toclose'
DirtyAssign <- ASSIGN / {} -> MissAssign
-DirtyBR <- BR / {} -> MissBR
-DirtyTR <- TR / {} -> MissTR
-DirtyPR <- PR / {} -> MissPR
+DirtyBR <- BR {} / {} -> MissBR
+DirtyTR <- TR {} / {} -> MissTR
+DirtyPR <- PR {} / {} -> MissPR
]]
grammar 'Nil' [[
@@ -289,7 +290,7 @@ Suffix <- DOT MustName
/ Sp ({} Table {}) -> Call
/ Sp ({} String {}) -> Call
/ Sp ({} BL DirtyExp (BR / Sp) {}) -> Index
- / Sp ({} PL CallArgList DirtyPR {}) -> Call
+ / Sp ({} PL CallArgList DirtyPR) -> Call
DirtyExp <- Exp
/ {} -> DirtyExp
@@ -319,14 +320,14 @@ AfterArg <- DOTS
/ MustName
-Table <- Sp ({} TL TableFields? DirtyTR {})
+Table <- Sp ({} TL TableFields? DirtyTR)
-> Table
TableFields <- (TableSep {} / TableField / DirtyField)+
DirtyField <- Sp ({} {(!TR !BL !COMMA !SEMICOLON !Word .)+})
-> UnknownSymbol
TableSep <- COMMA / SEMICOLON
TableField <- NewIndex / NewField / Exp
-NewIndex <- (BL DirtyExp DirtyBR DirtyAssign DirtyExp)
+NewIndex <- Sp ({} BL DirtyExp DirtyBR DirtyAssign DirtyExp)
-> NewIndex
NewField <- (MustName ASSIGN DirtyExp)
-> NewField
diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua
index 86b5f05a..4110c585 100644
--- a/server/test/signature/init.lua
+++ b/server/test/signature/init.lua
@@ -5,7 +5,7 @@ rawset(_G, 'TEST', true)
function TEST(script)
return function (expect)
- local pos = script:find('@', 1, true) + 1
+ local pos = script:find('@', 1, true)
local new_script = script:gsub('@', '')
local ast = parser:ast(new_script)
local vm = core.vm(ast)