branch : pmacs2
This commit is contained in:
moculus 2007-08-05 14:25:49 +00:00
parent 435bd37405
commit 57056968da
3 changed files with 10 additions and 7 deletions

View File

@ -145,6 +145,7 @@ class Application(object):
'.rst': 'rst', '.rst': 'rst',
'.java': 'java', '.java': 'java',
'.el': 'elisp', '.el': 'elisp',
'.scm': 'scheme',
} }
self.mode_detection = { self.mode_detection = {
'python': 'python', 'python': 'python',

View File

@ -12,13 +12,13 @@ class StringGrammar(Grammar):
class SchemeGrammar(Grammar): class SchemeGrammar(Grammar):
rules = [ rules = [
PatternRule(r'comment', r';.*$'), PatternRule(r'comment', r';.*$'),
PatternRule(r'delimiter', r'\(|\)'), PatternRule(r'delimiter', r'[()]'),
RegionRule(r'string', r'"', StringGrammar, r'"'), RegionRule(r'string', r'"', StringGrammar, r'"'),
PatternRule(r'spaces', r' +'), PatternRule(r'spaces', r' +'),
PatternRule(r'eol', r'\n'), PatternRule(r'eol', r'\n'),
PatternRule(r'abbrev', r"'|`|,\@|,"), PatternRule(r'abbrev', r"'|`|,\@|,"),
PatternRule(r'keyword', r'define-syntax|define-macro|syntax-rules'), PatternRule(r'keyword', r'define-syntax|define-macro|syntax-rules|let-syntax|letrec-syntax'),
PatternRule(r'keyword', r'quote|lambda|if|set\!|begin|cond|and|or|case|let\*|letrec|let|do|delay|quasiquote|else|=>|define|unquote-splicing|unquote|loop'), PatternRule(r'keyword', r'quote|lambda|if|set\!|begin|cond|and|or|case|let\*|letrec|let|do|delay|quasiquote|else|=>|define|unquote-splicing|unquote|loop'),
# builtin predicates, mutators, and general procedures # builtin predicates, mutators, and general procedures
@ -36,15 +36,19 @@ class SchemeGrammar(Grammar):
] ]
class SchemeTabber(tab2.StackTabber): class SchemeTabber(tab2.StackTabber):
pass def _handle_open_token(self, currlvl, y, i):
level = self.get_curr_level() + 4
token = self.get_token(y, i)
self._append(token.string, level)
return currlvl
class Scheme(mode2.Fundamental): class Scheme(mode2.Fundamental):
tabbercls = SchemeTabber tabbercls = SchemeTabber
grammar = SchemeGrammar grammar = SchemeGrammar
opentokens = ('delimiter',) opentokens = ('delimiter',)
opentags = {'(': ')',}, opentags = {'(': ')'}
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(',}, closetags = {')': '('}
colors = { colors = {
'comment': ('red', 'default'), 'comment': ('red', 'default'),

View File

@ -169,8 +169,6 @@ class StackTabber(Tabber):
self._pop() self._pop()
if self.is_leftmost_token(y, i): if self.is_leftmost_token(y, i):
currlvl = self.get_curr_level() currlvl = self.get_curr_level()
#else:
# raise Exception, "hmmmm: %r" % self.get_next_left_token(y, i)
else: else:
raise Exception, "mismatched closing tag %r vs %r" % (s2, s1) raise Exception, "mismatched closing tag %r vs %r" % (s2, s1)
return currlvl return currlvl