about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--pp.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/pp.lua b/pp.lua index 3710b07..85d323e 100644 --- a/pp.lua +++ b/pp.lua
@@ -1,6 +1,7 @@
1--- lam.pp 1--- lam.pp
2 2
3local pp = {} 3local pp = {}
4table.unpack = table.unpack or unpack
4 5
5function pp.dump (x, lvl) 6function pp.dump (x, lvl)
6 lvl = lvl or 0 7 lvl = lvl or 0
@@ -15,10 +16,12 @@ function pp.dump (x, lvl)
15 v = pp.dump(v, lvl+2) 16 v = pp.dump(v, lvl+2)
16 end 17 end
17 subo = subo .. string.format("\n%s[%s] = %s,", 18 subo = subo .. string.format("\n%s[%s] = %s,",
18 (space.." "), k, v) 19 (space.." "), k, v)
19 end 20 end
20 output = output .. string.format("\n%s{%s\n%s}", 21 output = output .. string.format("\n%s{%s\n%s}",
21 space, subo, space) 22 space, subo, space)
23 elseif type(x) == "string" then
24 output = output .. string.format("'%s'", x)
22 else 25 else
23 output = output .. string.format("%s", x) 26 output = output .. string.format("%s", x)
24 end 27 end
@@ -30,7 +33,7 @@ function pp.pp (x)
30end 33end
31 34
32return setmetatable(pp, { __call = 35return setmetatable(pp, { __call =
33 function(_, x) 36 function(_, x)
34 return pp.pp(x) 37 return pp.pp(x)
35 end, 38 end,
36}) 39})