lexing improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-03-16 05:23:14 +00:00
parent 6bcf147a8e
commit bc65acb16d
28 changed files with 347 additions and 325 deletions

View File

@ -48,6 +48,8 @@ class Application(object):
self.error_string = ""
self.error_timestamp = None
self.input = keyinput.Handler()
self.token_colors = {}
self.default_color = ('default', 'default',)
# initialize our colors
if curses.has_colors():

View File

@ -10,6 +10,7 @@ sub foo {
#@@:heredoc:mode.sql.Sql
my $s = <<EOT;
drop table foog;
insert into mytable (col1, col2, "col3") values (99, 33, 1234);
select cast(plunk as timestamp) from blarg join plarg using(id_what) where x = 3;
EOT
@ -23,8 +24,8 @@ EOT
# wejgiwe jgiweg jweigewgj we gwee e e e ee e
my $foo = {
#@@:string:mode.sql.Sql
'drop table ',
#@@:perl_string:mode.sql.Sql
'drop table foogy;',
'bar',
};

View File

@ -0,0 +1,12 @@
def do_junk(*args):
#@@:string:sql
s = "select * from foo where bar = 99;"
s = "select * from foo where bar = 99;"
#@@:string:xml
s = "<foo blah='3'>bar</foo>"
s = "<foo blah='3'>bar</foo>"
#@@:string:python
s = "lambda x, y: 'result: %d' % x + y"
s = "lambda x, y: 'result: %d' % x + y"

20
lex.py
View File

@ -99,6 +99,9 @@ class PatternRule(Rule):
class NocasePatternRule(PatternRule):
reflags = re.IGNORECASE
class FakeWindow(object):
def __init__(self, app):
self.application = app
class OverrideError(Exception):
pass
class OverridePatternRule(PatternRule):
@ -108,11 +111,8 @@ class OverridePatternRule(PatternRule):
if lexer.action == 'lex':
a = lexer.mode.window.application
try:
names = d['mode'].split('.')
modecls = a.globals()[names.pop(0)]
for name in names:
modecls = getattr(modecls, name)
mode = modecls(None)
modecls = a.modes[d['mode']]
mode = modecls(FakeWindow(lexer.mode.window.application))
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
lexer.mode.gstack['%s.start' % d['token']] = mode
else:
@ -442,14 +442,14 @@ class Lexer(object):
mode = self.mstack[-1]
else:
mode = self.mode
v = list(mode.default_color)
app = mode.window.application
v = list(app.default_color)
for j in range(0, len(fqlist)):
name = '.'.join(fqlist[j:])
if name in mode.colors:
assert type(mode.colors[name]) == type(()), repr(mode)
v = list(mode.colors[name])
if name in app.token_colors:
assert type(app.token_colors[name]) == type(()), repr(mode)
v = list(app.token_colors[name])
break
#if DARK_BACKGROUND:
if True:
v.append('bold')
return v

View File

@ -1598,7 +1598,7 @@ class GetToken(Method):
if token is None:
w.set_error('No Token')
else:
w.set_error('Token: %r' % token.string)
w.set_error('Token: %r (%s)' % (token.string, token.fqname()))
class RegisterSave(Method):
MAX_TXT = 30

View File

@ -85,20 +85,25 @@ class Fundamental(Handler):
grammar = None
lexer = None
tabber = None
default_color = ('default', 'default',)
colors = {}
#default_color = ('default', 'default',)
def install(cls, app):
app.setmode(cls.modename.lower(), cls, paths=cls.paths,
basenames=cls.basenames, extensions=cls.extensions,
detection=cls.detection)
for (key, val) in cls.colors.iteritems():
#key2 = '%s.%s' % (cls.modename, key)
#app.token_colors[key2] = val
if key in app.token_colors:
raise Exception, '%r conflict from %r' % (key, cls.modename)
else:
app.token_colors[key] = val
install = classmethod(install)
def __init__(self, w):
assert w is not None
self.window = w
# we need to defer this due to curses startup
#self.default_color = color.pairs('default', 'default')
Handler.__init__(self)
# first let's add all the "default" actions
@ -183,6 +188,7 @@ class Fundamental(Handler):
self.add_bindings('insert-dquotes', ('M-"',))
self.add_bindings('insert-escaped-squote', ('C-c M-\'',))
self.add_bindings('insert-escaped-dquote', ('C-c M-"',))
self.add_bindings('get-token', ('C-c t',))
# unbound actions
self.add_action(method.GetToken())

View File

@ -18,7 +18,7 @@ class TemplateGrammar(Grammar):
PatternRule(r'comment', r'##.*\n'),
PatternRule(r'placeholder', r'\$[a-zA-Z0-9_]+'),
PatternRule(r'directive', r'#.*?[#\n]'),
RegionRule(r'tag', r'</?', TagGrammar, r'/?>'),
RegionRule(r'cheetah_tag', r'</?', TagGrammar, r'/?>'),
]
class Template(mode.Fundamental):
@ -26,22 +26,22 @@ class Template(mode.Fundamental):
extensions = ['.tmpl']
grammar = TemplateGrammar
colors = {
'comment': ('red', 'default'),
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
#'comment': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'directive': ('magenta', 'default'),
'placeholder': ('magenta', 'default'),
'tag.start': ('default', 'default'),
'tag.namespace': ('magenta', 'default'),
'tag.name': ('blue', 'default'),
'tag.attrname': ('cyan', 'default'),
'tag.string.start': ('green', 'default'),
'tag.string.null': ('green', 'default'),
'tag.string.end': ('green', 'default'),
'tag.end': ('default', 'default'),
'cheetah_tag.start': ('default', 'default'),
'cheetah_tag.namespace': ('magenta', 'default'),
'cheetah_tag.name': ('blue', 'default'),
'cheetah_tag.attrname': ('cyan', 'default'),
'cheetah_tag.string.start': ('green', 'default'),
'cheetah_tag.string.null': ('green', 'default'),
'cheetah_tag.string.end': ('green', 'default'),
'cheetah_tag.end': ('default', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -9,8 +9,8 @@ class ConsoleGrammar(Grammar):
PatternRule(r'input', r'^-->.*$'),
#PatternRule(r'output', r'^ .*$'),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
RegionRule(r'py_string', r'"', StringGrammar, r'"'),
RegionRule(r'py_string', r"'", StringGrammar, r"'"),
PatternRule(r'bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
]
class Console(mode.Fundamental):
@ -21,11 +21,11 @@ class Console(mode.Fundamental):
'input': ('cyan', 'default'),
'output': ('default', 'default'),
'string.start': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
'py_string.start': ('green', 'default'),
'py_string.octal': ('magenta', 'default'),
'py_string.escaped': ('magenta', 'default'),
'py_string.null': ('green', 'default'),
'py_string.end': ('green', 'default'),
}
install = Console.install

View File

@ -29,10 +29,10 @@ class CSSGrammar(Grammar):
NocasePatternRule(r'rule', r'@(?:page|media|import)'),
NocasePatternRule(r'color', r'(?:aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|#[0-9]{6}|#[0-9]{3})'),
NocasePatternRule(r'keyword', r'(?:url|rgb|counter)'),
NocaseRegionRule(r'keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'),
NocasePatternRule(r'css_keyword', r'(?:url|rgb|counter)'),
NocaseRegionRule(r'css_keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'),
NocasePatternRule(r'label', r"\.?[-a-zA-Z0-9_]+(?= *{)"),
NocasePatternRule(r'css_label', r"\.?[-a-zA-Z0-9_]+(?= *{)"),
NocasePatternRule(r'ident', r"-?[a-z_][-a-z0-9_]*"),
NocasePatternRule(r'name', r"[-a-z0-9_]+"),
@ -50,10 +50,10 @@ class CSS(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'comment': ('red', 'default'),
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
#'comment': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'htmlcomment': ('red', 'default'),
'htmlcomment.start': ('red', 'default'),
@ -68,27 +68,27 @@ class CSS(mode.Fundamental):
'color': ('magenta', 'default'),
'hash': ('cyan', 'default'),
'label': ('cyan', 'default'),
'css_label': ('cyan', 'default'),
'rule': ('cyan', 'default'),
'keyword': ('cyan', 'default'),
'css_keyword': ('cyan', 'default'),
'ident': ('default', 'default'),
'name': ('default', 'default'),
'delimiter': ('default', 'default'),
'keyword': ('cyan', 'default'),
'keyword.start': ('default', 'default'),
'keyword.null': ('cyan', 'default'),
'keyword.octal': ('magenta', 'default'),
'keyword.escaped': ('magenta', 'default'),
'keyword.end': ('default', 'default'),
'css_keyword': ('cyan', 'default'),
'css_keyword.start': ('default', 'default'),
'css_keyword.null': ('cyan', 'default'),
'css_keyword.octal': ('magenta', 'default'),
'css_keyword.escaped': ('magenta', 'default'),
'css_keyword.end': ('default', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.end': ('green', '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):
mode.Fundamental.__init__(self, w)

View File

@ -13,7 +13,7 @@ class ELispGrammar(Grammar):
rules = [
PatternRule(r'comment', r';.*$'),
PatternRule(r'reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
PatternRule(r'keyword', r'(?:while|when|unless|setq|require|or|not|mapcar|list|let|lambda|if|exists|equal|defvar|defun|defalias|count|cons|cdr|car|apply|and)(?![a-zA-Z0-9_])'),
PatternRule(r'elisp_keyword', r'(?:while|when|unless|setq|require|or|not|mapcar|list|let|lambda|if|exists|equal|defvar|defun|defalias|count|cons|cdr|car|apply|and)(?![a-zA-Z0-9_])'),
PatternRule(r'symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
PatternRule(r'type', r":[a-zA-Z_][a-zA-Z0-9-_]*"),
PatternRule(r'attribute', r"&[a-zA-Z_][a-zA-Z0-9-_]*"),
@ -39,20 +39,20 @@ class ELisp(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'keyword': ('cyan', 'default'),
'elisp_keyword': ('cyan', 'default'),
'reserved': ('blue', 'default'),
'symbol': ('magenta', 'default'),
'type': ('blue', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.format': ('yellow', 'default'),
'string.end': ('green', 'default'),
'integer': ('default', 'default'),
'float': ('default', 'default'),
'imaginary': ('default', 'default'),
'comment': ('red', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.format': ('yellow', 'default'),
#'string.end': ('green', 'default'),
#'integer': ('default', 'default'),
#'float': ('default', 'default'),
#'imaginary': ('default', 'default'),
#'comment': ('red', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -19,9 +19,9 @@ class HTML(mode.Fundamental):
extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml']
grammar = HTMLGrammar
colors = {
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'script.start': ('default', 'default'),
'script.namespace': ('magenta', 'default'),
@ -41,7 +41,7 @@ class HTML(mode.Fundamental):
'tag.string.end': ('green', 'default'),
'tag.end': ('default', 'default'),
}
colors.update(Javascript.colors)
#colors.update(Javascript.colors)
def __init__(self, w):
mode.Fundamental.__init__(self, w)
self.add_bindings('close-paren', (')',))

View File

@ -13,19 +13,19 @@ class JavaGrammar(Grammar):
PatternRule(r'comment', r'//.*$'),
PatternRule(r'keyword', r"(?:abstract|assert|boolean|break|byte|case|catch|char|class|continue|default|double|do|else|extends|finally|final|float|for|if|implements|import|instanceof|interface|int|long|native|new|package|private|protected|public|return|short|static|switch|super|synchronized|threadsafe|throws|throw|transient|try|void|while)(?![a-zA-Z_])"),
PatternRule(r'label', r'[a-zA-Z_][a-zA-Z0-9_]*(?=:)'),
PatternRule(r'java_label', r'[a-zA-Z_][a-zA-Z0-9_]*(?=:)'),
PatternRule(r'builtin', r"(?:null|true|false|this)"),
PatternRule(r'java_builtin', r"(?:null|true|false|this)"),
PatternRule(r'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r"unop", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
PatternRule(r'binop', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
PatternRule(r"delimiter", r"->|\.|\(|\)|\[|\]|{|}|@|,|:|`|;|=|\?"),
PatternRule(r"integer", r"(?:0(?![x0-9])|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
PatternRule(r"float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
PatternRule(r"java_integer", r"(?:0(?![x0-9])|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
PatternRule(r"java_float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
RegionRule(r'string', '"', StringGrammar, '"'),
PatternRule(r'char', r"'.'|'\\.'|'\\[0-7]{3}'"),
PatternRule(r'java_char', r"'.'|'\\.'|'\\[0-7]{3}'"),
PatternRule(r"eol", r"\n$"),
]
@ -163,29 +163,29 @@ class Java(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'comment': ('red', 'default'),
'comment.start': ('red', 'default'),
'comment.end': ('red', 'default'),
'comment.null': ('red', 'default'),
#'comment': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.end': ('red', 'default'),
#'comment.null': ('red', 'default'),
'doccomment.start': ('red', 'default'),
'doccomment.end': ('red', 'default'),
'doccomment.null': ('red', 'default'),
'import': ('blue', 'default'),
'label': ('magenta', 'default'),
'keyword': ('cyan', 'default'),
'function': ('blue', 'default'),
'builtin': ('magenta', 'default'),
'java_label': ('magenta', 'default'),
#'keyword': ('cyan', 'default'),
#'function': ('blue', 'default'),
'java_builtin': ('magenta', 'default'),
'char': ('green', 'default'),
'string.start': ('green', 'default'),
'string.octal': ('green', 'default'),
'string.escaped': ('green', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
'integer': ('green', 'default'),
'float': ('green', 'default'),
'java_char': ('green', 'default'),
#'string.start': ('green', 'default'),
#'string.octal': ('green', 'default'),
#'string.escaped': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.end': ('green', 'default'),
'java_integer': ('green', 'default'),
'java_float': ('green', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -8,12 +8,12 @@ class JavascriptGrammar(Grammar):
PatternRule(r'comment', r'//.*$'),
RegionRule(r'comment', '/\*', Grammar, '\*/'),
PatternRule(r'continuation', r'\\(?= *$)'),
PatternRule(r'function', r"(?<=function )[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r'js_function', r"(?<=function )[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r'class', r"(?<=class )[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r'reserved', r'(?:as|break|case|catch|class|const|continue|default|delete|do|else|export|extends|false|finally|for|function|if|import|in|instanceof|is|namespace|new|null|package|private|public|return|super|switch|this|throw|true|try|typeof|use|var|void|while|with)(?![a-zA-Z0-9_])'),
PatternRule(r'reserved', r'(?:abstract|debugger|enum|goto|implements|interface|native|protected|synchronized|throws|transient|volatile)(?![a-zA-Z0-9_])'),
PatternRule(r'nonreserved', r'(?:get|include|set)(?![a-zA-Z0-9_])'),
PatternRule(r'js_reserved', r'(?:as|break|case|catch|class|const|continue|default|delete|do|else|export|extends|false|finally|for|function|if|import|in|instanceof|is|namespace|new|null|package|private|public|return|super|switch|this|throw|true|try|typeof|use|var|void|while|with)(?![a-zA-Z0-9_])'),
PatternRule(r'js_reserved', r'(?:abstract|debugger|enum|goto|implements|interface|native|protected|synchronized|throws|transient|volatile)(?![a-zA-Z0-9_])'),
PatternRule(r'js_nonreserved', r'(?:get|include|set)(?![a-zA-Z0-9_])'),
PatternRule(r"method", r"(?<=\.)[a-zA-Z_][a-zA-Z0-9_]*(?= *\()"),
PatternRule(r'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
@ -29,7 +29,7 @@ class JavascriptGrammar(Grammar):
PatternRule(r'delimiter', r'%=|&&=|&=|\(|\)|\*=|\+=|,|-=|\.{3}|\.|/=(?= |$)|::|:|;|<<=|>>=|>>>=|\?|\[|\]|^=|^^=|\{|\}|\|=|\|\|='),
PatternRule(r'operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/(?= |$)|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\'),
RegionRule('regex', "/", StringGrammar, "/"),
RegionRule('js_regex', "/", StringGrammar, "/"),
RegionRule('string', "'", StringGrammar, "'"),
RegionRule('string', '"', StringGrammar, '"'),
]
@ -62,33 +62,33 @@ class Javascript(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'comment': ('red', 'default'),
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
#'comment': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'continuation': ('red', 'default'),
'function': ('blue', 'default'),
'js_function': ('blue', 'default'),
'class': ('green', 'default'),
'reserved': ('cyan', 'default'),
'nonreserved': ('cyan', 'default'),
'js_reserved': ('cyan', 'default'),
'js_nonreserved': ('cyan', 'default'),
'delimiter': ('default', 'default'),
'operator': ('default', 'default'),
'integer': ('default', 'default'),
'float': ('default', 'default'),
#'delimiter': ('default', 'default'),
#'operator': ('default', 'default'),
#'integer': ('default', 'default'),
#'float': ('default', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.end': ('green', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.end': ('green', 'default'),
'regex.start': ('cyan', 'default'),
'regex.null': ('cyan', 'default'),
'regex.octal': ('magenta', 'default'),
'regex.escaped': ('magenta', 'default'),
'regex.end': ('cyan', 'default'),
'js_regex.start': ('cyan', 'default'),
'js_regex.null': ('cyan', 'default'),
'js_regex.octal': ('magenta', 'default'),
'js_regex.escaped': ('magenta', 'default'),
'js_regex.end': ('cyan', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -40,12 +40,12 @@ class Lisp(mode.Fundamental):
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'),
#'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):
mode.Fundamental.__init__(self, w)

View File

@ -21,10 +21,10 @@ class MakeGrammar(Grammar):
#RegionRule(r'targets', r'^[^:= ]+ *:', Grammar, r';|\n', ShGrammar, r'\n'),
RegionRule(r'actions', r'^ ', ShGrammar, r'\n'),
PatternRule(r'variable', r'\$\([a-zA-Z0-9_]+\)'),
PatternRule(r'variable', r'\${[a-zA-Z0-9_]+}'),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
PatternRule(r'make_variable', r'\$\([a-zA-Z0-9_]+\)'),
PatternRule(r'make_variable', r'\${[a-zA-Z0-9_]+}'),
RegionRule(r'make_string', r'"', StringGrammar, r'"'),
RegionRule(r'make_string', r"'", StringGrammar, r"'"),
]
class Make(mode.Fundamental):
@ -33,22 +33,22 @@ class Make(mode.Fundamental):
grammar = MakeGrammar
savetabs = True
colors = {
'comment': ('red', 'default'),
'continuation': ('red', 'default'),
#'comment': ('red', 'default'),
#'continuation': ('red', 'default'),
'targets.start': ('cyan', 'default'),
'assignment.start': ('yellow', 'default'),
#'targets': ('cyan', 'default'),
#'assignment': ('yellow', 'default'),
'variable': ('yellow', 'default'),
'make_variable': ('yellow', 'default'),
'string.start': ('green', 'default'),
'string.variable': ('yellow', 'default'),
'string.escaped': ('magenta', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
'make_string.start': ('green', 'default'),
'make_string.variable': ('yellow', 'default'),
'make_string.escaped': ('magenta', 'default'),
'make_string.null': ('green', 'default'),
'make_string.end': ('green', 'default'),
}
colors.update(Sh.colors)
#colors.update(Sh.colors)
install = Make.install

View File

@ -5,7 +5,7 @@ from lex import Grammar, PatternRule
class MuttGrammar(Grammar):
rules = [
PatternRule(name=r'header', pattern=r'^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'),
PatternRule(name=r'mutt_header', pattern=r'^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'),
PatternRule(name=r'quoteb', pattern=r'^ *(?:(?: *>){3})*(?: *>){2}.*$'),
PatternRule(name=r'quotea', pattern=r'^ *(?:(?: *>){3})*(?: *>){1}.*$'),
PatternRule(name=r'quotec', pattern=r'^ *(?:(?: *>){3})*(?: *>){3}.*$'),
@ -21,7 +21,7 @@ class Mutt(mode.Fundamental):
modename = 'Mutt'
grammar = MuttGrammar()
colors = {
'header': ('green', 'default', 'bold'),
'mutt_header': ('green', 'default', 'bold'),
'email': ('cyan', 'default', 'bold'),
'url': ('cyan', 'default', 'bold'),
'quotea': ('yellow', 'default', 'bold'),

View File

@ -9,12 +9,12 @@ class StringGrammar(Grammar):
class NasmGrammar(Grammar):
rules = [
PatternRule(r'keyword', r"(?:section|global|extern)(?![a-zA-Z_])"),
PatternRule(r'nasm_keyword', r"(?:section|global|extern)(?![a-zA-Z_])"),
PatternRule(r'macros', r"%(?:define|undef|assign|strlen|macro|endmacro|if|elif|else|endif|ifdef|ifndef|include|push|pop|stacksize)(?![a-zA-Z_])"),
PatternRule(r'instructions', r"(?:jeq|jne|ja|jmp|push|pushad|pushfd|call|ret|sub|add|pop|popa|popad|popfd|call|and|cwd|cdq|cmp|cmpxchg|cpuid|div|divpd|enter|leave|fadd|fld|fmul|fsqrt|fsub|hlt|imul|inc|int|int3|lea|mov|movd|mul|neg|not|nop|or|sal|sar|shl|shr|shld|shrd|syscall|sysenter|sysexit|test|xchg|xadd|xor)(?![a-zA-Z_])"),
PatternRule(r'registers', r"(?:eax|ax|ah|al|ebx|bx|bh|bl|ecx|cx|ch|cl|esi|edi|esp|ebp)(?![a-zA-Z_])"),
PatternRule(r'prefix', r"(?:dword|word|lock)(?![a-zA-Z_])"),
PatternRule(r'label', r"[a-zA-Z_.][a-zA-Z0-9_.]*:"),
PatternRule(r'nasm_label', r"[a-zA-Z_.][a-zA-Z0-9_.]*:"),
PatternRule(r"identifier", r"[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r"integer", r"(0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
PatternRule(r"float", r"[0-9]+\.[0-9]*|\.[0-9]+|([0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
@ -31,15 +31,15 @@ class Nasm(mode.Fundamental):
extensions = ['.s']
grammar = NasmGrammar
colors = {
'keyword': ('cyan', 'default', 'bold'),
'nasm_keyword': ('cyan', 'default', 'bold'),
'macros': ('blue', 'default', 'bold'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
'comment': ('red', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.end': ('green', 'default'),
#'comment': ('red', 'default'),
'registers': ('yellow', 'default'),
'instructions': ('magenta', 'default'),
'label': ('blue', 'default'),
'nasm_label': ('blue', 'default'),
}
install = Nasm.install

View File

@ -25,7 +25,7 @@ class OcamlGrammar(Grammar):
PatternRule(r'delimiter', r"[()]"),
PatternRule(r'keyword', r"(?:with|while|when|virtual|val|type|try|true|to|then|struct|sig|rec|private|parser|or|open|of|object|new|mutable|module|mod|method|match|lxor|lsr|lsl|lor|let|lazy|land|initializer|inherti|include|in|if|functor|function|fun|for|false|external|exception|end|else|downto|done|do|constraint|class|begin|asr|assert|as|and)(?!['a-zA-Z0-9_])"),
PatternRule(r'ocaml_keyword', r"(?:with|while|when|virtual|val|type|try|true|to|then|struct|sig|rec|private|parser|or|open|of|object|new|mutable|module|mod|method|match|lxor|lsr|lsl|lor|let|lazy|land|initializer|inherti|include|in|if|functor|function|fun|for|false|external|exception|end|else|downto|done|do|constraint|class|begin|asr|assert|as|and)(?!['a-zA-Z0-9_])"),
PatternRule(r'builtin', r"(?:int|char|string|float|bool|false|true|unit|exn|array|list|option|int32|int64|nativeint|format4|lazy_t)(?!['a-zA-Z0-9_])"),
PatternRule(r'builtin_exception', r"(?:Match_failure|Assert_failure|Invalid_argument|Failure|Not_found|Out_of_memory|Stack_overflow|Sys_error|End_of_file|Division_by_zero|Sys_blocked_io|Undefined_recursive_module|Exit)(?!['a-zA-Z0-9_])"),
@ -45,7 +45,7 @@ class OcamlGrammar(Grammar):
PatternRule(r'char', r"'\\[0-9]{3}'"),
PatternRule(r'char', r"'\\x[0-9A-Fa-f]{2}'"),
RegionRule(r'string', r'"', StringGrammar, '"'),
RegionRule(r'ocaml_string', r'"', StringGrammar, '"'),
PatternRule(r'label', r"~[a-z_]['a-zA-Z0-9_]*:"),
PatternRule(r'optlabel', r"\?[a-z_]['a-zA-Z0-9_]*:"),
@ -63,29 +63,29 @@ class Ocaml(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '('}
colors = {
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'linenum': ('red', 'default'),
'keyword': ('cyan', 'default'),
'ocaml_keyword': ('cyan', 'default'),
#'builtin': ('magenta', 'default'),
#'builtin_exception': ('magenta', 'default'),
#'builtin_function': ('magenta', 'default'),
'label': ('blue', 'default'),
'ocaml_label': ('blue', 'default'),
'optlabel': ('blue', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.hex': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.end': ('green', 'default'),
'char': ('green', 'default'),
'integer': ('default', 'default'),
'float': ('default', 'default'),
'ocaml_string.start': ('green', 'default'),
'ocaml_string.null': ('green', 'default'),
'ocaml_string.octal': ('magenta', 'default'),
'ocaml_string.hex': ('magenta', 'default'),
'ocaml_string.escaped': ('magenta', 'default'),
'ocaml_string.end': ('green', 'default'),
#'char': ('green', 'default'),
#'integer': ('default', 'default'),
#'float': ('default', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -59,21 +59,21 @@ class PerlGrammar(Grammar):
PatternGroupRule(r'prototype', r'delimiter', r'\(', r'prototype', r'[\[\]\\@$%&*;]+', r'delimiter', '\)'),
PatternRule(r'comment', r'#.*$'),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", Grammar, r"'"),
RegionRule(r'perl_string', r'"', StringGrammar, r'"'),
RegionRule(r'perl_string', r"'", Grammar, r"'"),
RegionRule(r'evalstring', r"`", StringGrammar, r"`"),
PatternRule(r'number', r'0?\.[0-9]+|[0-9]+(?:\.[0-9]+)?'),
PatternRule(r'keyword', r"(?<!->)(?:STDIN|STDERR|STDOUT|continue|do|else|elsif|eval|foreach|for|if|last|my|next|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
PatternRule(r'perl_keyword', r"(?<!->)(?:STDIN|STDERR|STDOUT|continue|do|else|elsif|eval|foreach|for|if|last|my|next|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
PatternRule(r'hash_key', r'(?<={)[A-Za-z0-9_]+(?=})'),
PatternRule(r'hash_key', r'[A-Za-z0-9_]+(?= *=>)'),
PatternRule(r'length', r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),
PatternRule(r'cast', r'[\$\@\%\^\&](?= *{)'),
PatternRule(r'scalar', r"\$[\[\]<>ab/'\"_@\?#\$!%^|&*()](?![A-Za-z0-9_])"),
PatternRule(r'array', r"@_"),
PatternRule(r'function', r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?=-> *\()"),
PatternRule(r'perl_function', r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?=-> *\()"),
PatternRule(r'scalar', r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),
PatternRule(r'array', r"@\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*"),
PatternRule(r'hash', r"%\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*"),
PatternRule(r'perl_hash', r"%\$*[A-Za-z_](?:[A-Za-z0-9_]|::)*"),
PatternRule(r'deref', r"[@%\$&\*](?={)"),
# match regexes
@ -94,10 +94,10 @@ class PerlGrammar(Grammar):
PatternRule(r'sub', r"(?<=sub )[a-zA-Z_][a-zA-Z_0-9]*"),
PatternRule(r'use', r"(?<=use )(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*"),
PatternRule(r'require', r"(?<=require )(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*"),
PatternRule(r'label', r'[a-zA-Z_][a-zA-Z0-9_]*:(?!:)'),
PatternRule(r'perl_label', r'[a-zA-Z_][a-zA-Z0-9_]*:(?!:)'),
PatternRule(r'method', r"(?<=->)[a-zA-Z_][a-zA-Z_0-9]*"),
PatternRule(r'function', r"&\$*(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*"),
PatternRule(r'builtin', r"(?<!->)&?(?:write|warn|wantarray|waitpid|wait|vec|values|utime|use|untie|unshift|unpack|unlink|undef|umask|ucfirst|uc|truncate|times|time|tied|tie|telldir|tell|syswrite|system|sysseek|sysread|sysopen|syscall|symlink|substr|sub|study|stat|srand|sqrt|sprintf|split|splice|sort|socketpair|socket|sleep|sin|shutdown|shmwrite|shmread|shmget|shmctl|shift|setsockopt|setservent|setpwent|setprotoent|setpriority|setpgrp|setnetent|sethostent|setgrent|send|semop|semget|semctl|select|seekdir|seek|scalar|rmdir|rindex|rewinddir|reverse|return|reset|require|rename|ref|redo|recv|readpipe|readlink|readline|readdir|read|rand|quotemeta|push|prototype|printf|print|pos|pop|pipe|package|pack|our|ord|opendir|open|oct|no|next|my|msgsnd|msgrcv|msgget|msgctl|mkdir|map|lstat|log|lock|localtime|local|listen|link|length|lcfirst|lc|last|kill|keys|join|ioctl|int|index|import|hex|grep|goto|gmtime|glob|getsockopt|getsockname|getservent|getservbyport|getservbyname|getpwuid|getpwnam|getpwent|getprotoent|getprotobynumber|getprotobyname|getpriority|getppid|getpgrp|getpeername|getnetent|getnetbyname|getnetbyaddr|getlogin|gethostent|gethostbyname|gethostbyaddr|getgrnam|getgrgid|getgrent|getc|formline|format|fork|flock|fileno|fcntl|exp|exit|exists|exec|eval|eof|endservent|endpwent|endprotoent|endnetent|endhostent|endgrent|each|dump|do|die|delete|defined|dbmopen|dbmclose|crypt|cos|continue|connect|closedir|close|chroot|chr|chown|chop|chomp|chmod|chdir|caller|bless|binmode|bind|atan2|alarm|accept|abs)(?![a-zA-Z0-9_])"),
PatternRule(r'perl_function', r"&\$*(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*"),
PatternRule(r'perl_builtin', r"(?<!->)&?(?:write|warn|wantarray|waitpid|wait|vec|values|utime|use|untie|unshift|unpack|unlink|undef|umask|ucfirst|uc|truncate|times|time|tied|tie|telldir|tell|syswrite|system|sysseek|sysread|sysopen|syscall|symlink|substr|sub|study|stat|srand|sqrt|sprintf|split|splice|sort|socketpair|socket|sleep|sin|shutdown|shmwrite|shmread|shmget|shmctl|shift|setsockopt|setservent|setpwent|setprotoent|setpriority|setpgrp|setnetent|sethostent|setgrent|send|semop|semget|semctl|select|seekdir|seek|scalar|rmdir|rindex|rewinddir|reverse|return|reset|require|rename|ref|redo|recv|readpipe|readlink|readline|readdir|read|rand|quotemeta|push|prototype|printf|print|pos|pop|pipe|package|pack|our|ord|opendir|open|oct|no|next|my|msgsnd|msgrcv|msgget|msgctl|mkdir|map|lstat|log|lock|localtime|local|listen|link|length|lcfirst|lc|last|kill|keys|join|ioctl|int|index|import|hex|grep|goto|gmtime|glob|getsockopt|getsockname|getservent|getservbyport|getservbyname|getpwuid|getpwnam|getpwent|getprotoent|getprotobynumber|getprotobyname|getpriority|getppid|getpgrp|getpeername|getnetent|getnetbyname|getnetbyaddr|getlogin|gethostent|gethostbyname|gethostbyaddr|getgrnam|getgrgid|getgrent|getc|formline|format|fork|flock|fileno|fcntl|exp|exit|exists|exec|eval|eof|endservent|endpwent|endprotoent|endnetent|endhostent|endgrent|each|dump|do|die|delete|defined|dbmopen|dbmclose|crypt|cos|continue|connect|closedir|close|chroot|chr|chown|chop|chomp|chmod|chdir|caller|bless|binmode|bind|atan2|alarm|accept|abs)(?![a-zA-Z0-9_])"),
# quote operator: qq(), qx() and qr() usually interpolate
RegionRule(r'quoted', r'q[rqx] *(?P<delim>\()', QuotedGrammar1, r'\)'),
@ -116,8 +116,8 @@ class PerlGrammar(Grammar):
RegionRule(r'quoted', r'qw?#', Grammar, r'#'),
RegionRule(r'quoted', r'qw? *(?P<delim>[^ #])', Grammar, r'%(delim)s'),
PatternRule(r'function', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()"),
PatternRule(r'class', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?=->)"),
PatternRule(r'perl_function', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?= *\()"),
PatternRule(r'perl_class', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?=->)"),
# some basic stuff
PatternRule(r'delimiter', r"->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"),
@ -137,7 +137,7 @@ class PerlTabber(tab.StackTabber):
if not highlighter.tokens[y]:
return False
t = highlighter.tokens[y][0]
return t.name == 'keyword' and t.string == 'sub'
return t.name == 'perl_keyword' and t.string == 'sub'
def _handle_open_token(self, currlvl, y, i):
currlvl = tab.StackTabber._handle_open_token(self, currlvl, y, i)
return currlvl
@ -176,16 +176,16 @@ class PerlTabber(tab.StackTabber):
elif fqname == 'pod.end':
self._opt_pop('pod')
currlvl = 0
elif fqname == 'string.start':
elif fqname == 'perl_string.start':
self._opt_append('string', None)
elif fqname == 'string.end':
elif fqname == 'perl_string.end':
self._opt_pop('string')
if self.is_rightmost_token(y, i):
self._opt_append('cont', currlvl + 4)
if self.is_rightmost_token(y, i):
if(not fqname.startswith('pod') and
not fqname.startswith('heredoc') and
not fqname.startswith('string') and
not fqname.startswith('perl_string') and
not fqname.startswith('endblock') and
not fqname == 'eol' and
not fqname == 'comment' and
@ -206,7 +206,7 @@ class Perl(mode.Fundamental):
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
# comments
'comment': ('red', 'default'),
#'comment': ('red', 'default'),
'endblock.start': ('red', 'default'),
'endblock.null': ('red', 'default'),
'endblock.end': ('red', 'default'),
@ -222,27 +222,27 @@ class Perl(mode.Fundamental):
# basic stuff
'escaped': ('magenta', 'default'),
'null': ('default', 'default'),
'delimiter': ('default', 'default'),
#'delimiter': ('default', 'default'),
'sub': ('cyan', 'default'),
'prototype': ('magenta', 'default'),
'number': ('default', 'default'),
'operator': ('default', 'default'),
'noperator': ('magenta', 'default'),
'endblock': ('red', 'default'),
'keyword': ('magenta', 'default'),
'perl_keyword': ('magenta', 'default'),
'cast': ('yellow', 'default'),
'scalar': ('yellow', 'default'),
'array': ('yellow', 'default'),
'deref': ('yellow', 'default'),
'hash': ('yellow', 'default'),
'perl_hash': ('yellow', 'default'),
'hash_key': ('green', 'default'),
'function': ('cyan', 'default'),
'builtin': ('magenta', 'default'),
'perl_function': ('cyan', 'default'),
'perl_builtin': ('magenta', 'default'),
'method': ('cyan', 'default'),
'bareword': ('default', 'default'),
'label': ('cyan', 'default'),
'perl_label': ('cyan', 'default'),
'package': ('cyan', 'default'),
'class': ('cyan', 'default'),
'perl_class': ('cyan', 'default'),
'use': ('cyan', 'default'),
'require': ('cyan', 'default'),
'method': ('cyan', 'default'),
@ -256,11 +256,11 @@ class Perl(mode.Fundamental):
'evaldoc.end': ('cyan', 'default'),
# strings
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.escaped': ('magenta', 'default'),
'string.deref': ('yellow', 'default'),
'string.end': ('green', 'default'),
'perl_string.start': ('green', 'default'),
'perl_string.null': ('green', 'default'),
'perl_string.escaped': ('magenta', 'default'),
'perl_string.deref': ('yellow', 'default'),
'perl_string.end': ('green', 'default'),
# `` strings
'evalstring.start': ('cyan', 'default'),
@ -291,7 +291,7 @@ class Perl(mode.Fundamental):
'replace.deref': ('yellow', 'default'),
'replace.length': ('yellow', 'default'),
'replace.scalar': ('yellow', 'default'),
'replace.hash': ('yellow', 'default'),
'replace.perl_hash': ('yellow', 'default'),
'replace.cast': ('yellow', 'default'),
# translate regex

View File

@ -19,9 +19,9 @@ class PythonGrammar(Grammar):
rules = [
PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule(r'classname', r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
PatternRule(r'reserved', r'(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'),
PatternRule(r'keyword', r'(?:yield|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])'),
PatternRule(r"builtin", r'(?<!\.)(?:zip|xrange|vars|unicode|unichr|type|tuple|super|sum|str|staticmethod|sorted|slice|setattr|set|round|repr|reduce|raw_input|range|property|pow|ord|open|oct|object|max|min|map|long|locals|list|len|iter|issubclass|isinstance|int|input|id|hex|hash|hasattr|globals|getattr|frozenset|float|filter|file|execfile|eval|enumerate|divmod|dir|dict|delattr|complex|compile|coerce|cmp|classmethod|chr|callable|bool)(?![a-zA-Z0-9_])'),
PatternRule(r'python_reserved', r'(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'),
PatternRule(r'python_keyword', r'(?:yield|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])'),
PatternRule(r"python_builtin", r'(?<!\.)(?:zip|xrange|vars|unicode|unichr|type|tuple|super|sum|str|staticmethod|sorted|slice|setattr|set|round|repr|reduce|raw_input|range|property|pow|ord|open|oct|object|max|min|map|long|locals|list|len|iter|issubclass|isinstance|int|input|id|hex|hash|hasattr|globals|getattr|frozenset|float|filter|file|execfile|eval|enumerate|divmod|dir|dict|delattr|complex|compile|coerce|cmp|classmethod|chr|callable|bool)(?![a-zA-Z0-9_])'),
PatternRule(r'methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
PatternRule(r'functioncall', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
PatternRule(r'system_identifier', r'__[a-zA-Z0-9_]+__'),
@ -64,7 +64,7 @@ class PythonTabber(tab.StackTabber):
return True
tokens = self.get_tokens(y)
t0 = tokens[0]
if t0.name == 'keyword' and t0.string in self.startlevel_names:
if t0.name == 'python_keyword' and t0.string in self.startlevel_names:
# if a line has no whitespace and beings with something like
# 'while','class','def','if',etc. then we can start at it
return True
@ -149,7 +149,7 @@ class PythonTabber(tab.StackTabber):
else:
#self._pop()
pass
elif fqname == 'keyword':
elif fqname == 'python_keyword':
if token.string in self.endlevel_names:
# we know we'll unindent at least once
self._pop()
@ -188,25 +188,25 @@ class Python(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'keyword': ('cyan', 'default'),
'reserved': ('magenta', 'default'),
'builtin': ('cyan', 'default'),
'python_keyword': ('cyan', 'default'),
'python_reserved': ('magenta', 'default'),
'python_builtin': ('cyan', 'default'),
'functionname': ('blue', 'default'),
'classname': ('green', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.end': ('green', 'default'),
'rawstring.start': ('green', 'default'),
'rawstring.null': ('green', 'default'),
'rawstring.escaped': ('green', 'default'),
'rawstring.end': ('green', 'default'),
'integer': ('default', 'default'),
'float': ('default', 'default'),
'imaginary': ('default', 'default'),
'comment': ('red', 'default'),
'continuation': ('red', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.end': ('green', 'default'),
'rawstring.start': ('green', 'default'),
'rawstring.null': ('green', 'default'),
'rawstring.escaped': ('green', 'default'),
'rawstring.end': ('green', 'default'),
#'integer': ('default', 'default'),
#'float': ('default', 'default'),
#'imaginary': ('default', 'default'),
#'comment': ('red', 'default'),
#'continuation': ('red', 'default'),
'system_identifier': ('cyan', 'default'),
}
def __init__(self, w):

View File

@ -35,7 +35,7 @@ class RSTGrammar(Grammar):
PatternRule(r'reference', r'[a-zA-Z]+_'),
PatternRule(r'footnote', r'\[[0-9]+\]_'),
PatternRule(r'citation', r'\[.+?\]_'),
PatternRule(r'url', r'http://[^ ]+'),
PatternRule(r'rst_url', r'http://[^ ]+'),
PatternRule(r'bullet', r'^ *[-*+]'),
PatternRule(r'enumeration', r'^ *(?:[0-9]+|#)\.'),
@ -71,7 +71,7 @@ class RST(mode.Fundamental):
'reference': ('blue', 'default'),
'footnote': ('blue', 'default'),
'citation': ('blue', 'default'),
'url': ('blue', 'default'),
'rst_url': ('blue', 'default'),
'bullet': ('magenta', 'default'),
'enumeration': ('magenta', 'default'),

View File

@ -14,13 +14,13 @@ class SchemeGrammar(Grammar):
PatternRule(r'abbrev', r"'|`|,\@|,"),
# from r5rs
PatternRule(r'keyword', r'(?:=>|unquote-splicing|unquote|syntax-rules|set!|quote|quasiquote|or|map|loop|letrec-syntax|letrec|let-syntax|let\*|let|lambda|if|for-each|else|dynamic-wind|do|delay|define-syntax|define-macro|define|cond|case|call-with-output-file|call-with-input-file|call-with-current-continuation|begin|and)(?![^\n )])'),
PatternRule(r'scheme_keyword', r'(?:=>|unquote-splicing|unquote|syntax-rules|set!|quote|quasiquote|or|map|loop|letrec-syntax|letrec|let-syntax|let\*|let|lambda|if|for-each|else|dynamic-wind|do|delay|define-syntax|define-macro|define|cond|case|call-with-output-file|call-with-input-file|call-with-current-continuation|begin|and)(?![^\n )])'),
PatternRule(r'boolean', r'#[tf]'),
PatternRule(r'char', r'#\\space|#\\newline|#\\.'),
PatternRule(r'number', '[+-]?[0-9][^ ()\n]+'),
PatternRule(r'number', '#[bodx][ie]?[^ ()\n]+'),
PatternRule(r'number', '#[ie][bodx]?[^ ()\n]+'),
PatternRule(r'scheme_boolean', r'#[tf]'),
PatternRule(r'scheme_char', r'#\\space|#\\newline|#\\.'),
PatternRule(r'scheme_number', '[+-]?[0-9][^ ()\n]+'),
PatternRule(r'scheme_number', '#[bodx][ie]?[^ ()\n]+'),
PatternRule(r'scheme_number', '#[ie][bodx]?[^ ()\n]+'),
PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][-a-zA-Z0-9!$%&*/:<=>?^_~+.@]*|\+|-|\.\.\.'),
]
@ -36,19 +36,18 @@ class Scheme(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '('}
colors = {
'comment': ('red', 'default'),
#'comment': ('red', 'default'),
'keyword': ('cyan', 'default'),
'builtin': ('cyan', 'default'),
'scheme_keyword': ('cyan', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.end': ('green', 'default'),
'char': ('green', 'default'),
'boolean': ('magenta', 'default'),
'number': ('default', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.end': ('green', 'default'),
'scheme_char': ('green', 'default'),
'scheme_boolean': ('magenta', 'default'),
'scheme_number': ('default', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -28,7 +28,7 @@ class CaseGrammar(Grammar):
class TestGrammar(Grammar):
rules = [
PatternRule(r'builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|test|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"),
PatternRule(r'sh_builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|test|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"),
PatternRule(r'binop', r'==|=|!=|<|>'),
PatternRule(r'binop', r'-(?:nt|ot|ef|eq|ne|lt|gt|le|ge)(?![a-zA-Z0-9_])'),
PatternRule(r'unop', r'-[a-zA-Z](?![a-zA-Z0-9_])'),
@ -47,10 +47,10 @@ class TestGrammar(Grammar):
class ShGrammar(Grammar):
rules = [
PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'),
PatternRule(r'reserved', r"(?:done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"),
PatternRule(r'sh_function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'),
PatternRule(r'sh_reserved', r"(?:done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"),
RegionRule(r'case', r'case', Grammar, 'in', CaseGrammar, r'esac'),
PatternRule(r'builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"),
PatternRule(r'sh_builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"),
RegionRule(r'test', r'test', TestGrammar, r'\n'),
RegionRule(r'test2', r'\[', TestGrammar, r'\]'),
PatternRule(r'delimiter', r";;|[();{}|&><]"),
@ -82,7 +82,7 @@ class ShTabber(tab.StackTabber):
if not highlighter.tokens[y]:
return False
t = highlighter.tokens[y][0]
return t.name == 'function'
return t.name == 'sh_function'
def _handle_close_token(self, currlvl, y, i):
s = self.get_token(y, i).string
if s == ')' and self.markers and self._peek_name() == "case":
@ -95,7 +95,7 @@ class ShTabber(tab.StackTabber):
fqname = token.fqname()
if token.name == 'continuation':
self._opt_append("cont", currlvl + 4)
elif token.name == 'reserved' and token.string == 'else':
elif token.name == 'sh_reserved' and token.string == 'else':
currlvl -= 4
elif token.name == 'eol':
self._opt_pop("cont")
@ -109,15 +109,15 @@ class Sh(mode.Fundamental):
detection = ['sh', 'bash']
grammar = ShGrammar
tabbercls = ShTabber
opentokens = ('delimiter', 'reserved', 'case.start')
opentokens = ('delimiter', 'sh_reserved', 'case.start')
opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', 'case': 'esac'}
closetokens = ('delimiter', 'reserved', 'case.end')
closetokens = ('delimiter', 'sh_reserved', 'case.end')
closetags = {')': '(', ']': '[', '}': '{',
'done': 'do', 'fi': 'then', 'esac': 'case'}
colors = {
'builtin': ('cyan', 'default', 'bold'),
'function': ('magenta', 'default', 'bold'),
'reserved': ('magenta', 'default', 'bold'),
'sh_builtin': ('cyan', 'default', 'bold'),
'sh_function': ('magenta', 'default', 'bold'),
'sh_reserved': ('magenta', 'default', 'bold'),
'variable': ('yellow', 'default', 'bold'),
# case statements
@ -125,16 +125,16 @@ class Sh(mode.Fundamental):
'case.middle0': ('magenta', 'default', 'bold'),
'case.end': ('magenta', 'default', 'bold'),
'delimiter': ('default', 'default', 'bold'),
#'delimiter': ('default', 'default', 'bold'),
'test.start': ('cyan', 'default', 'bold'),
'binop': ('magenta', 'default', 'bold'),
'unop': ('magenta', 'default', 'bold'),
'string.start': ('green', 'default'),
'string.variable': ('yellow', 'default'),
'string.escaped': ('magenta', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
#'string.start': ('green', 'default'),
#'string.variable': ('yellow', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.null': ('green', 'default'),
#'string.end': ('green', 'default'),
'eval.start': ('cyan', 'default'),
'eval.variable': ('yellow', 'default'),
@ -146,8 +146,8 @@ class Sh(mode.Fundamental):
'neval.null': ('cyan', 'default'),
'neval.end': ('yellow', 'default'),
'comment': ('red', 'default'),
'continuation': ('red', 'default'),
#'comment': ('red', 'default'),
#'continuation': ('red', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -9,16 +9,16 @@ class PlPgSqlGrammar(Grammar):
PatternRule(r'delimiter', r':=|[():;,\.\[\]]'),
NocasePatternRule(r'attribute', r'(?:check|exists|unique|not null|default|primary key|minvalue|foreign key|references)(?![A-Za-z0-9_])'),
NocasePatternRule(r'keyword', r'(?:declare|begin|end if|end loop|end|raise notice|return|if|while|for|else)(?![A-Za-z0-9_])'),
NocasePatternRule(r'operator', r'(?:case|when|then|else|end|not|and|or|is not|is|in|not in)(?![A-Za-z0-9_])'),
NocasePatternRule(r'keyword', r'(?:create database|create index|create sequence|create table|create trigger|create view|select|insert|update|delete|drop database|drop index|drop sequence|drop table|drop trigger|drop view|create user|alter user|drop user|drop function|grant|revoke|create function|create or replace function|create or replace view|create language|create operator|create type)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_keyword', r'(?:declare|begin|end if|end loop|end|raise notice|return|if|while|for|else)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_operator', r'(?:case|when|then|else|end|not|and|or|is not|is|in|not in)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_keyword', r'(?:create database|create index|create sequence|create table|create trigger|create view|select|insert|update|delete|drop database|drop index|drop sequence|drop table|drop trigger|drop view|create user|alter user|drop user|drop function|grant|revoke|create function|create or replace function|create or replace view|create language|create operator|create type)(?![A-Za-z0-9_])'),
NocasePatternRule(r'pseudokeyword', r'(?:returns|language|right join|left join|inner join|outer join|join|where|null|true|false|into|values|as|from|order by|next|asc|desc|limit|distinct|cascade|alias for|using|on)(?![A-Za-z0-9_])'),
NocasePatternRule(r'type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool|record|row)(?![A-Za-z0-9_])'),
PatternRule(r'builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool|record|row)(?![A-Za-z0-9_])'),
PatternRule(r'sql_builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![A-Za-z0-9_])'),
RegionRule(r'string', "''", StringGrammar, "''"),
RegionRule(r'quoted', '"', StringGrammar, '"'),
PatternRule(r'variable', r'\$[1-9][0-9]*'),
PatternRule(r'bareword', r'[A-Za-z0-9_]+'),
RegionRule(r'sql_quoted', '"', StringGrammar, '"'),
PatternRule(r'sql_variable', r'\$[1-9][0-9]*'),
PatternRule(r'sql_bareword', r'[A-Za-z0-9_]+'),
PatternRule(r'empty', r'^ *\n$'),
PatternRule(r'eol', r'\n'),
]
@ -30,13 +30,13 @@ class FunctionGrammar(Grammar):
PatternRule(r'delimiter', r':=|[():;,\.\$\[\]]'),
PatternRule(r'name', r'[a-zA-Z_][a-zA-Z0-9_]*(?=\()'),
NocasePatternRule(r'keyword', r'(?:as|returns|language)'),
NocasePatternRule(r'type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_keyword', r'(?:as|returns|language)'),
NocasePatternRule(r'sql_type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool)(?![A-Za-z0-9_])'),
NocasePatternRule(r'language', r'(?<=language ) *[a-zA-Z_][a-zA-Z0-9_]+'),
RegionRule(r'definition', "'", PlPgSqlGrammar, "'(?!')"),
PatternRule(r'bareword', r'[A-Za-z0-9_]+'),
PatternRule(r'sql_bareword', r'[A-Za-z0-9_]+'),
PatternRule(r'empty', r'^ *\n$'),
PatternRule(r'eol', r'\n'),
]
@ -51,14 +51,14 @@ class SqlGrammar(Grammar):
NocaseRegionRule(r'function', r'create or replace function', FunctionGrammar, r';'),
NocasePatternRule(r'attribute', r'(?:check|exists|unique|not null|default|primary key|minvalue|foreign key|references)(?![A-Za-z0-9_])'),
NocasePatternRule(r'operator', r'(?:case|when|then|else|end|not|and|or|is not|is|in|not in)(?![A-Za-z0-9_])'),
NocasePatternRule(r'keyword', r'(?:create database|create index|create sequence|create table|create trigger|create view|select|insert|update|delete|drop database|drop index|drop sequence|drop table|drop trigger|drop view|create user|alter user|drop user|drop function|grant|revoke|create function|create or replace function|create or replace view|create language|create operator|create type)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_operator', r'(?:case|when|then|else|end|not|and|or|is not|is|in|not in)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_keyword', r'(?:create database|create index|create sequence|create table|create trigger|create view|select|insert|update|delete|drop database|drop index|drop sequence|drop table|drop trigger|drop view|create user|alter user|drop user|drop function|grant|revoke|create function|create or replace function|create or replace view|create language|create operator|create type)(?![A-Za-z0-9_])'),
NocasePatternRule(r'pseudokeyword', r'(?:returns|language|right join|left join|inner join|outer join|join|where|null|true|false|into|values|as|from|order by|asc|desc|limit|distinct|cascade|using|on)(?![A-Za-z0-9_])'),
NocasePatternRule(r'type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool)(?![A-Za-z0-9_])'),
PatternRule(r'builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![A-Za-z0-9_])'),
NocasePatternRule(r'sql_type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool)(?![A-Za-z0-9_])'),
PatternRule(r'sql_builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![A-Za-z0-9_])'),
RegionRule(r'string', "'", StringGrammar, "'"),
RegionRule(r'quoted', '"', StringGrammar, '"'),
PatternRule(r'bareword', r'[A-Za-z0-9_]+'),
RegionRule(r'sql_quoted', '"', StringGrammar, '"'),
PatternRule(r'sql_bareword', r'[A-Za-z0-9_]+'),
PatternRule(r'empty', r'^ *\n$'),
PatternRule(r'eol', r'\n'),
]
@ -78,7 +78,7 @@ class SqlTabber(tab.StackTabber):
s = token.string.lower()
if token.name == 'delimiter' and s == ';':
self._opt_pop('cont')
elif token.name == 'keyword':
elif token.name == 'sql_keyword':
if s == 'declare':
self._append('declare', currlvl + 4)
elif s == 'begin':
@ -116,21 +116,23 @@ class Sql(mode.Fundamental):
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'comment': ('red', 'default'),
'operator': ('yellow', 'default'),
#'comment': ('red', 'default'),
'sql_operator': ('yellow', 'default'),
'attribute': ('magenta', 'default'),
'keyword': ('cyan', 'default'),
'sql_keyword': ('cyan', 'default'),
'pseudokeyword': ('cyan', 'default'),
'type': ('green', 'default'),
'builtin': ('yellow', 'default'),
'quoted': ('yellow', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.escaped': ('magenta', 'default'),
'string.octal': ('magenta', 'default'),
'string.end': ('green', 'default'),
'variable': ('yellow', 'default'),
'bareword': ('default', 'default'),
'sql_type': ('green', 'default'),
'sql_builtin': ('yellow', 'default'),
'sql_quoted.start': ('yellow', 'default'),
'sql_quoted.null': ('yellow', 'default'),
'sql_quoted.end': ('yellow', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.end': ('green', 'default'),
'sql_variable': ('yellow', 'default'),
'sql_bareword': ('default', 'default'),
'function.start': ('cyan', 'default'),
'function.null': ('default', 'default'),
@ -139,7 +141,7 @@ class Sql(mode.Fundamental):
'function.end': ('default', 'default'),
'function.definition.start': ('magenta', 'default'),
'function.definition.bareword': ('magenta', 'default'),
'function.definition.sql_bareword': ('magenta', 'default'),
'function.definition.null': ('magenta', 'default'),
'function.definition.end': ('magenta', 'default'),
}

View File

@ -39,12 +39,12 @@ class Text(mode.Fundamental):
extensions=['.txt']
grammar = TextGrammar
colors = {
'misspelled': ('red', 'default'),
'cont.start': ('default', 'default'),
'cont.end': ('default', 'default'),
'word': ('default', 'default'),
'punct': ('default', 'default'),
'stuff': ('default', 'default'),
#'misspelled': ('red', 'default'),
#'cont.start': ('default', 'default'),
#'cont.end': ('default', 'default'),
#'word': ('default', 'default'),
#'punct': ('default', 'default'),
#'stuff': ('default', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -4,8 +4,8 @@ from mode.text import WordRule, ContinuedRule
class Text2Grammar(Grammar):
rules = [
PatternRule(name=r'email', pattern=r'(?:^|(?<=[ :]))<?[^<>@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'),
PatternRule(name=r'url', pattern=r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'),
PatternRule(name=r'text2_email', pattern=r'(?:^|(?<=[ :]))<?[^<>@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'),
PatternRule(name=r'text2_url', pattern=r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'),
ContinuedRule(),
WordRule(),
PatternRule(r'punct', r'[^a-zA-Z0-9_]'),
@ -18,14 +18,14 @@ class Text2(mode.text.Text):
extensions = ['.txt']
extensions = []
colors = {
'email': ('cyan', 'default'),
'url': ('green', 'default'),
'misspelled': ('red', 'default'),
'cont.start': ('default', 'default'),
'cont.end': ('default', 'default'),
'word': ('default', 'default'),
'punct': ('default', 'default'),
'stuff': ('default', 'default'),
'text2_email': ('cyan', 'default'),
'text2_url': ('green', 'default'),
#'misspelled': ('red', 'default'),
#'cont.start': ('default', 'default'),
#'cont.end': ('default', 'default'),
#'word': ('default', 'default'),
#'punct': ('default', 'default'),
#'stuff': ('default', 'default'),
}
install = Text2.install

View File

@ -25,7 +25,7 @@ class TemplateGrammar(Grammar):
rules = [
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
RegionRule(r'directive', r'\[\%', DirectiveGrammar, r'%%\]'),
RegionRule(r'tag', r'</?', TagGrammar, r'/?>'),
RegionRule(r'tt_tag', r'</?', TagGrammar, r'/?>'),
]
class Template(mode.Fundamental):
@ -33,9 +33,9 @@ class Template(mode.Fundamental):
extensions = ['.tt']
grammar = TemplateGrammar
colors = {
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'directive.start': ('magenta', 'default'),
'directive.comment': ('red', 'default'),
@ -48,14 +48,14 @@ class Template(mode.Fundamental):
'directive.null': ('magenta', 'default'),
'directive.end': ('magenta', 'default'),
'tag.start': ('default', 'default'),
'tag.namespace': ('magenta', 'default'),
'tag.name': ('blue', 'default'),
'tag.attrname': ('cyan', 'default'),
'tag.string.start': ('green', 'default'),
'tag.string.null': ('green', 'default'),
'tag.string.end': ('green', 'default'),
'tag.end': ('default', 'default'),
'tt_tag.start': ('default', 'default'),
'tt_tag.namespace': ('magenta', 'default'),
'tt_tag.name': ('blue', 'default'),
'tt_tag.attrname': ('cyan', 'default'),
'tt_tag.string.start': ('green', 'default'),
'tt_tag.string.null': ('green', 'default'),
'tt_tag.string.end': ('green', 'default'),
'tt_tag.end': ('default', 'default'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -14,7 +14,7 @@ class XMLGrammar(Grammar):
rules = [
# TODO: how does cdata work again?
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
RegionRule(r'tag', r'<', TagGrammar, r'/?>'),
RegionRule(r'xml_tag', r'<', TagGrammar, r'/?>'),
]
class XML(mode.Fundamental):
@ -22,17 +22,17 @@ class XML(mode.Fundamental):
extensions = ['.xml', '.xml.in']
grammar = XMLGrammar
colors = {
'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'),
'tag.start': ('default', 'default'),
'tag.namespace': ('magenta', 'default'),
'tag.name': ('blue', 'default'),
'tag.attrname': ('cyan', 'default'),
'tag.string.start': ('green', 'default'),
'tag.string.null': ('green', 'default'),
'tag.string.end': ('green', 'default'),
'tag.end': ('default', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'xml_tag.start': ('default', 'default'),
'xml_tag.namespace': ('magenta', 'default'),
'xml_tag.name': ('blue', 'default'),
'xml_tag.attrname': ('cyan', 'default'),
'xml_tag.string.start': ('green', 'default'),
'xml_tag.string.null': ('green', 'default'),
'xml_tag.string.end': ('green', 'default'),
'xml_tag.end': ('default', 'default'),
}
install = XML.install