summaryrefslogtreecommitdiff
path: root/server/src/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-31 19:06:15 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-31 19:06:15 +0800
commit584b26c62fafe843c6ae618dba1350d07bf8f091 (patch)
treed6b8c30c0652db6f9eb4007312a76d5fc9368617 /server/src/parser
parente789de1e2b6680c57d4746374d2d4977764265cd (diff)
downloadlua-language-server-584b26c62fafe843c6ae618dba1350d07bf8f091.zip
更新语法解析
Diffstat (limited to 'server/src/parser')
-rw-r--r--server/src/parser/ast.lua5
-rw-r--r--server/src/parser/grammar.lua13
2 files changed, 11 insertions, 7 deletions
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