Removed some old orphaned functions.
This commit is contained in:
parent
65c2acb447
commit
bf9c5a6749
73
pretty.lua
73
pretty.lua
|
@ -192,44 +192,6 @@ local function fill_holes_in_key_value_pairs (key_value_pairs)
|
|||
table.sort(key_value_pairs, compare_key_value_pairs)
|
||||
end
|
||||
|
||||
local function is_identifier(str)
|
||||
-- TODO: Remove, Unused
|
||||
|
||||
-- An identier is defined in the lua reference guide
|
||||
|
||||
return str:match('^[_%a][_%w]*$') and not RESERVED_LUA_WORDS[str]
|
||||
end
|
||||
|
||||
local function contains_only_nice_string_keys (t)
|
||||
-- TODO: Remove, Unused
|
||||
|
||||
-- A "nice" string is here defined is one following the rules of lua
|
||||
-- identifiers.
|
||||
|
||||
for k, _ in pairs(t) do
|
||||
if type(k) ~= 'string' or not is_identifier(k) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function contains_only_nice_number_indexes (t)
|
||||
-- TODO: Remove, Unused
|
||||
|
||||
-- A "nice" index is here defined as one which would be visited when using
|
||||
-- ipairs: An integer larger than 1 and less than #t
|
||||
|
||||
local max_index = #t
|
||||
for k, v in pairs(t) do
|
||||
if type(k) ~= 'number' or k < 1 or max_index < k or k ~= math.floor(k) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function escape_string (str)
|
||||
|
||||
-- Error checking
|
||||
|
@ -332,41 +294,6 @@ local function fix_seperator_info (l, indent_char, max_depth)
|
|||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Identifyer stuff
|
||||
|
||||
local function is_empty_table (value)
|
||||
-- TODO: Remove. This is unused.
|
||||
|
||||
if type(value) ~= 'table' then
|
||||
error(('[pretty/internal]: Only tables allowed in function pretty.is_empty_table, but was given %s (%s)'):format(value, type(value)), 2)
|
||||
end
|
||||
return next(value) == nil
|
||||
end
|
||||
|
||||
local function get_table_type (value)
|
||||
-- TODO: Remove. This is unused.
|
||||
|
||||
-- Determines table type:
|
||||
-- * Sequence: All keys are integer in the range 1..#value
|
||||
-- * Pure Map: #value == 0
|
||||
-- * Mixed: Any other
|
||||
|
||||
|
||||
if is_empty_table(value) then return TABLE_TYPE.EMPTY end
|
||||
|
||||
local is_sequence = contains_only_nice_number_indexes(value)
|
||||
local only_string_keys = contains_only_nice_string_keys(value)
|
||||
local is_pure_map = (#value == 0)
|
||||
|
||||
-- Return type
|
||||
if is_sequence then return TABLE_TYPE.SEQUENCE
|
||||
elseif only_string_keys then return TABLE_TYPE.STRING_MAP
|
||||
elseif is_pure_map then return TABLE_TYPE.PURE_MAP
|
||||
else return TABLE_TYPE.MIXED
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Formatting stuff
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user