diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-14 14:54:55 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-14 14:55:00 -0700 |
| commit | 3e2844ef62d1b1fd099a790a0927e0768a2a846b (patch) | |
| tree | ccf8efbd2eae800d016da6f2bf27d7d6a3396f08 /nomsu_compiler.moon | |
| parent | 9bba7dd2cd5860c8b527f10044f7e1c4d1a4a0e2 (diff) | |
Added error truncating.
Diffstat (limited to 'nomsu_compiler.moon')
| -rw-r--r-- | nomsu_compiler.moon | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon index ea79843..9fcf796 100644 --- a/nomsu_compiler.moon +++ b/nomsu_compiler.moon @@ -103,25 +103,24 @@ with NomsuCompiler parse = Parsers[syntax_version] or Parsers[max_parser_version] tree = parse(nomsu_code, source.filename) pretty_error = require("pretty_errors") - -- TODO: truncate find_errors = (t)-> if t.type == "Error" - return pretty_error{ + coroutine.yield pretty_error{ error:t.error, hint:t.hint, source:t\get_source_code! start:t.source.start, stop:t.source.stop } - errs = "" - for k,v in pairs(t) - continue unless AST.is_syntax_tree(v) - err = find_errors(v) - if #err > 0 - if #errs > 0 then errs ..="\n\n" - errs ..= err - return errs - - errs = find_errors(tree) + else + for k,v in pairs(t) + continue unless AST.is_syntax_tree(v) + find_errors(v) + + errs = [err for err in coroutine.wrap(-> find_errors(tree))] + if #errs > 4 + num_errs = #errs + 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(errs, 0) + error(table.concat(errs, '\n\n'), 0) return tree .can_optimize = -> false |
