aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-09-14 15:19:50 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-09-14 15:20:07 -0700
commit626b6cab7988e26766ba64178dd67e4093494552 (patch)
tree47a12a5ac0364661335e53c045fd1a26b4a6fdf9 /nomsu_compiler.moon
parent3e2844ef62d1b1fd099a790a0927e0768a2a846b (diff)
Updated compiler to produce cool string output.
Diffstat (limited to 'nomsu_compiler.moon')
-rw-r--r--nomsu_compiler.moon17
1 files changed, 8 insertions, 9 deletions
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 9fcf796..b5168a5 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -105,10 +105,7 @@ with NomsuCompiler
pretty_error = require("pretty_errors")
find_errors = (t)->
if t.type == "Error"
- coroutine.yield pretty_error{
- error:t.error, hint:t.hint, source:t\get_source_code!
- start:t.source.start, stop:t.source.stop
- }
+ coroutine.yield t
else
for k,v in pairs(t)
continue unless AST.is_syntax_tree(v)
@@ -120,7 +117,11 @@ with NomsuCompiler
errs = [errs[i] for i=1,3]
table.insert(errs, "\027[31;1m +#{num_errs-#errs} additional errors...\027[0m\n")
if #errs > 0
- error(table.concat(errs, '\n\n'), 0)
+ err_strings = [pretty_error{
+ error:t.error, hint:t.hint, source:t\get_source_code!
+ start:t.source.start, stop:t.source.stop
+ } for t in *errs]
+ error(table.concat(err_strings, '\n\n'), 0)
return tree
.can_optimize = -> false
@@ -833,13 +834,11 @@ with NomsuCompiler
elseif bit.type != "List" and bit.type != "Dict"
interp_nomsu\parenthesize!
nomsu\append interp_nomsu
- if interp_nomsu\is_multiline! and i < #tree
+ if interp_nomsu\is_multiline!
nomsu\append "\n.."
nomsu = NomsuCode(tree.source)
add_text(nomsu, tree)
- if nomsu\is_multiline! and nomsu\match("\n$")
- nomsu\append '\\("")' -- Need to specify where the text ends
- return NomsuCode(tree.source, '".."\n ', nomsu)
+ return NomsuCode(tree.source, '"\\\n ..', nomsu, '"')
when "List", "Dict"
assert #tree > 0