diff --git a/mode/tal.py b/mode/tal.py index 6770fb2..26d5212 100644 --- a/mode/tal.py +++ b/mode/tal.py @@ -68,6 +68,23 @@ hi_cyan = ('cyan155', 'default') lo_blue = ('blue113', 'default') hi_blue = ('blue225', 'default') +class Talasm(Method): + '''Assemble the given .tal file''' + bname = '*Talasm*' + def run_pipe(self, w, args, switch, mname=None): + return w.application.run_pipe(args, w.buffer, self.bname, switch, mname) + def _execute(self, w, **vargs): + path = w.buffer.path + if path.endswith('.tal'): + dest = path[:-4] + '.rom' + else: + raise Exception('invalid path: %s' % path) + args = ['uxnasm', path, dest] + r = self.run_pipe(w, args, lambda x: x != 0, 'error') + b = w.application.get_buffer_by_name(self.bname) + b.orig_path = w.buffer.path + if r == 0: w.set_error(b.lines[-2]) + class Taldoc(Method): '''View documentation''' ops = { @@ -220,7 +237,7 @@ class Tal(Fundamental): name = 'tal' extensions = ['.tal'] grammar = TalGrammar - actions = [Taldoc] + actions = [Taldoc, Talasm] colors = { 'tal.addr': hi_cyan, 'tal.defmacro': hi_blue, @@ -239,6 +256,7 @@ class Tal(Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} _bindings = { + 'talasm': ('C-c c', 'C-c C-c'), 'taldoc': ('C-c p',), 'close-paren': (')',), 'close-brace': ('}',),