parent
6354d80dab
commit
1f1f6ff3c4
|
@ -25,6 +25,13 @@ class StringGrammar(Grammar):
|
|||
PatternRule('data', r'[^\\"]+'),
|
||||
]
|
||||
|
||||
class SubTypeGrammar(Grammar): pass
|
||||
SubTypeGrammar.rules = [
|
||||
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
|
||||
PatternRule('scala.type', '[a-zA-Z0-9_]+'),
|
||||
PatternRule('spaces', ' +'),
|
||||
]
|
||||
|
||||
class ScalaGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule('scala.comment', '//.*$'),
|
||||
|
@ -35,7 +42,14 @@ class ScalaGrammar(Grammar):
|
|||
PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)( +)([a-zA-Z0-9_]+)',
|
||||
'delimiter', 'spaces', 'scala.type'),
|
||||
|
||||
PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
|
||||
PatternMatchRule('x', r'(extends)( +)([a-zA-Z0-9_]+)',
|
||||
'scala.reserved', 'spaces', 'scala.type'),
|
||||
PatternMatchRule('x', r'(with)( +)([a-zA-Z0-9_]+)',
|
||||
'scala.reserved', 'spaces', 'scala.type'),
|
||||
|
||||
#PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
|
||||
PatternRule('delimiter', r'(?:;|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
|
||||
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
|
||||
|
||||
RegionRule('scala.inline', r'(?:^| )(?=<[a-zA-Z_])', XMLGrammar, '^[ \t]*$'),
|
||||
PatternRule('spaces', r'(?:\t| )+'),
|
||||
|
@ -66,8 +80,10 @@ class ScalaGrammar(Grammar):
|
|||
]
|
||||
|
||||
class ScalaTabber(StackTabber2):
|
||||
open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}}
|
||||
close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}}
|
||||
#open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}}
|
||||
#close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}}
|
||||
open_tokens = {'delimiter': {'{': '}', '(': ')'}}
|
||||
close_tokens = {'delimiter': {'}': '{', ')': '('}}
|
||||
control_tokens = {'scala.reserved': set(('if', 'else', 'while', 'do', 'for'))}
|
||||
end_at_eof = True
|
||||
start_free_tokens = {'string.start': 'string.end'}
|
||||
|
|
Loading…
Reference in New Issue