summaryrefslogtreecommitdiff
path: root/server/src/parser/ast.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/parser/ast.lua')
-rw-r--r--server/src/parser/ast.lua52
1 files changed, 42 insertions, 10 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index 9903dca2..f2486fd6 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -1213,16 +1213,22 @@ local Defs = {
[2] = valueType,
}
end,
- EmmyFunctionType = function (start, ...)
+ EmmyFunctionType = function (start, args, returns, finish)
local result = {
start = start,
+ finish = finish - 1,
type = 'emmyFunctionType',
- ...
+ args = args,
+ returns = returns,
}
- result.finish = result[#result] - 1
- result[#result] = nil
return result
end,
+ EmmyFunctionRtns = function (...)
+ return {...}
+ end,
+ EmmyFunctionArgs = function (...)
+ return {...}
+ end,
EmmyAlias = function (name, emmyName, ...)
return {
type = 'emmyAlias',
@@ -1233,9 +1239,10 @@ local Defs = {
...
}
end,
- EmmyParam = function (argName, emmyName, ...)
+ EmmyParam = function (argName, emmyName, option, ...)
local emmy = {
type = 'emmyParam',
+ option = option,
argName,
emmyName,
...
@@ -1244,13 +1251,14 @@ local Defs = {
emmy.finish = emmy[#emmy].finish
return emmy
end,
- EmmyReturn = function (...)
+ EmmyReturn = function (start, type, finish, option)
local emmy = {
type = 'emmyReturn',
- ...
+ option = option,
+ start = start,
+ finish = finish - 1,
+ [1] = type,
}
- emmy.start = emmy[1].start
- emmy.finish = emmy[#emmy].finish
return emmy
end,
EmmyField = function (access, fieldName, ...)
@@ -1315,9 +1323,33 @@ local Defs = {
EmmyComment = function (...)
return {
type = 'emmyComment',
- [1] = table.concat({...}, ' '),
+ [1] = table.concat({...}),
}
end,
+ EmmyOption = function (options)
+ if not options or options == '' then
+ return nil
+ end
+ local 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
+ return option
+ end,
+ EmmyTypeEnum = function (default, enum, comment)
+ enum.type = 'emmyEnum'
+ if default ~= '' then
+ enum.default = true
+ end
+ enum.comment = comment
+ return enum
+ end,
-- 捕获错误
UnknownSymbol = function (start, symbol)