diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-14 15:19:50 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-14 15:20:07 -0700 |
| commit | 626b6cab7988e26766ba64178dd67e4093494552 (patch) | |
| tree | 47a12a5ac0364661335e53c045fd1a26b4a6fdf9 /nomsu_compiler.lua | |
| parent | 3e2844ef62d1b1fd099a790a0927e0768a2a846b (diff) | |
Updated compiler to produce cool string output.
Diffstat (limited to 'nomsu_compiler.lua')
| -rw-r--r-- | nomsu_compiler.lua | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua index b71eab0..c7b7dc6 100644 --- a/nomsu_compiler.lua +++ b/nomsu_compiler.lua @@ -184,13 +184,7 @@ do local find_errors find_errors = function(t) if t.type == "Error" then - return coroutine.yield(pretty_error({ - error = t.error, - hint = t.hint, - source = t:get_source_code(), - start = t.source.start, - stop = t.source.stop - })) + return coroutine.yield(t) else for k, v in pairs(t) do local _continue_0 = false @@ -234,7 +228,24 @@ do table.insert(errs, "\027[31;1m +" .. tostring(num_errs - #errs) .. " additional errors...\027[0m\n") end if #errs > 0 then - error(table.concat(errs, '\n\n'), 0) + local err_strings + do + local _accum_0 = { } + local _len_0 = 1 + for _index_0 = 1, #errs do + local t = errs[_index_0] + _accum_0[_len_0] = pretty_error({ + error = t.error, + hint = t.hint, + source = t:get_source_code(), + start = t.source.start, + stop = t.source.stop + }) + _len_0 = _len_0 + 1 + end + err_strings = _accum_0 + end + error(table.concat(err_strings, '\n\n'), 0) end return tree end @@ -1305,7 +1316,7 @@ do end end nomsu:append(interp_nomsu) - if interp_nomsu:is_multiline() and i < #tree then + if interp_nomsu:is_multiline() then nomsu:append("\n..") end end @@ -1313,10 +1324,7 @@ do end local nomsu = NomsuCode(tree.source) add_text(nomsu, tree) - if nomsu:is_multiline() and nomsu:match("\n$") then - nomsu:append('\\("")') - end - return NomsuCode(tree.source, '".."\n ', nomsu) + return NomsuCode(tree.source, '"\\\n ..', nomsu, '"') elseif "List" == _exp_0 or "Dict" == _exp_0 then assert(#tree > 0) local nomsu = NomsuCode(tree.source, pop_comments(tree[1].source.start)) |
