improvements to scala mode

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-09-10 00:18:43 -04:00
parent c439163434
commit eed9887e8f
1 changed files with 20 additions and 9 deletions

View File

@ -1,11 +1,9 @@
#import commands
from tab import StackTabber2
#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.xml import XMLGrammar
from mode.pipe import Pipe
from method.shell import Interact
chr1 = '[a-zA-Z_]'
chr2 = '[a-zA-Z_0-9]'
@ -28,11 +26,11 @@ class ScalaGrammar(Grammar):
PatternRule('scala.comment', '//.*$'),
RegionRule('scala.comment', r'/\*', NestedCommentGrammar, r'\*/'),
PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
PatternRule('spaces', r'(?:\t| )+'),
PatternRule('eol', r'\n'),
PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<|>|:|/|\+|-|\*|=)'),
PatternRule('scala.def', '(?<=(?<![a-zA-Z0-9_])def )[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule('scala.class', '(?<=(?<![a-zA-Z0-9_])class )[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule('scala.class', '(?<=(?<![a-zA-Z0-9_])object )[a-zA-Z_][a-zA-Z0-9_]*'),
@ -52,10 +50,10 @@ class ScalaGrammar(Grammar):
PatternRule('scala.symbol', "'[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule('scala.annotation', '@[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule('scala.bareword', '[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule('scala.null', 'null'),
RegionRule('scala.inline', r'(?:^| )(?=<[a-zA-Z_])', XMLGrammar, '^[ \t]*$'),
]
class ScalaTabber(StackTabber2):
@ -84,6 +82,13 @@ class ScalaTabber(StackTabber2):
# the default is to assume no
return False
class ScalaStart(Interact):
args = []
modename = 'scalapipe'
reuse = True
def _execute(self, w, **vargs):
Interact._execute(self, w, bname='*Scala*', cmd='scala')
class Scala(Fundamental):
name = 'Scala'
extensions = ['.scala']
@ -91,6 +96,7 @@ class Scala(Fundamental):
tabbercls = ScalaTabber
grammar = ScalaGrammar
commentc = '//'
actions = [ScalaStart]
opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',)
@ -115,5 +121,10 @@ class Scala(Fundamental):
'close-bracket': (']',),
}
class ScalaPipe(Pipe):
name = 'scalapipe'
grammar = ScalaGrammar
def install(*args):
Scala.install(*args)
ScalaPipe.install(*args)