summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-07 02:38:16 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-07 02:38:16 +0800
commite9975c2081dfe2f42392a7612b2a3862e513e45e (patch)
tree630e9e8ae9fb085e46771f807bcaa41ae038004b /script/parser
parent3e2948e1480659d7c29f9d701e378330c08b238f (diff)
downloadlua-language-server-e9975c2081dfe2f42392a7612b2a3862e513e45e.zip
doc.type.boolean
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/guide.lua1
-rw-r--r--script/parser/luadoc.lua20
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)