mighty

The mighty programming language, compiler and tools (WIP)
Log | Files | Refs

utils.lua (562B)



local utils = {}

-- adapted from https://gist.github.com/ripter/4270799
function utils.print_table(tbl, indent)
	if not tbl then
		return
	end
	if not indent then
		indent = 0
	end
	for k, v in pairs(tbl) do
		if k == "line" or k == "col" or k == "file" then
			goto pass
		end
		formatting = string.rep("  ", indent) .. k .. ": "
		if type(v) == "table" then
			print(formatting)
			utils.print_table(v, indent + 1)
		elseif type(v) == "boolean" then
			print(formatting .. tostring(v))
		else
			print(formatting .. v)
		end
		::pass::
	end
end

return utils