diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | dump.lua (renamed from pp.lua) | 13 | ||||
-rw-r--r-- | read.lua | 2 | ||||
-rw-r--r-- | repl.lua | 2 |
4 files changed, 8 insertions, 11 deletions
diff --git a/Makefile b/Makefile index 51b3fc2..42349fb 100644 --- a/Makefile +++ b/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | LUA ?= rlwrap luajit \ | 1 | LUA ?= rlwrap luajit \ |
2 | -e 'pp = require "pp"' \ | 2 | -e 'pp = require("dump").pp' \ |
3 | -e 'eval = require "eval"' \ | 3 | -e 'eval = require "eval"' \ |
4 | -e 'read = require "read"' \ | 4 | -e 'read = require "read"' \ |
5 | -e 'type = require "type"' \ | 5 | -e 'type = require "type"' \ |
diff --git a/pp.lua b/dump.lua index 4d9d9af..dc32096 100644 --- a/pp.lua +++ b/dump.lua | |||
@@ -1,10 +1,9 @@ | |||
1 | --- lam.pp | 1 | --- lam.pp |
2 | 2 | ||
3 | local pp = {} | 3 | local m = {} |
4 | local type = require "type" | 4 | local type = require "type" |
5 | local unpack = table.unpack or unpack | ||
6 | 5 | ||
7 | function pp.dump (x, lvl) | 6 | function m.dump (x, lvl) |
8 | lvl = lvl or 0 | 7 | lvl = lvl or 0 |
9 | local space = string.rep(" ", lvl) | 8 | local space = string.rep(" ", lvl) |
10 | local output = "" | 9 | local output = "" |
@@ -16,7 +15,7 @@ function pp.dump (x, lvl) | |||
16 | if v == x then | 15 | if v == x then |
17 | v = "self" | 16 | v = "self" |
18 | else | 17 | else |
19 | v = pp.dump(v, lvl+2) | 18 | v = m.dump(v, lvl+2) |
20 | end | 19 | end |
21 | subo = subo .. string.format("\n%s[%s] = %s,", | 20 | subo = subo .. string.format("\n%s[%s] = %s,", |
22 | (space.." "), k, v) | 21 | (space.." "), k, v) |
@@ -29,9 +28,9 @@ function pp.dump (x, lvl) | |||
29 | return output | 28 | return output |
30 | end | 29 | end |
31 | 30 | ||
32 | function pp.pp (x) | 31 | function m.pp (x) |
33 | print(pp.dump(x)) | 32 | print(m.dump(x)) |
34 | end | 33 | end |
35 | 34 | ||
36 | --- | 35 | --- |
37 | return pp | 36 | return m |
diff --git a/read.lua b/read.lua index f8d6b09..8a154a1 100644 --- a/read.lua +++ b/read.lua | |||
@@ -5,8 +5,6 @@ local t = require "type" | |||
5 | local utf8 = require "utf8" | 5 | local utf8 = require "utf8" |
6 | local pop = require("util").pop | 6 | local pop = require("util").pop |
7 | 7 | ||
8 | local pp = require("pp").pp | ||
9 | |||
10 | -- TODO: | 8 | -- TODO: |
11 | -- - string reading | 9 | -- - string reading |
12 | -- - # syntax | 10 | -- - # syntax |
diff --git a/repl.lua b/repl.lua index 93e430c..a3fdf95 100644 --- a/repl.lua +++ b/repl.lua | |||
@@ -3,7 +3,7 @@ | |||
3 | local m = {} | 3 | local m = {} |
4 | local read = require("read") | 4 | local read = require("read") |
5 | local eval = require("eval") | 5 | local eval = require("eval") |
6 | local pp = require("pp").pp | 6 | local pp = require("dump").pp |
7 | 7 | ||
8 | local function schemeprint (x) | 8 | local function schemeprint (x) |
9 | -- if x == nil then return end | 9 | -- if x == nil then return end |