summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-24 20:57:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-24 20:57:50 +0800
commit55bc394b5c8cc41380ff7e26729e850ecadde7ed (patch)
tree4b598460756a7eb8a3d3454f4cffc939bc91de6c /script/parser
parentbc0270a06a1017301ca96712b350c399537e63a6 (diff)
downloadlua-language-server-55bc394b5c8cc41380ff7e26729e850ecadde7ed.zip
fix #565
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/ast.lua12
-rw-r--r--script/parser/grammar.lua12
2 files changed, 23 insertions, 1 deletions
diff --git a/script/parser/ast.lua b/script/parser/ast.lua
index bd8a66cf..e92e3e16 100644
--- a/script/parser/ast.lua
+++ b/script/parser/ast.lua
@@ -6,6 +6,7 @@ local mathType = math.type
local tableRemove = table.remove
local pairs = pairs
local tableSort = table.sort
+local print = print
_ENV = nil
@@ -1925,6 +1926,17 @@ local Defs = {
}
}
}
+ end,
+ CallArgSnip = function (name, tailStart, tailSymbol)
+ PushError {
+ type = 'UNEXPECT_SYMBOL',
+ start = tailStart,
+ finish = tailStart,
+ info = {
+ symbol = tailSymbol,
+ }
+ }
+ return name
end
}
diff --git a/script/parser/grammar.lua b/script/parser/grammar.lua
index 01756c2a..2c046f0e 100644
--- a/script/parser/grammar.lua
+++ b/script/parser/grammar.lua
@@ -304,6 +304,13 @@ MustName <- Name / DirtyName
DirtyName <- {} -> DirtyName
]]
+grammar 'DocType' [[
+DocType <- (!%nl !')' !',' DocChar)+
+DocChar <- '(' (!%nl !')' .)+ ')'?
+ / '<' (!%nl !'>' .)+ '>'?
+ / .
+]]
+
grammar 'Exp' [[
Exp <- (UnUnit BinUnit*)
-> Binary
@@ -332,9 +339,12 @@ Single <- !FUNCTION Name
Suffix <- SuffixWithoutCall
/ ({} PL SuffixCall DirtyPR {})
-> Call
-SuffixCall <- Sp ({} {| (COMMA / Exp->NoNil)+ |} {})
+SuffixCall <- Sp ({} {| (COMMA / CallArg)+ |} {})
-> PackExpList
/ %nil
+CallArg <- Sp (Name {} {'?'? ':'} Sps DocType)
+ -> CallArgSnip
+ / Exp->NoNil
SuffixWithoutCall
<- (DOT (Name / MissField))
-> GetField