parent
864c1f4e9d
commit
891535fa99
17
mode/tal.py
17
mode/tal.py
|
@ -73,18 +73,26 @@ class Talasm(Method):
|
|||
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):
|
||||
def get_dest(self, w):
|
||||
path = w.buffer.path
|
||||
if path.endswith('.tal'):
|
||||
dest = path[:-4] + '.rom'
|
||||
return path[:-4] + '.rom'
|
||||
else:
|
||||
raise Exception('invalid path: %s' % path)
|
||||
def _execute(self, w, **vargs):
|
||||
path = w.buffer.path
|
||||
dest = self.get_dest(w)
|
||||
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 TalCheck(Talasm):
|
||||
'''Check the syntax of the current .tal file'''
|
||||
def get_dest(self, w):
|
||||
return '/dev/null'
|
||||
|
||||
class Taldoc(Method):
|
||||
'''View documentation'''
|
||||
ops = {
|
||||
|
@ -237,7 +245,7 @@ class Tal(Fundamental):
|
|||
name = 'tal'
|
||||
extensions = ['.tal']
|
||||
grammar = TalGrammar
|
||||
actions = [Taldoc, Talasm]
|
||||
actions = [Taldoc, Talasm, TalCheck]
|
||||
colors = {
|
||||
'tal.addr': hi_cyan,
|
||||
'tal.defmacro': hi_blue,
|
||||
|
@ -256,7 +264,8 @@ class Tal(Fundamental):
|
|||
closetokens = ('delimiter',)
|
||||
closetags = {')': '(', ']': '[', '}': '{'}
|
||||
_bindings = {
|
||||
'talasm': ('C-c c', 'C-c C-c'),
|
||||
'talasm': ('C-c c', 'C-c C-c',),
|
||||
'tal-check': ('C-c s',),
|
||||
'taldoc': ('C-c p',),
|
||||
'close-paren': (')',),
|
||||
'close-brace': ('}',),
|
||||
|
|
Loading…
Reference in New Issue