diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-19 12:07:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-19 12:07:56 +0800 |
commit | 21f5a489430b04caee6cdc4b62f34bc3ca884181 (patch) | |
tree | 80cb3976128d6ad4ac9c1bfd9058185737929499 /server | |
parent | 8b1e9fd0702f4ad74482b10b6b5330e69d53260a (diff) | |
download | lua-language-server-21f5a489430b04caee6cdc4b62f34bc3ca884181.zip |
更新语法解析
Diffstat (limited to 'server')
-rw-r--r-- | server/src/parser/ast.lua | 30 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 9 |
2 files changed, 25 insertions, 14 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index f8a16c54..f2356531 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -290,25 +290,37 @@ local defs = { name.type = 'goto' return name end, - IfBlock = function (exp, ...) - return { + IfBlock = function (exp, start, ...) + local obj = { filter = exp, + start = start, ... } + local max = #obj + obj.finish = obj[max] + obj[max] = nil + return obj end, - ElseIfBlock = function (exp, ...) - return { + ElseIfBlock = function (exp, start, ...) + local obj = { filter = exp, + start = start, ... } + local max = #obj + obj.finish = obj[max] + obj[max] = nil + return obj end, - ElseBlock = function (...) - if ... == '' then - return {} - end - return { + ElseBlock = function (start, ...) + local obj = { + start = start, ... } + local max = #obj + obj.finish = obj[max] + obj[max] = nil + return obj end, If = function (start, ...) local obj = { diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 0e7fa608..d4a7f648 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -339,15 +339,14 @@ If <- Sp ({} IfBody {}) -> If IfBody <- (IfPart -> IfBlock) (ElseIfPart -> ElseIfBlock)* - ElsePart? + (ElsePart -> ElseBlock)? END IfPart <- IF Exp THEN - Action* + {} Action* {} ElseIfPart <- ELSEIF Exp THEN - Action* + {} Action* {} ElsePart <- ELSE - Action* - -> ElseBlock + {} Action* {} For <- Loop / In |