asm command

--HG--
branch : pmacs2
This commit is contained in:
~d6 2022-01-27 21:55:10 -05:00
parent 0cfae9cb2a
commit 864c1f4e9d
1 changed files with 19 additions and 1 deletions

View File

@ -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': ('}',),