summaryrefslogtreecommitdiff
path: root/server/src/parser/grammar.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-29 15:11:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-29 15:11:23 +0800
commit272915898dfaa1da0416e28c75d6bac226934e98 (patch)
treeef026ee6ac1fdd57a841ea60934c2db7afaea5b3 /server/src/parser/grammar.lua
parent94d49cbd755932e74463c852ff100a6755d28546 (diff)
downloadlua-language-server-272915898dfaa1da0416e28c75d6bac226934e98.zip
更新语法解析
Diffstat (limited to 'server/src/parser/grammar.lua')
-rw-r--r--server/src/parser/grammar.lua35
1 files changed, 19 insertions, 16 deletions
diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua
index 7afea5e7..562dab12 100644
--- a/server/src/parser/grammar.lua
+++ b/server/src/parser/grammar.lua
@@ -78,7 +78,6 @@ local function errorpos(pos, err)
type = 'UNKNOWN',
start = pos,
err = err,
- level = 'error',
}
end
@@ -91,6 +90,7 @@ ShortComment <- (!%nl .)*
grammar 'Sp' [[
Sp <- (Comment / %nl / %s)*
+Sps <- (Comment / %nl / %s)+
]]
grammar 'Common' [[
@@ -299,13 +299,13 @@ NewField <- (MustName ASSIGN DirtyExp)
Function <- Sp ({} FunctionBody {})
-> Function
FunctionBody<- FUNCTION FuncName PL ArgList PR
- Action*
+ (!END Action)*
END?
/ FUNCTION FuncName PL ArgList PR?
- Action*
+ (!END Action)*
END?
/ FUNCTION FuncName Nothing
- Action*
+ (!END Action)*
END?
FuncName <- (Name? (FuncSuffix)*)
-> Simple
@@ -317,7 +317,8 @@ Action <- !END .
]]
grammar 'Action' [[
-Action <- SEMICOLON
+Action <- Sp (CrtAction / UnkAction)
+CrtAction <- SEMICOLON
/ Do
/ Break
/ Return
@@ -333,13 +334,15 @@ Action <- SEMICOLON
/ Set
/ Call
/ Exp
+UnkAction <- ({} {. (!Sps !CrtAction .)*} {})
+ -> UnknownSymbol
SimpleList <- (Simple (COMMA Simple)*)
-> List
Do <- Sp ({} DO DoBody END? {})
-> Do
-DoBody <- Action*
+DoBody <- (!END Action)*
-> DoBody
Break <- BREAK
@@ -362,19 +365,19 @@ IfBody <- IfHead
(ElsePart -> ElseBlock)?
END?
IfPart <- IF Exp THEN
- {} (!ELSEIF !ELSE Action)* {}
+ {} (!ELSEIF !ELSE !END Action)* {}
/ IF DirtyExp THEN
- {} (!ELSEIF !ELSE Action)* {}
+ {} (!ELSEIF !ELSE !END Action)* {}
/ IF DirtyExp
{} {}
ElseIfPart <- ELSEIF Exp THEN
- {} (!ELSE !ELSEIF Action)* {}
+ {} (!ELSE !ELSEIF !END Action)* {}
/ ELSEIF DirtyExp THEN
- {} (!ELSE !ELSEIF Action)* {}
+ {} (!ELSE !ELSEIF !END Action)* {}
/ ELSEIF DirtyExp
{} {}
ElsePart <- ELSE
- {} Action* {}
+ {} (!END Action)* {}
For <- Loop / In
/ FOR
@@ -382,7 +385,7 @@ For <- Loop / In
Loop <- Sp ({} LoopBody {})
-> Loop
LoopBody <- FOR LoopStart LoopFinish LoopStep DO?
- Action*
+ (!END Action)*
END?
LoopStart <- MustName ASSIGN DirtyExp
LoopFinish <- COMMA? Exp
@@ -394,19 +397,19 @@ LoopStep <- COMMA DirtyExp
In <- Sp ({} InBody {})
-> In
InBody <- FOR NameList IN? ExpList DO?
- Action*
+ (!END Action)*
END?
While <- Sp ({} WhileBody {})
-> While
WhileBody <- WHILE Exp DO
- Action*
+ (!END Action)*
END?
Repeat <- Sp ({} RepeatBody {})
-> Repeat
RepeatBody <- REPEAT
- Action*
+ (!UNTIL Action)*
UNTIL Exp
Local <- (LOCAL TOCLOSE? NameList (ASSIGN ExpList)?)
@@ -422,7 +425,7 @@ LocalFunction
]]
grammar 'Lua' [[
-Lua <- (Sp Action)* -> Lua Sp
+Lua <- Action* -> Lua Sp
]]
return function (lua, mode, parser_)