diff options
-rw-r--r-- | pp.lua | 13 |
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 | ||
3 | local pp = {} | 3 | local pp = {} |
4 | table.unpack = table.unpack or unpack | ||
4 | 5 | ||
5 | function pp.dump (x, lvl) | 6 | function 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) | |||
30 | end | 33 | end |
31 | 34 | ||
32 | return setmetatable(pp, { __call = | 35 | return 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 | }) |