aboutsummaryrefslogtreecommitdiff
path: root/nomsu.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-04-19 17:23:44 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-04-19 17:23:54 -0700
commitda33269c307c8a045e548cb1df2a3281a7a0f99e (patch)
tree9451b857633b0869b4589a73107056815aa560c7 /nomsu.lua
parentdcb380f1f6ec67c52364b1246546f1f6b2c168d3 (diff)
All tests passing (except object)
Diffstat (limited to 'nomsu.lua')
-rw-r--r--nomsu.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 9b273d1..b76a929 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -17,7 +17,7 @@ local colors = setmetatable({ }, {
return ""
end
})
-local colored = setmetatable({ }, {
+colored = setmetatable({ }, {
__index = function(_, color)
return (function(msg)
return colors[color] .. tostring(msg or '') .. colors.reset
@@ -170,6 +170,7 @@ do
local line_no = 1
local text_loc = lpeg.userdata.source_code.source:sub(pos, pos)
line_no = text_loc:get_line_number()
+ src = FILE_CACHE[text_loc.filename]
local prev_line = src:sub(LINE_STARTS[src][line_no - 1] or 1, LINE_STARTS[src][line_no] - 1)
local err_line = src:sub(LINE_STARTS[src][line_no], (LINE_STARTS[src][line_no + 1] or 0) - 1)
local next_line = src:sub(LINE_STARTS[src][line_no + 1] or -1, (LINE_STARTS[src][line_no + 2] or 0) - 1)
@@ -187,7 +188,7 @@ setmetatable(NOMSU_DEFS, {
if type(value) == 'table' then
error("Not a tuple: " .. tostring(repr(value)))
end
- local source = lpeg.userdata.source_code.source:sub(start, stop)
+ local source = lpeg.userdata.source_code.source:sub(start, stop - 1)
local node = Types[key](value, source)
return node
end