diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-19 17:23:44 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-19 17:23:54 -0700 |
| commit | da33269c307c8a045e548cb1df2a3281a7a0f99e (patch) | |
| tree | 9451b857633b0869b4589a73107056815aa560c7 /nomsu.moon | |
| parent | dcb380f1f6ec67c52364b1246546f1f6b2c168d3 (diff) | |
All tests passing (except object)
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -22,6 +22,7 @@ export Tuple Tuple = immutable(nil, {name:"Tuple"}) {:repr, :stringify, :min, :max, :equivalent, :set, :is_list, :sum} = utils colors = setmetatable({}, {__index:->""}) +export colored colored = setmetatable({}, {__index:(_,color)-> ((msg)-> colors[color]..tostring(msg or '')..colors.reset)}) {:insert, :remove, :concat} = table debug_getinfo = debug.getinfo @@ -154,11 +155,13 @@ NOMSU_DEFS = with {} return start + #nodent .error = (src,pos,err_msg)-> + --src = tostring(FILE_CACHE[lpeg.userdata.source_code.source.filename]) if src\sub(pos,pos)\match("[\r\n]") pos += #src\match("[ \t\n\r]*", pos) line_no = 1 text_loc = lpeg.userdata.source_code.source\sub(pos,pos) line_no = text_loc\get_line_number! + src = FILE_CACHE[text_loc.filename] prev_line = src\sub(LINE_STARTS[src][line_no-1] or 1, LINE_STARTS[src][line_no]-1) err_line = src\sub(LINE_STARTS[src][line_no], (LINE_STARTS[src][line_no+1] or 0)-1) next_line = src\sub(LINE_STARTS[src][line_no+1] or -1, (LINE_STARTS[src][line_no+2] or 0)-1) @@ -170,7 +173,7 @@ NOMSU_DEFS = with {} setmetatable(NOMSU_DEFS, {__index:(key)=> make_node = (start, value, stop)-> if type(value) == 'table' then error("Not a tuple: #{repr value}")-- = Tuple(value) - source = lpeg.userdata.source_code.source\sub(start,stop) + source = lpeg.userdata.source_code.source\sub(start,stop-1) node = Types[key](value, source) return node self[key] = make_node |
