diff --git a/mode/scala.py b/mode/scala.py index e792968..4a664c9 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -1,12 +1,11 @@ -import commands -import time -from tab import StackTabber -from method import Method +#import commands +#from tab import StackTabber +#from method import Method from mode import Fundamental from lex import Grammar, PatternRule, RegionRule, PatternMatchRule from mode.python import StringGrammar1, StringGrammar2 -from mode.pipe import Pipe -from method.shell import Interact +#from mode.pipe import Pipe +#from method.shell import Interact chr1 = '[a-zA-Z_]' chr2 = '[a-zA-Z_0-9]' @@ -18,6 +17,12 @@ NestedCommentGrammar.rules = [ PatternRule('data', r'(?:[^\*]|\*(?!/))+'), ] +class StringGrammar(Grammar): + rules = [ + PatternRule('escaped', r"\\u[0-9A-Fa-f]{4}|\\[0-7]{1,3}|\\[btnfr\"'\\]"), + PatternRule('data', r'[^\\"]+'), + ] + class ScalaGrammar(Grammar): rules = [ PatternRule('scala.comment', '//.*$'), @@ -37,8 +42,8 @@ class ScalaGrammar(Grammar): PatternRule('scala.bool', '(?:true|false)(?![a-zA-Z0-9_])'), PatternRule('scala.char', r"'(?:[^'\\]|\\u[0-9A-Fa-f]{4}|\\[0-7]{1,3}|\\[btnfr\"'\\])'"), - #PatternRule('scala.string', '-?[0-9]'), - #PatternRule('scala.symbol', '-?[0-9]'), + RegionRule('scala.string', '"', StringGrammar, '"'), + PatternRule('scala.symbol', "'[a-zA-Z_][a-zA-Z0-9_]*"), PatternRule('scalar.null', 'null'), ]