From 1f1f6ff3c4df74ec4dd091628277b884874f7294 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Mon, 27 Sep 2010 09:33:01 -0400 Subject: [PATCH] scala highlighting update --HG-- branch : pmacs2 --- mode/scala.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/mode/scala.py b/mode/scala.py index f9736af..d2e0ab1 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -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'}