diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-27 16:45:11 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-27 16:45:35 -0700 |
| commit | b54829de363f67a8a6f6131ceb0eb27aa09d4292 (patch) | |
| tree | c03e3a7ad9a5cd58d0055b262e0ddf1bca89ba97 /nomsu.lua | |
| parent | 6fecb5d3950949d3bcf232f74283229248c21247 (diff) | |
Better text interpolation/handling of "\". Also added syntax support for
(statement; statement)
Diffstat (limited to 'nomsu.lua')
| -rw-r--r-- | nomsu.lua | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -165,9 +165,9 @@ do 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) + local prev_line = src:sub(LINE_STARTS[src][line_no - 1] or 1, LINE_STARTS[src][line_no] - 2) + local err_line = src:sub(LINE_STARTS[src][line_no], (LINE_STARTS[src][line_no + 1] or 0) - 2) + local next_line = src:sub(LINE_STARTS[src][line_no + 1] or -1, (LINE_STARTS[src][line_no + 2] or 0) - 2) local pointer = ("-"):rep(pos - LINE_STARTS[src][line_no]) .. "^" err_msg = (err_msg or "Parse error") .. " in " .. tostring(lpeg.userdata.source_code.source.filename) .. " on line " .. tostring(line_no) .. ":\n" err_msg = err_msg .. "\n" .. tostring(prev_line) .. "\n" .. tostring(err_line) .. "\n" .. tostring(pointer) .. "\n" .. tostring(next_line) .. "\n" |
