2007-08-03 18:19:16 -04:00
|
|
|
import commands, os.path, sets, string, sys, traceback
|
|
|
|
import color, completer, default, mode2, method, regex, tab2
|
|
|
|
from point2 import Point
|
|
|
|
from lex3 import Grammar, PatternRule, RegionRule, OverridePatternRule
|
2007-08-06 11:36:49 -04:00
|
|
|
from mode.python import StringGrammar
|
2007-08-03 18:19:16 -04:00
|
|
|
|
|
|
|
class LispGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(r'comment', r';.*$'),
|
2007-08-06 11:36:49 -04:00
|
|
|
PatternRule(r'delimiter', r'[()]'),
|
2007-08-03 18:19:16 -04:00
|
|
|
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
2007-08-06 11:36:49 -04:00
|
|
|
PatternRule(r'spaces', r' +'),
|
|
|
|
PatternRule(r'eol', r'\n'),
|
2007-08-03 18:19:16 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class LispTabber(tab2.StackTabber):
|
2007-08-06 11:36:49 -04:00
|
|
|
def _handle_open_token(self, currlvl, y, i):
|
|
|
|
level = self.get_curr_level() + 4
|
|
|
|
self._append(self.get_token(y, i).string, level)
|
|
|
|
return currlvl
|
2007-08-03 18:19:16 -04:00
|
|
|
|
|
|
|
class Lisp(mode2.Fundamental):
|
|
|
|
tabbercls = LispTabber
|
|
|
|
grammar = LispGrammar
|
|
|
|
opentokens = ('delimiter',)
|
2007-08-06 11:36:49 -04:00
|
|
|
opentags = {'(': ')'}
|
2007-08-03 18:19:16 -04:00
|
|
|
closetokens = ('delimiter',)
|
2007-08-06 11:36:49 -04:00
|
|
|
closetags = {')': '('}
|
2007-08-03 18:19:16 -04:00
|
|
|
colors = {
|
2007-08-06 11:36:49 -04:00
|
|
|
'comment': ('red', 'default'),
|
2007-08-03 18:19:16 -04:00
|
|
|
'string.start': ('green', 'default'),
|
|
|
|
'string.null': ('green', 'default'),
|
|
|
|
'string.octal': ('magenta', 'default'),
|
|
|
|
'string.escaped': ('magenta', 'default'),
|
|
|
|
'string.end': ('green', 'default'),
|
|
|
|
}
|
|
|
|
def __init__(self, w):
|
|
|
|
mode2.Fundamental.__init__(self, w)
|
|
|
|
self.add_bindings('close-paren', (')',))
|
|
|
|
self.add_bindings('close-brace', ('}',))
|
|
|
|
self.add_bindings('close-bracket', (']',))
|
|
|
|
def name(self):
|
|
|
|
return "Lisp"
|