From ac0fb2afb22a3cbd799b7d95d72843e14fba8656 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Wed, 11 Aug 2010 08:55:30 -0400 Subject: [PATCH] added scala strings and symbols --HG-- branch : pmacs2 --- mode/scala.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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'), ]