diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-06-26 20:52:59 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-06-26 20:52:59 +0800 |
commit | eb4cc1e5915a2ac0fceaa4f6b08f7f0f762d3fb6 (patch) | |
tree | 82ef5a990f3b43b51d03785558398a97ba3aa46f /server/src/parser | |
parent | f92a71db462b2769eea194143f15ab090b665862 (diff) | |
download | lua-language-server-eb4cc1e5915a2ac0fceaa4f6b08f7f0f762d3fb6.zip |
用option来实现一些私有功能
Diffstat (limited to 'server/src/parser')
-rw-r--r-- | server/src/parser/ast.lua | 16 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 9903dca2..0e408c73 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -1233,9 +1233,23 @@ local Defs = { ... } end, - EmmyParam = function (argName, emmyName, ...) + EmmyParam = function (argName, emmyName, options, ...) + local option + if options then + option = {} + for _, pair in ipairs(options) do + if pair.type == 'pair' then + local key = pair[1] + local value = pair[2] + if key.type == 'name' then + option[key[1]] = value[1] + end + end + end + end local emmy = { type = 'emmyParam', + option = option, argName, emmyName, ... diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 50f76d0b..913b0b25 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -560,7 +560,8 @@ EmmyTypeEnums <- %s* '|' %s* String EmmyAlias <- MustEmmyName %s* EmmyType EmmyTypeEnums* -EmmyParam <- MustEmmyName %s* EmmyType EmmyTypeEnums* +EmmyParam <- MustEmmyName %s* EmmyType %s* EmmyOption %s* EmmyTypeEnums* +EmmyOption <- Table / %nil EmmyReturn <- EmmyType |