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 from mode.python import StringGrammar class LispGrammar(Grammar): rules = [ PatternRule(r'comment', r';.*$'), PatternRule(r'delimiter', r'[()]'), RegionRule(r'string', r'"', StringGrammar, r'"'), PatternRule(r'spaces', r' +'), PatternRule(r'eol', r'\n'), ] class LispTabber(tab2.StackTabber): 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 class Lisp(mode2.Fundamental): tabbercls = LispTabber grammar = LispGrammar opentokens = ('delimiter',) opentags = {'(': ')'} closetokens = ('delimiter',) closetags = {')': '('} colors = { 'comment': ('red', 'default'), '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"