From e9975c2081dfe2f42392a7612b2a3862e513e45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 7 Apr 2022 02:38:16 +0800 Subject: doc.type.boolean --- script/parser/guide.lua | 1 + script/parser/luadoc.lua | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'script/parser') diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 2de1ac22..2b22d1b2 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -235,6 +235,7 @@ function m.isLiteral(obj) or tp == 'doc.type.table' or tp == 'doc.type.string' or tp == 'doc.type.integer' + or tp == 'doc.type.boolean' end --- 获取字面量 diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 4dbece5a..4d9de5be 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -578,11 +578,31 @@ local function parseInteger(parent) return integer end +local function parseBoolean(parent) + local tp, content = peekToken() + if not tp + or tp ~= 'name' + or (content ~= 'true' and content ~= 'false') then + return nil + end + + nextToken() + local boolean = { + type = 'doc.type.boolean', + start = getStart(), + finish = getFinish(), + parent = parent, + [1] = content == 'true' and true or false, + } + return boolean +end + function parseTypeUnit(parent) local result = parseFunction(parent) or parseTable(parent) or parseString(parent) or parseInteger(parent) + or parseBoolean(parent) or parseDots('doc.type.name', parent) if not result then local literal = checkToken('symbol', '`', 1) -- cgit v1.2.3