diff options
author | sumneko <sumneko@hotmail.com> | 2019-05-05 20:38:25 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-05-05 20:38:25 +0800 |
commit | c1902bfe0f61006bd9afae43c10ee6a25863e5f6 (patch) | |
tree | e11e3cd65ad9109aa878a60e713d8b1d609858d1 /server/src/parser | |
parent | d64ec162e683c42befb2d32ae31b024e4d4a5510 (diff) | |
download | lua-language-server-c1902bfe0f61006bd9afae43c10ee6a25863e5f6.zip |
更新语法解析
Diffstat (limited to 'server/src/parser')
-rw-r--r-- | server/src/parser/ast.lua | 17 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 6 |
2 files changed, 13 insertions, 10 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index f361021b..5a3630cd 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -738,8 +738,8 @@ local Defs = { local last = args[max] pushError { type = 'MISS_NAME', - start = last, - finish = last, + start = last+1, + finish = last+1, } end if #list == 0 then @@ -1119,8 +1119,8 @@ local Defs = { pushError { type = 'MISS_NAME', level = 'warning', - start = pos-1, - finish = pos-1, + start = pos, + finish = pos, } return { type = 'emmyName', @@ -1177,11 +1177,14 @@ local Defs = { [2] = valueType, } end, - EmmyFunctionType = function (...) + EmmyFunctionType = function (start, ...) local result = { + start = start, type = 'emmyFunctionType', ... } + result.finish = result[#result] - 1 + result[#result] = nil return result end, EmmyAlias = function (name, emmyName, ...) @@ -1276,8 +1279,8 @@ local Defs = { DirtyName = function (pos) pushError { type = 'MISS_NAME', - start = pos-1, - finish = pos-1, + start = pos, + finish = pos, } return { type = 'name', diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 28e3eb28..25ac30f2 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -541,15 +541,15 @@ EmmyClass <- (MustEmmyName EmmyParentClass?) EmmyParentClass <- %s* {} ':' %s* MustEmmyName EmmyType <- EmmyFunctionType - / EmmyArrayType / EmmyTableType + / EmmyArrayType / EmmyCommonType EmmyCommonType <- EmmyTypeNames -> EmmyCommonType EmmyTypeNames <- EmmyTypeName (%s* {} '|' %s* !String EmmyTypeName)* EmmyTypeName <- EmmyFunctionType - / EmmyArrayType / EmmyTableType + / EmmyArrayType / MustEmmyName EmmyTypeEnums <- %s* '|' %s* String @@ -580,7 +580,7 @@ EmmyArrayType <- (MustEmmyName '[]') EmmyTableType <- ({} 'table' Cut '<' %s* EmmyType %s* ',' %s* EmmyType %s* '>' {}) -> EmmyTableType -EmmyFunctionType<- ('fun' Cut %s* EmmyFunctionArgs? %s* EmmyFunctionRtn?) +EmmyFunctionType<- ({} 'fun' Cut %s* EmmyFunctionArgs? %s* EmmyFunctionRtn? {}) -> EmmyFunctionType EmmyFunctionArgs<- '(' %s* EmmyFunctionArg %s* (',' %s* EmmyFunctionArg %s*)* ')' EmmyFunctionRtn <- ':' %s* EmmyType |