diff options
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/guide.lua | 1 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 20 |
2 files changed, 21 insertions, 0 deletions
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) |