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