diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-31 18:51:12 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-31 18:51:12 +0800 |
commit | 464333078e16232af075608d882d9d5c627425db (patch) | |
tree | b2aef5623afa903178f572f2dcc8c5decd9932fc /server/src | |
parent | bbab1b7fd1085e470d05b5e064ed5c655f264b45 (diff) | |
download | lua-language-server-464333078e16232af075608d882d9d5c627425db.zip |
更新语法检查
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/parser/ast.lua | 8 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 21 |
2 files changed, 20 insertions, 9 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 8c5f7fe9..291d93c6 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -317,17 +317,21 @@ local defs = { end, List = function (first, second, ...) if second then - return { + local list = { type = 'list', + start = first.start, first, second, ... } + local last = list[#list] + list.finish = last.finish + return list elseif first == '' then return nil else return first end end, - ExpList = function (start, ...) + CallArgList = function (start, ...) local args = {...} local max = #args local finish = args[max] - 1 diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 18118ac6..3bff2e31 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -289,13 +289,19 @@ Suffix <- DOT MustName / Sp ({} Table {}) -> Call / Sp ({} String {}) -> Call / Sp ({} BL DirtyExp (BR / Sp) {}) -> Index - / Sp ({} PL ExpList DirtyPR {}) -> Call + / Sp ({} PL CallArgList DirtyPR {}) -> Call DirtyExp <- Exp / {} -> DirtyExp -ExpList <- Sp ({} (!%nl (COMMA {} / Exp))+ {}) - -> ExpList +ExpList <- (COMMA Exp)+ + -> List + / (Exp (COMMA Exp)*) + -> List +CallArgList <- Sp ({} (COMMA {} / Exp / DirtyCallArg)+ {}) + -> CallArgList / %nil +DirtyCallArg<- Sp ({} {(!PR !PL !COMMA !Word .)+}) + -> UnknownSymbol NameList <- (COMMA MustName)+ -> List / (Name (COMMA MustName)*) @@ -313,10 +319,10 @@ AfterArg <- DOTS / MustName -Table <- Sp ({} TL TableFields DirtyTR {}) +Table <- Sp ({} TL TableFields? DirtyTR {}) -> Table -TableFields <- (TableSep {} / TableField / DirtyField)* -DirtyField <- Sp ({} {(!TR !COMMA !SEMICOLON !Word !BL .)+}) +TableFields <- (TableSep {} / TableField / DirtyField)+ +DirtyField <- Sp ({} {(!TR !BL !COMMA !SEMICOLON !Word .)+}) -> UnknownSymbol TableSep <- COMMA / SEMICOLON TableField <- NewIndex / NewField / Exp @@ -343,6 +349,7 @@ FuncSuffix <- DOT MustName -- 纯占位,修改了 `relabel.lua` 使重复定义不抛错 Action <- !END . +Set <- END ]] grammar 'Action' [[ @@ -443,7 +450,7 @@ RepeatBody <- REPEAT Local <- (LOCAL TOCLOSE? NameList (ASSIGN ExpList)?) -> Local -Set <- (SimpleList ASSIGN ExpList) +Set <- (SimpleList ASSIGN ExpList?) -> Set Call <- Simple |