aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-29 16:16:45 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-29 16:17:33 -0800
commitbc41cc3a244bf47679d1c47d17006a2aa7356bc8 (patch)
tree102ec25b54f795d7a24648faa129f4dbccef3619 /nomsu_compiler.moon
parentfebe7e82e06e1071c312f449b1ced319ef9a6932 (diff)
Switched to have colors/utf8 be optional, fixed an issue with currently
running files leaking when errors occurred (causing spurious circular import errors), and improved tutorial.
Diffstat (limited to 'nomsu_compiler.moon')
-rw-r--r--nomsu_compiler.moon13
1 files changed, 13 insertions, 0 deletions
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 3993490..73cc5a8 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -4,6 +4,7 @@
unpack or= table.unpack
{:match, :sub, :gsub, :format, :byte, :find} = string
{:LuaCode, :Source} = require "code_obj"
+require "text"
SyntaxTree = require "syntax_tree"
Files = require "files"
@@ -15,6 +16,18 @@ fail_at = (source, msg)->
source = source.source
elseif type(source) == 'string'
source = Source\from_string(source)
+ else
+ -- debug.getinfo() output:
+ assert(source.short_src and source.currentline)
+ file = Files.read(source.short_src)
+ assert file, "Could not find #{source.short_src}"
+ lines = file\lines!
+ start = 1
+ for i=1,source.currentline-1
+ start += #lines[i]
+ stop = start + #lines[source.currentline]
+ source = Source(source.short_src, start, stop)
+
if source and not file
file = Files.read(source.filename)