parent
ab5d13b363
commit
c47fca63d6
|
@ -1,5 +1,7 @@
|
|||
from mode import Fundamental
|
||||
from lex import Grammar, PatternRule, RegionRule, NocaseKeywordRule
|
||||
from tab import StackTabber
|
||||
import regex
|
||||
|
||||
directives = '''abbreviate array attribute btrace class constant default
|
||||
dictionary end endif etrace extend fake_action global ifdef ifndef iftrue
|
||||
|
@ -64,9 +66,45 @@ class Inform6Grammar(Grammar):
|
|||
PatternRule('continuation', r'\\\n$'),
|
||||
]
|
||||
|
||||
class Inform6Tabber(StackTabber):
|
||||
def is_base(self, y):
|
||||
if y == 0:
|
||||
return True
|
||||
h = self.mode.window.buffer.highlights[self.mode.name]
|
||||
if not h.tokens[y]:
|
||||
return False
|
||||
t = h.tokens[y][0]
|
||||
if t.name != 'inform6.directive':
|
||||
return False
|
||||
return t.string.lower() in ('constant', 'include', 'object')
|
||||
def _handle_open_token(self, currlvl, y, i):
|
||||
t = self.get_token(y, i)
|
||||
l = self.get_curr_level() + self.mode.tabwidth
|
||||
self._append(t.string, l, y)
|
||||
return currlvl
|
||||
def _handle_other_token(self, currlvl, y, i):
|
||||
w = self.mode.tabwidth
|
||||
t = self.get_token(y, i)
|
||||
s = t.string.lower()
|
||||
n = t.fqname()
|
||||
if n == 'inform6.directive':
|
||||
if s == 'object':
|
||||
self._append('object', currlvl + w, y)
|
||||
if n == 'inform6.keyword':
|
||||
if s in ('with', 'has'):
|
||||
if self._peek_name() == 'keyword':
|
||||
self._pop()
|
||||
currlvl -= w
|
||||
self._append('keyword', currlvl + w, y)
|
||||
elif n == 'delimiter':
|
||||
self._opt_pop('keyword')
|
||||
self._opt_pop('object')
|
||||
return currlvl
|
||||
|
||||
class Inform6(Fundamental):
|
||||
name = 'inform6'
|
||||
extensions = ['.inf']
|
||||
tabbercls = Inform6Tabber
|
||||
grammar = Inform6Grammar
|
||||
commentc = '!'
|
||||
opentokens = ('delimiter',)
|
||||
|
|
Loading…
Reference in New Issue