parent
38f93f7faa
commit
61d34834de
|
@ -31,9 +31,10 @@ class StringGrammar(Grammar):
|
|||
class SubTypeGrammar(Grammar): pass
|
||||
SubTypeGrammar.rules = [
|
||||
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
|
||||
PatternRule('scala.type', '[A-Z][a-zA-Z0-9_.]*'),
|
||||
PatternRule('scala.type', '[a-zA-Z_][a-zA-Z0-9_.#]*'),
|
||||
PatternRule('spaces', ' +'),
|
||||
PatternRule('scala.annotation', '@[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule('delimiter', r'(?:;|=>|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=|#)'),
|
||||
PatternRule('scala.annotation', '@[a-zA-Z_][a-zA-Z0-9_.]*'),
|
||||
RegionRule('scala.string', '"', StringGrammar, '"'),
|
||||
]
|
||||
|
||||
|
@ -66,7 +67,7 @@ class ScalaGrammar(Grammar):
|
|||
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
|
||||
|
||||
# match various scala delimiters and operators
|
||||
PatternRule('delimiter', r'(?:;|=>|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
|
||||
PatternRule('delimiter', r'(?:;|=>|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=|#)'),
|
||||
|
||||
# semi-hack to support XML
|
||||
RegionRule('scala.inline', r'(?:^| )(?=<[a-zA-Z_])', XMLGrammar, '^[ \t]*$'),
|
||||
|
|
19
tab.py
19
tab.py
|
@ -375,6 +375,11 @@ class StackTabber2(Tabber):
|
|||
marker = self.stack[-1]
|
||||
if marker.name in ('control', 'continue', 'pre-control'):
|
||||
self.stack.pop()
|
||||
elif marker.name == 'case':
|
||||
if t.string in self.close_scope_tokens.get(t.fqname(), empty):
|
||||
self.stack.pop()
|
||||
else:
|
||||
break
|
||||
elif marker.name in self.open_tokens.get(marker.type_, empty):
|
||||
s = self.open_tokens[marker.type_][marker.name]
|
||||
if s in (None, t.string):
|
||||
|
@ -454,12 +459,16 @@ class StackTabber2(Tabber):
|
|||
else:
|
||||
self.stack.pop()
|
||||
|
||||
if t.string in self.open_scope_tokens.get(t.name, empty):
|
||||
self._pop('continue', 'control')
|
||||
if i == 0 and t.string in self.open_scope_tokens.get(t.name, empty):
|
||||
self._save_curr_level()
|
||||
open_scope = t.string in self.open_scope_tokens.get(t.name, empty)
|
||||
|
||||
if i == end - start or self.fixed_indent:
|
||||
if open_scope:
|
||||
self._pop('continue', 'control')
|
||||
if i == 0:
|
||||
self._save_curr_level()
|
||||
|
||||
if not open_scope and self.stack and self._peek().name == 'case':
|
||||
level = self._get_curr_level()
|
||||
elif i == end - start or self.fixed_indent:
|
||||
level = self._get_next_level()
|
||||
else:
|
||||
level = tokens[i + 1].x
|
||||
|
|
Loading…
Reference in New Issue