From 7fc2e8d182800a48e99744fc88fef24ca578b18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 23 Jun 2021 20:22:26 +0800 Subject: add integer --- script/parser/ast.lua | 2 +- script/parser/guide.lua | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'script/parser') diff --git a/script/parser/ast.lua b/script/parser/ast.lua index 40b5788e..bd8a66cf 100644 --- a/script/parser/ast.lua +++ b/script/parser/ast.lua @@ -547,7 +547,7 @@ local Defs = { local n = tonumber(number) if n then State.LastNumber = { - type = 'number', + type = mathType(n) == 'integer' and 'integer' or 'number', start = start, finish = finish - 1, [1] = n, diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 1c6b9e81..e6501f12 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -183,6 +183,7 @@ function m.isLiteral(obj) or tp == 'boolean' or tp == 'string' or tp == 'number' + or tp == 'integer' or tp == 'table' or tp == 'function' end @@ -198,6 +199,8 @@ function m.getLiteral(obj) return obj[1] elseif tp == 'number' then return obj[1] + elseif tp == 'integer' then + return obj[1] end return nil end @@ -818,6 +821,11 @@ function m.getKeyNameOfLiteral(obj) if n then return ('%s'):format(formatNumber(obj[1])) end + elseif tp == 'integer' then + local n = obj[1] + if n then + return ('%s'):format(formatNumber(obj[1])) + end elseif tp == 'boolean' then local b = obj[1] if b then @@ -883,6 +891,8 @@ function m.getKeyTypeOfLiteral(obj) return 'string' elseif tp == 'number' then return 'number' + elseif tp == 'integer' then + return 'integer' elseif tp == 'boolean' then return 'boolean' end -- cgit v1.2.3