syntax check

--HG--
branch : pmacs2
This commit is contained in:
~d6 2022-03-24 22:41:26 -04:00
parent 864c1f4e9d
commit 891535fa99
1 changed files with 13 additions and 4 deletions

View File

@ -73,18 +73,26 @@ class Talasm(Method):
bname = '*Talasm*' bname = '*Talasm*'
def run_pipe(self, w, args, switch, mname=None): def run_pipe(self, w, args, switch, mname=None):
return w.application.run_pipe(args, w.buffer, self.bname, switch, mname) 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 path = w.buffer.path
if path.endswith('.tal'): if path.endswith('.tal'):
dest = path[:-4] + '.rom' return path[:-4] + '.rom'
else: else:
raise Exception('invalid path: %s' % path) raise Exception('invalid path: %s' % path)
def _execute(self, w, **vargs):
path = w.buffer.path
dest = self.get_dest(w)
args = ['uxnasm', path, dest] args = ['uxnasm', path, dest]
r = self.run_pipe(w, args, lambda x: x != 0, 'error') r = self.run_pipe(w, args, lambda x: x != 0, 'error')
b = w.application.get_buffer_by_name(self.bname) b = w.application.get_buffer_by_name(self.bname)
b.orig_path = w.buffer.path b.orig_path = w.buffer.path
if r == 0: w.set_error(b.lines[-2]) 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): class Taldoc(Method):
'''View documentation''' '''View documentation'''
ops = { ops = {
@ -237,7 +245,7 @@ class Tal(Fundamental):
name = 'tal' name = 'tal'
extensions = ['.tal'] extensions = ['.tal']
grammar = TalGrammar grammar = TalGrammar
actions = [Taldoc, Talasm] actions = [Taldoc, Talasm, TalCheck]
colors = { colors = {
'tal.addr': hi_cyan, 'tal.addr': hi_cyan,
'tal.defmacro': hi_blue, 'tal.defmacro': hi_blue,
@ -256,7 +264,8 @@ class Tal(Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
_bindings = { _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',), 'taldoc': ('C-c p',),
'close-paren': (')',), 'close-paren': (')',),
'close-brace': ('}',), 'close-brace': ('}',),