Updated to Fennel V 0.5.1
This commit is contained in:
parent
ae22728efb
commit
99e18e0318
3741
lib/fennel
3741
lib/fennel
File diff suppressed because it is too large
Load diff
5334
lib/fennel.lua
5334
lib/fennel.lua
File diff suppressed because it is too large
Load diff
|
@ -15,9 +15,7 @@ do
|
||||||
long_control_char_escapes = long
|
long_control_char_escapes = long
|
||||||
end
|
end
|
||||||
local function escape(str)
|
local function escape(str)
|
||||||
local str0 = str:gsub("\\", "\\\\")
|
return str:gsub("\\", "\\\\"):gsub("(%c)%f[0-9]", long_control_char_escapes):gsub("%c", short_control_char_escapes)
|
||||||
local str1 = str0:gsub("(%c)%f[0-9]", long_control_char_escapes)
|
|
||||||
return str1:gsub("%c", short_control_char_escapes)
|
|
||||||
end
|
end
|
||||||
local function sequence_key_3f(k, len)
|
local function sequence_key_3f(k, len)
|
||||||
return ((type(k) == "number") and (1 <= k) and (k <= len) and (math.floor(k) == k))
|
return ((type(k) == "number") and (1 <= k) and (k <= len) and (math.floor(k) == k))
|
||||||
|
@ -122,8 +120,10 @@ end
|
||||||
local function put_kv_table(self, t, ordered_keys)
|
local function put_kv_table(self, t, ordered_keys)
|
||||||
puts(self, "{")
|
puts(self, "{")
|
||||||
self.level = (self.level + 1)
|
self.level = (self.level + 1)
|
||||||
for _, k in ipairs(ordered_keys) do
|
for i, k in ipairs(ordered_keys) do
|
||||||
|
if (self["table-edges"] or (i ~= 1)) then
|
||||||
tabify(self)
|
tabify(self)
|
||||||
|
end
|
||||||
put_key(self, k)
|
put_key(self, k)
|
||||||
puts(self, " ")
|
puts(self, " ")
|
||||||
put_value(self, t[k])
|
put_value(self, t[k])
|
||||||
|
@ -135,24 +135,27 @@ local function put_kv_table(self, t, ordered_keys)
|
||||||
put_value(self, v)
|
put_value(self, v)
|
||||||
end
|
end
|
||||||
self.level = (self.level - 1)
|
self.level = (self.level - 1)
|
||||||
|
if self["table-edges"] then
|
||||||
tabify(self)
|
tabify(self)
|
||||||
|
end
|
||||||
return puts(self, "}")
|
return puts(self, "}")
|
||||||
end
|
end
|
||||||
local function put_table(self, t)
|
local function put_table(self, t)
|
||||||
local metamethod = nil
|
local metamethod = nil
|
||||||
do
|
local function _1_()
|
||||||
local _0_0 = t
|
local _0_0 = t
|
||||||
if _0_0 then
|
if _0_0 then
|
||||||
local _1_0 = getmetatable(_0_0)
|
local _2_0 = getmetatable(_0_0)
|
||||||
if _1_0 then
|
if _2_0 then
|
||||||
metamethod = _1_0.__fennelview
|
return _2_0.__fennelview
|
||||||
else
|
else
|
||||||
metamethod = _1_0
|
return _2_0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
metamethod = _0_0
|
return _0_0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
metamethod = (self["metamethod?"] and _1_())
|
||||||
if (already_visited_3f(self, t) and self["detect-cycles?"]) then
|
if (already_visited_3f(self, t) and self["detect-cycles?"]) then
|
||||||
return puts(self, "#<table ", get_id(self, t), ">")
|
return puts(self, "#<table ", get_id(self, t), ">")
|
||||||
elseif (self.level >= self.depth) then
|
elseif (self.level >= self.depth) then
|
||||||
|
@ -165,7 +168,14 @@ local function put_table(self, t)
|
||||||
if ((1 < (self.appearances[t] or 0)) and self["detect-cycles?"]) then
|
if ((1 < (self.appearances[t] or 0)) and self["detect-cycles?"]) then
|
||||||
return puts(self, "#<table", id, ">")
|
return puts(self, "#<table", id, ">")
|
||||||
elseif ((#non_seq_keys == 0) and (#t == 0)) then
|
elseif ((#non_seq_keys == 0) and (#t == 0)) then
|
||||||
return puts(self, "{}")
|
local function _2_()
|
||||||
|
if self["empty-as-square"] then
|
||||||
|
return "[]"
|
||||||
|
else
|
||||||
|
return "{}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return puts(self, _2_())
|
||||||
elseif (#non_seq_keys == 0) then
|
elseif (#non_seq_keys == 0) then
|
||||||
return put_sequential_table(self, t, len)
|
return put_sequential_table(self, t, len)
|
||||||
elseif "else" then
|
elseif "else" then
|
||||||
|
@ -203,9 +213,8 @@ local function fennelview(x, options)
|
||||||
return " "
|
return " "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
inspector = {["detect-cycles?"] = not (false == options0["detect-cycles?"]), ["max-ids"] = {}, appearances = count_table_appearances(x, {}), buffer = {}, depth = (options0.depth or 128), fennelview = _1_, ids = {}, indent = (options0.indent or _2_()), level = 0}
|
inspector = {["detect-cycles?"] = not (false == options0["detect-cycles?"]), ["empty-as-square"] = options0["empty-as-square"], ["max-ids"] = {}, ["metamethod?"] = not (false == options0["metamethod?"]), ["table-edges"] = (options0["table-edges"] ~= false), appearances = count_table_appearances(x, {}), buffer = {}, depth = (options0.depth or 128), fennelview = _1_, ids = {}, indent = (options0.indent or _2_()), level = 0}
|
||||||
put_value(inspector, x)
|
put_value(inspector, x)
|
||||||
do
|
|
||||||
local str = table.concat(inspector.buffer)
|
local str = table.concat(inspector.buffer)
|
||||||
if options0["one-line"] then
|
if options0["one-line"] then
|
||||||
return one_line(str)
|
return one_line(str)
|
||||||
|
@ -213,5 +222,4 @@ local function fennelview(x, options)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return fennelview
|
return fennelview
|
||||||
|
|
Loading…
Reference in a new issue