Compare commits

..

No commits in common. "225a6ab3e2b8901321b608f97ee695d30cfbed19" and "480754b38ecd2b1952d440cff8f9d959ac714a28" have entirely different histories.

3 changed files with 10 additions and 57 deletions

View File

@ -12,7 +12,7 @@ _data = '''
[y:d:*] ************ ***** ***** **** ************* ********** **********
[y:d:*] ********** ***** ***** **** ****** **** ******** ********
[y:d:*] ***
[y:d:*] *** [c:d:*]pmacs[d:d] is a python-based text editor by [c:d:*]Erik Osheim[d:d], [b:d:*](c) 2005-2021
[y:d:*] *** [c:d:*]pmacs[d:d] is a python-based text editor by [c:d:*]Erik Osheim[d:d], [b:d:*](c) 2005-2009
[y:d:*] *** [c:d:*]pmacs[d:d] is available to you under the [c:d:*]GNU General Public License v2
[y:d:*]*****
[y:d:*]***** [d:d]to view available commands use [c:d:*]C-c M-h [b:d:*](show-bindings-buffer)

View File

@ -6,8 +6,8 @@ class ConfGrammar(Grammar):
rules = [
PatternRule('conf.comment', '#.*$'),
PatternRule('conf.comment', '//.*$'),
RegionRule('conf.string', "'", StringGrammar1, "'"),
RegionRule('conf.string', '"', StringGrammar2, '"'),
#RegionRule('conf.string', "'", StringGrammar1, "'"),
#RegionRule('conf.string', '"', StringGrammar2, '"'),
PatternRule('conf.data', r'(?:[^\'"#/]|/(?!/))+'),
]

View File

@ -1,24 +1,14 @@
from method import Argument, Method
from mode import Fundamental
from lex import Grammar, PatternRule, PatternMatchRule, RegionRule
from lex import Grammar, PatternRule, RegionRule
import re
class CommentGrammar(Grammar): pass
comment_rule = RegionRule('comment', r'\((?:[ \t\n]|$)', CommentGrammar, r'\)(?:[ \t\n]|$)')
CommentGrammar.rules = [
comment_rule,
PatternRule('data', r'[^\(\) \t\n][^ \t\n]*|[\(\)][^ \t\n]+'),
PatternRule('spaces', r'[ \t]+'),
]
class TalGrammar(Grammar):
rules = [
PatternRule('spaces', '[ \t]+'),
comment_rule,
RegionRule('comment', r'\((?:[ \t]|$)', Grammar, '(?:^|[ \t])\)'),
PatternRule('delimiter', r'[\[\]{}]'),
PatternRule('tal.inst', r'(BRK|LIT|INC|POP|DUP|NIP|SWP|OVR|ROT|EQU|NEQ|GTH|LTH|JMP|JCN|JSR|STH|LDZ|STZ|LDR|STR|LDA|STA|DEI|DEO|ADD|SUB|MUL|DIV|AND|ORA|EOR|SFT)2?k?r?(?![a-zA-z0-9_])'), # instructions
PatternRule('tal.inst', r'(BRK|LIT|INC|POP|DUP|NIP|SWP|OVR|ROT|EQU|NEQ|GTH|LTH|JMP|JCN|JSR|STH|LDZ|STZ|LDR|STR|LDA|STA|DEI|DEO|ADD|SUB|MUL|DIV|AND|ORA|EOR|SFT)2?k?r?'), # instructions
PatternRule('tal.defmacro', r'%[^ \t\n]+'), # macro-define
PatternRule('tal.pad', r'\|[^ \t\n]+'), # pad (absolute)
PatternRule('tal.pad', r'\$[^ \t\n]+'), # pad (relative)
@ -32,7 +22,6 @@ class TalGrammar(Grammar):
PatternRule('tal.addr', r':[^/ \t\n]+'), # raw addr
PatternRule('tal.addr', r'\'[^/ \t\n]+'), # raw char
PatternRule('tal.addr', r'\"[^/ \t\n]+'), # raw word
PatternMatchRule('x', r'(~)(.+)$', 'tal.include', 'tal.filename'),
PatternRule('tal.word', r'[^ \t\n]+'),
PatternRule('eol', '\n'),
]
@ -68,31 +57,6 @@ 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 get_dest(self, w):
path = w.buffer.path
if path.endswith('.tal'):
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 = {
@ -134,7 +98,7 @@ class Taldoc(Method):
'AND': ['And', [['a', 'b'], ['a&b']], None, 'bitwise-and (a & b)'],
'ORA': ['Or', [['a', 'b'], ['a|b']], None, 'bitwise-or (a | b)'],
'EOR': ['Exclusive Or', [['a', 'b'], ['a^b']], None, 'bitwise-xor (a ^ b)'],
'SFT': ['Shift', [['a', 'b^'], ['c']], None, 'bitshift right (b & 0x0f) then left (b >> 4)'],
'SFT': ['Shift', [['a', 'b^'], ['c']], None, 'bitshift left (b >> 4) then right (b & 0xf)'],
}
inst_re = re.compile(r'^([A-Z]{3})(2?k?r?)$')
addr_dict = {
@ -197,10 +161,7 @@ class Taldoc(Method):
if '2' in suffix:
glyph = '*'
if 'k' in suffix:
if ds is not None:
ds = [ds[0], ds[0] + ds[1]]
if rs is not None:
rs = [rs[0], rs[0] + rs[1]]
ds = [ds[0], ds[0] + ds[1]]
def mark(x):
if x.endswith('^') or x.endswith('*'):
return x
@ -211,7 +172,7 @@ class Taldoc(Method):
if rs is None:
msg = '%s (%s) %s: %s' % (word, stk(ds), name, desc)
elif ds is None:
msg = '%s {%s} %s: %s' % (word, stk(rs), name, desc)
msg = '%s {%s} %: %s' % (word, stk(rs), name, desc)
else:
msg = '%s (%s) {%s} %s: %s' % (word, stk(ds), stk(rs), name, desc)
w.set_error(msg)
@ -245,7 +206,7 @@ class Tal(Fundamental):
name = 'tal'
extensions = ['.tal']
grammar = TalGrammar
actions = [Taldoc, Talasm, TalCheck]
actions = [Taldoc]
colors = {
'tal.addr': hi_cyan,
'tal.defmacro': hi_blue,
@ -256,16 +217,8 @@ class Tal(Fundamental):
'tal.number': hi_green,
'tal.pad': hi_orange,
'tal.spacer': hi_orange,
'tal.include': lo_cyan,
'tal.filename': hi_cyan,
}
opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
_bindings = {
'talasm': ('C-c c', 'C-c C-c',),
'tal-check': ('C-c s',),
'taldoc': ('C-c p',),
'close-paren': (')',),
'close-brace': ('}',),