first stab at scala indenter... by no means complete or correct

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-08-11 23:16:48 -04:00
parent 0f1a81d199
commit dd3151d354
1 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#import commands #import commands
#from tab import StackTabber from tab import StackTabber2
#from method import Method #from method import Method
from mode import Fundamental from mode import Fundamental
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
@ -54,11 +54,25 @@ class ScalaGrammar(Grammar):
PatternRule('scala.null', 'null'), PatternRule('scala.null', 'null'),
] ]
class ScalaTabber(StackTabber2):
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'}
end_free_tokens = {'string.end': 'string.start'}
is_ignored_tokens = set(('spaces', 'eol', 'comment', 'comment.start',
'comment.data', 'comment.null', 'comment.end'))
is_indent_tokens = set(('spaces',))
def is_base(self, y): return y == 0
class Scala(Fundamental): class Scala(Fundamental):
name = 'Scala' name = 'Scala'
extensions = ['.scala'] extensions = ['.scala']
tabwidth = 2
tabbercls = ScalaTabber
grammar = ScalaGrammar grammar = ScalaGrammar
commentc = '--' commentc = '//'
opentokens = ('delimiter',) opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'} opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',) closetokens = ('delimiter',)
@ -75,9 +89,9 @@ class Scala(Fundamental):
} }
_bindings = { _bindings = {
'close-paren': (')',), 'close-paren': (')',),
'close-brace': ('}',), 'close-brace': ('}',),
'close-bracket': (']',), 'close-bracket': (']',),
} }
def install(*args): def install(*args):