diff options
-rw-r--r-- | core.lua | 8 | ||||
-rw-r--r-- | read.lua | 7 | ||||
-rw-r--r-- | type.lua | 5 | ||||
-rw-r--r-- | util.lua | 13 |
4 files changed, 10 insertions, 23 deletions
diff --git a/core.lua b/core.lua index 556866c..3e4773a 100644 --- a/core.lua +++ b/core.lua | |||
@@ -2,11 +2,9 @@ | |||
2 | 2 | ||
3 | local dump = require("dump") | 3 | local dump = require("dump") |
4 | local type = require("type") | 4 | local type = require("type") |
5 | local utf8 = require("utf8") | ||
6 | local null = type.null | ||
7 | local assert_arity, assert_type = type.assert_arity, type.assert_type | 5 | local assert_arity, assert_type = type.assert_arity, type.assert_type |
8 | local util = require("util") | 6 | local null = type.null |
9 | local error = util.error | 7 | local error = require("util").error |
10 | 8 | ||
11 | local function fold (kons, knil, r) | 9 | local function fold (kons, knil, r) |
12 | if r == null then | 10 | if r == null then |
@@ -111,7 +109,7 @@ end | |||
111 | env["integer->char"] = function (r) | 109 | env["integer->char"] = function (r) |
112 | assert_arity(r,1,1) | 110 | assert_arity(r,1,1) |
113 | assert_type(r[1], "number") -- todo: check integer | 111 | assert_type(r[1], "number") -- todo: check integer |
114 | return type.character(utf8.char(r[1])) | 112 | return type.character(r[1]) |
115 | end | 113 | end |
116 | 114 | ||
117 | env["string->list"] = function (r) | 115 | env["string->list"] = function (r) |
diff --git a/read.lua b/read.lua index 666f509..658ad7d 100644 --- a/read.lua +++ b/read.lua | |||
@@ -4,7 +4,8 @@ local m = {} | |||
4 | local type = require("type") | 4 | local type = require("type") |
5 | local eof, input_port = type.eof, type.input_port | 5 | local eof, input_port = type.eof, type.input_port |
6 | local util = require("util") | 6 | local util = require("util") |
7 | local constantly, error, pop = util.constantly, util.error, util.pop | 7 | local error, pop = util.error, util.pop |
8 | local utf8_char = require("utf8").char | ||
8 | 9 | ||
9 | local token_separators = "[%s#()\"'`,@;]" | 10 | local token_separators = "[%s#()\"'`,@;]" |
10 | 11 | ||
@@ -127,7 +128,7 @@ local function consume_string_hexvalue (cs) | |||
127 | table.insert(u8ch, c) | 128 | table.insert(u8ch, c) |
128 | until c == ";" | 129 | until c == ";" |
129 | table.remove(u8ch) -- discard ';' | 130 | table.remove(u8ch) -- discard ';' |
130 | return utf8.char(tonumber(table.concat(u8ch), 16)), cs | 131 | return utf8_char(tonumber(table.concat(u8ch), 16)), cs |
131 | end | 132 | end |
132 | 133 | ||
133 | local function consume_string (cs) | 134 | local function consume_string (cs) |
@@ -258,7 +259,7 @@ m.readmacros = { | |||
258 | table.insert(Q, m.read(port)) | 259 | table.insert(Q, m.read(port)) |
259 | return type.list(Q) | 260 | return type.list(Q) |
260 | end, | 261 | end, |
261 | comment = constantly(nil), -- throw comments away | 262 | comment = function (_,_,_) return nil end, |
262 | } | 263 | } |
263 | 264 | ||
264 | ---[[ READ ]]--- | 265 | ---[[ READ ]]--- |
diff --git a/type.lua b/type.lua index 79f42a6..83b29f2 100644 --- a/type.lua +++ b/type.lua | |||
@@ -7,8 +7,9 @@ | |||
7 | 7 | ||
8 | local m = {} | 8 | local m = {} |
9 | local utf8 = require("utf8") | 9 | local utf8 = require("utf8") |
10 | local util = require("util") | 10 | local utf8_char, utf8_codepoint, utf8_codes = |
11 | local tochars, error, constantly = util.tochars, util.error, util.constantly | 11 | utf8.char, utf8.codepoint, utf8.codes |
12 | local error = require("util").error | ||
12 | 13 | ||
13 | ---[[ ATOMIC TYPES ]]--- | 14 | ---[[ ATOMIC TYPES ]]--- |
14 | 15 | ||
diff --git a/util.lua b/util.lua index a13912c..7040e33 100644 --- a/util.lua +++ b/util.lua | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | local m = {} | 3 | local m = {} |
4 | local string = string | 4 | local string = string |
5 | local utf8 = require("utf8") | ||
6 | 5 | ||
7 | m.luaerror = error | 6 | m.luaerror = error |
8 | 7 | ||
@@ -23,17 +22,5 @@ function m.pop (tbl) | |||
23 | return table.remove(tbl, 1) | 22 | return table.remove(tbl, 1) |
24 | end | 23 | end |
25 | 24 | ||
26 | function m.tochars (str) | ||
27 | local cs = {} | ||
28 | for _, code in utf8.codes(str) do | ||
29 | table.insert(cs, code) | ||
30 | end | ||
31 | return cs | ||
32 | end | ||
33 | |||
34 | function m.constantly (x) | ||
35 | return function () return x end | ||
36 | end | ||
37 | |||
38 | -------- | 25 | -------- |
39 | return m | 26 | return m |