parent
6bcf147a8e
commit
bc65acb16d
|
@ -48,6 +48,8 @@ class Application(object):
|
||||||
self.error_string = ""
|
self.error_string = ""
|
||||||
self.error_timestamp = None
|
self.error_timestamp = None
|
||||||
self.input = keyinput.Handler()
|
self.input = keyinput.Handler()
|
||||||
|
self.token_colors = {}
|
||||||
|
self.default_color = ('default', 'default',)
|
||||||
|
|
||||||
# initialize our colors
|
# initialize our colors
|
||||||
if curses.has_colors():
|
if curses.has_colors():
|
||||||
|
|
|
@ -10,6 +10,7 @@ sub foo {
|
||||||
#@@:heredoc:mode.sql.Sql
|
#@@:heredoc:mode.sql.Sql
|
||||||
my $s = <<EOT;
|
my $s = <<EOT;
|
||||||
drop table foog;
|
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;
|
select cast(plunk as timestamp) from blarg join plarg using(id_what) where x = 3;
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
@ -23,8 +24,8 @@ EOT
|
||||||
# wejgiwe jgiweg jweigewgj we gwee e e e ee e
|
# wejgiwe jgiweg jweigewgj we gwee e e e ee e
|
||||||
|
|
||||||
my $foo = {
|
my $foo = {
|
||||||
#@@:string:mode.sql.Sql
|
#@@:perl_string:mode.sql.Sql
|
||||||
'drop table ',
|
'drop table foogy;',
|
||||||
'bar',
|
'bar',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
20
lex.py
|
@ -99,6 +99,9 @@ class PatternRule(Rule):
|
||||||
class NocasePatternRule(PatternRule):
|
class NocasePatternRule(PatternRule):
|
||||||
reflags = re.IGNORECASE
|
reflags = re.IGNORECASE
|
||||||
|
|
||||||
|
class FakeWindow(object):
|
||||||
|
def __init__(self, app):
|
||||||
|
self.application = app
|
||||||
class OverrideError(Exception):
|
class OverrideError(Exception):
|
||||||
pass
|
pass
|
||||||
class OverridePatternRule(PatternRule):
|
class OverridePatternRule(PatternRule):
|
||||||
|
@ -108,11 +111,8 @@ class OverridePatternRule(PatternRule):
|
||||||
if lexer.action == 'lex':
|
if lexer.action == 'lex':
|
||||||
a = lexer.mode.window.application
|
a = lexer.mode.window.application
|
||||||
try:
|
try:
|
||||||
names = d['mode'].split('.')
|
modecls = a.modes[d['mode']]
|
||||||
modecls = a.globals()[names.pop(0)]
|
mode = modecls(FakeWindow(lexer.mode.window.application))
|
||||||
for name in names:
|
|
||||||
modecls = getattr(modecls, name)
|
|
||||||
mode = modecls(None)
|
|
||||||
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
|
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
|
||||||
lexer.mode.gstack['%s.start' % d['token']] = mode
|
lexer.mode.gstack['%s.start' % d['token']] = mode
|
||||||
else:
|
else:
|
||||||
|
@ -442,14 +442,14 @@ class Lexer(object):
|
||||||
mode = self.mstack[-1]
|
mode = self.mstack[-1]
|
||||||
else:
|
else:
|
||||||
mode = self.mode
|
mode = self.mode
|
||||||
v = list(mode.default_color)
|
app = mode.window.application
|
||||||
|
v = list(app.default_color)
|
||||||
for j in range(0, len(fqlist)):
|
for j in range(0, len(fqlist)):
|
||||||
name = '.'.join(fqlist[j:])
|
name = '.'.join(fqlist[j:])
|
||||||
if name in mode.colors:
|
if name in app.token_colors:
|
||||||
assert type(mode.colors[name]) == type(()), repr(mode)
|
assert type(app.token_colors[name]) == type(()), repr(mode)
|
||||||
v = list(mode.colors[name])
|
v = list(app.token_colors[name])
|
||||||
break
|
break
|
||||||
#if DARK_BACKGROUND:
|
|
||||||
if True:
|
if True:
|
||||||
v.append('bold')
|
v.append('bold')
|
||||||
return v
|
return v
|
||||||
|
|
|
@ -1598,7 +1598,7 @@ class GetToken(Method):
|
||||||
if token is None:
|
if token is None:
|
||||||
w.set_error('No Token')
|
w.set_error('No Token')
|
||||||
else:
|
else:
|
||||||
w.set_error('Token: %r' % token.string)
|
w.set_error('Token: %r (%s)' % (token.string, token.fqname()))
|
||||||
|
|
||||||
class RegisterSave(Method):
|
class RegisterSave(Method):
|
||||||
MAX_TXT = 30
|
MAX_TXT = 30
|
||||||
|
|
|
@ -85,20 +85,25 @@ class Fundamental(Handler):
|
||||||
grammar = None
|
grammar = None
|
||||||
lexer = None
|
lexer = None
|
||||||
tabber = None
|
tabber = None
|
||||||
default_color = ('default', 'default',)
|
|
||||||
colors = {}
|
colors = {}
|
||||||
|
#default_color = ('default', 'default',)
|
||||||
|
|
||||||
def install(cls, app):
|
def install(cls, app):
|
||||||
app.setmode(cls.modename.lower(), cls, paths=cls.paths,
|
app.setmode(cls.modename.lower(), cls, paths=cls.paths,
|
||||||
basenames=cls.basenames, extensions=cls.extensions,
|
basenames=cls.basenames, extensions=cls.extensions,
|
||||||
detection=cls.detection)
|
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)
|
install = classmethod(install)
|
||||||
|
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
|
assert w is not None
|
||||||
self.window = w
|
self.window = w
|
||||||
|
|
||||||
# we need to defer this due to curses startup
|
|
||||||
#self.default_color = color.pairs('default', 'default')
|
|
||||||
Handler.__init__(self)
|
Handler.__init__(self)
|
||||||
|
|
||||||
# first let's add all the "default" actions
|
# 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-dquotes', ('M-"',))
|
||||||
self.add_bindings('insert-escaped-squote', ('C-c M-\'',))
|
self.add_bindings('insert-escaped-squote', ('C-c M-\'',))
|
||||||
self.add_bindings('insert-escaped-dquote', ('C-c M-"',))
|
self.add_bindings('insert-escaped-dquote', ('C-c M-"',))
|
||||||
|
self.add_bindings('get-token', ('C-c t',))
|
||||||
|
|
||||||
# unbound actions
|
# unbound actions
|
||||||
self.add_action(method.GetToken())
|
self.add_action(method.GetToken())
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TemplateGrammar(Grammar):
|
||||||
PatternRule(r'comment', r'##.*\n'),
|
PatternRule(r'comment', r'##.*\n'),
|
||||||
PatternRule(r'placeholder', r'\$[a-zA-Z0-9_]+'),
|
PatternRule(r'placeholder', r'\$[a-zA-Z0-9_]+'),
|
||||||
PatternRule(r'directive', r'#.*?[#\n]'),
|
PatternRule(r'directive', r'#.*?[#\n]'),
|
||||||
RegionRule(r'tag', r'</?', TagGrammar, r'/?>'),
|
RegionRule(r'cheetah_tag', r'</?', TagGrammar, r'/?>'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class Template(mode.Fundamental):
|
class Template(mode.Fundamental):
|
||||||
|
@ -26,22 +26,22 @@ class Template(mode.Fundamental):
|
||||||
extensions = ['.tmpl']
|
extensions = ['.tmpl']
|
||||||
grammar = TemplateGrammar
|
grammar = TemplateGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
|
|
||||||
'directive': ('magenta', 'default'),
|
'directive': ('magenta', 'default'),
|
||||||
'placeholder': ('magenta', 'default'),
|
'placeholder': ('magenta', 'default'),
|
||||||
|
|
||||||
'tag.start': ('default', 'default'),
|
'cheetah_tag.start': ('default', 'default'),
|
||||||
'tag.namespace': ('magenta', 'default'),
|
'cheetah_tag.namespace': ('magenta', 'default'),
|
||||||
'tag.name': ('blue', 'default'),
|
'cheetah_tag.name': ('blue', 'default'),
|
||||||
'tag.attrname': ('cyan', 'default'),
|
'cheetah_tag.attrname': ('cyan', 'default'),
|
||||||
'tag.string.start': ('green', 'default'),
|
'cheetah_tag.string.start': ('green', 'default'),
|
||||||
'tag.string.null': ('green', 'default'),
|
'cheetah_tag.string.null': ('green', 'default'),
|
||||||
'tag.string.end': ('green', 'default'),
|
'cheetah_tag.string.end': ('green', 'default'),
|
||||||
'tag.end': ('default', 'default'),
|
'cheetah_tag.end': ('default', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
|
@ -9,8 +9,8 @@ class ConsoleGrammar(Grammar):
|
||||||
PatternRule(r'input', r'^-->.*$'),
|
PatternRule(r'input', r'^-->.*$'),
|
||||||
#PatternRule(r'output', r'^ .*$'),
|
#PatternRule(r'output', r'^ .*$'),
|
||||||
|
|
||||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
RegionRule(r'py_string', r'"', StringGrammar, r'"'),
|
||||||
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
RegionRule(r'py_string', r"'", StringGrammar, r"'"),
|
||||||
PatternRule(r'bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
PatternRule(r'bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
]
|
]
|
||||||
class Console(mode.Fundamental):
|
class Console(mode.Fundamental):
|
||||||
|
@ -21,11 +21,11 @@ class Console(mode.Fundamental):
|
||||||
'input': ('cyan', 'default'),
|
'input': ('cyan', 'default'),
|
||||||
'output': ('default', 'default'),
|
'output': ('default', 'default'),
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
'py_string.start': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
'py_string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
'py_string.escaped': ('magenta', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
'py_string.null': ('green', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
'py_string.end': ('green', 'default'),
|
||||||
}
|
}
|
||||||
|
|
||||||
install = Console.install
|
install = Console.install
|
||||||
|
|
40
mode/css.py
40
mode/css.py
|
@ -29,10 +29,10 @@ class CSSGrammar(Grammar):
|
||||||
NocasePatternRule(r'rule', r'@(?:page|media|import)'),
|
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'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)'),
|
NocasePatternRule(r'css_keyword', r'(?:url|rgb|counter)'),
|
||||||
NocaseRegionRule(r'keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'),
|
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'ident', r"-?[a-z_][-a-z0-9_]*"),
|
||||||
NocasePatternRule(r'name', r"[-a-z0-9_]+"),
|
NocasePatternRule(r'name', r"[-a-z0-9_]+"),
|
||||||
|
@ -50,10 +50,10 @@ class CSS(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
|
|
||||||
'htmlcomment': ('red', 'default'),
|
'htmlcomment': ('red', 'default'),
|
||||||
'htmlcomment.start': ('red', 'default'),
|
'htmlcomment.start': ('red', 'default'),
|
||||||
|
@ -68,27 +68,27 @@ class CSS(mode.Fundamental):
|
||||||
'color': ('magenta', 'default'),
|
'color': ('magenta', 'default'),
|
||||||
|
|
||||||
'hash': ('cyan', 'default'),
|
'hash': ('cyan', 'default'),
|
||||||
'label': ('cyan', 'default'),
|
'css_label': ('cyan', 'default'),
|
||||||
'rule': ('cyan', 'default'),
|
'rule': ('cyan', 'default'),
|
||||||
'keyword': ('cyan', 'default'),
|
'css_keyword': ('cyan', 'default'),
|
||||||
|
|
||||||
'ident': ('default', 'default'),
|
'ident': ('default', 'default'),
|
||||||
'name': ('default', 'default'),
|
'name': ('default', 'default'),
|
||||||
|
|
||||||
'delimiter': ('default', 'default'),
|
'delimiter': ('default', 'default'),
|
||||||
|
|
||||||
'keyword': ('cyan', 'default'),
|
'css_keyword': ('cyan', 'default'),
|
||||||
'keyword.start': ('default', 'default'),
|
'css_keyword.start': ('default', 'default'),
|
||||||
'keyword.null': ('cyan', 'default'),
|
'css_keyword.null': ('cyan', 'default'),
|
||||||
'keyword.octal': ('magenta', 'default'),
|
'css_keyword.octal': ('magenta', 'default'),
|
||||||
'keyword.escaped': ('magenta', 'default'),
|
'css_keyword.escaped': ('magenta', 'default'),
|
||||||
'keyword.end': ('default', 'default'),
|
'css_keyword.end': ('default', 'default'),
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ELispGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'comment', r';.*$'),
|
PatternRule(r'comment', r';.*$'),
|
||||||
PatternRule(r'reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
|
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'symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
PatternRule(r'type', 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-_]*"),
|
PatternRule(r'attribute', r"&[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
@ -39,20 +39,20 @@ class ELisp(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
'keyword': ('cyan', 'default'),
|
'elisp_keyword': ('cyan', 'default'),
|
||||||
'reserved': ('blue', 'default'),
|
'reserved': ('blue', 'default'),
|
||||||
'symbol': ('magenta', 'default'),
|
'symbol': ('magenta', 'default'),
|
||||||
'type': ('blue', 'default'),
|
'type': ('blue', 'default'),
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.format': ('yellow', 'default'),
|
#'string.format': ('yellow', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
'integer': ('default', 'default'),
|
#'integer': ('default', 'default'),
|
||||||
'float': ('default', 'default'),
|
#'float': ('default', 'default'),
|
||||||
'imaginary': ('default', 'default'),
|
#'imaginary': ('default', 'default'),
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
|
@ -19,9 +19,9 @@ class HTML(mode.Fundamental):
|
||||||
extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml']
|
extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml']
|
||||||
grammar = HTMLGrammar
|
grammar = HTMLGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
|
|
||||||
'script.start': ('default', 'default'),
|
'script.start': ('default', 'default'),
|
||||||
'script.namespace': ('magenta', 'default'),
|
'script.namespace': ('magenta', 'default'),
|
||||||
|
@ -41,7 +41,7 @@ class HTML(mode.Fundamental):
|
||||||
'tag.string.end': ('green', 'default'),
|
'tag.string.end': ('green', 'default'),
|
||||||
'tag.end': ('default', 'default'),
|
'tag.end': ('default', 'default'),
|
||||||
}
|
}
|
||||||
colors.update(Javascript.colors)
|
#colors.update(Javascript.colors)
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
self.add_bindings('close-paren', (')',))
|
self.add_bindings('close-paren', (')',))
|
||||||
|
|
42
mode/java.py
42
mode/java.py
|
@ -13,19 +13,19 @@ class JavaGrammar(Grammar):
|
||||||
PatternRule(r'comment', r'//.*$'),
|
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'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'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
|
||||||
PatternRule(r"unop", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
|
PatternRule(r"unop", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
|
||||||
PatternRule(r'binop', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
PatternRule(r'binop', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
||||||
|
|
||||||
PatternRule(r"delimiter", 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"java_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_float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
|
||||||
RegionRule(r'string', '"', StringGrammar, '"'),
|
RegionRule(r'string', '"', StringGrammar, '"'),
|
||||||
PatternRule(r'char', r"'.'|'\\.'|'\\[0-7]{3}'"),
|
PatternRule(r'java_char', r"'.'|'\\.'|'\\[0-7]{3}'"),
|
||||||
PatternRule(r"eol", r"\n$"),
|
PatternRule(r"eol", r"\n$"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -163,29 +163,29 @@ class Java(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
|
|
||||||
'doccomment.start': ('red', 'default'),
|
'doccomment.start': ('red', 'default'),
|
||||||
'doccomment.end': ('red', 'default'),
|
'doccomment.end': ('red', 'default'),
|
||||||
'doccomment.null': ('red', 'default'),
|
'doccomment.null': ('red', 'default'),
|
||||||
|
|
||||||
'import': ('blue', 'default'),
|
'import': ('blue', 'default'),
|
||||||
'label': ('magenta', 'default'),
|
'java_label': ('magenta', 'default'),
|
||||||
'keyword': ('cyan', 'default'),
|
#'keyword': ('cyan', 'default'),
|
||||||
'function': ('blue', 'default'),
|
#'function': ('blue', 'default'),
|
||||||
'builtin': ('magenta', 'default'),
|
'java_builtin': ('magenta', 'default'),
|
||||||
|
|
||||||
'char': ('green', 'default'),
|
'java_char': ('green', 'default'),
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.octal': ('green', 'default'),
|
#'string.octal': ('green', 'default'),
|
||||||
'string.escaped': ('green', 'default'),
|
#'string.escaped': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
'integer': ('green', 'default'),
|
'java_integer': ('green', 'default'),
|
||||||
'float': ('green', 'default'),
|
'java_float': ('green', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
|
@ -8,12 +8,12 @@ class JavascriptGrammar(Grammar):
|
||||||
PatternRule(r'comment', r'//.*$'),
|
PatternRule(r'comment', r'//.*$'),
|
||||||
RegionRule(r'comment', '/\*', Grammar, '\*/'),
|
RegionRule(r'comment', '/\*', Grammar, '\*/'),
|
||||||
PatternRule(r'continuation', r'\\(?= *$)'),
|
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'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'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'reserved', r'(?:abstract|debugger|enum|goto|implements|interface|native|protected|synchronized|throws|transient|volatile)(?![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'nonreserved', r'(?:get|include|set)(?![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"method", r"(?<=\.)[a-zA-Z_][a-zA-Z0-9_]*(?= *\()"),
|
||||||
PatternRule(r'identifier', 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'delimiter', r'%=|&&=|&=|\(|\)|\*=|\+=|,|-=|\.{3}|\.|/=(?= |$)|::|:|;|<<=|>>=|>>>=|\?|\[|\]|^=|^^=|\{|\}|\|=|\|\|='),
|
||||||
PatternRule(r'operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/(?= |$)|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\'),
|
PatternRule(r'operator', r'!==|!=|!|%|&&|&|\*|\+\+|\+|--|-|/(?= |$)|<<=|<<|<=|<|===|==|=|>>>=|>>>|>>=|>>|>=|>|\\'),
|
||||||
|
|
||||||
RegionRule('regex', "/", StringGrammar, "/"),
|
RegionRule('js_regex', "/", StringGrammar, "/"),
|
||||||
RegionRule('string', "'", StringGrammar, "'"),
|
RegionRule('string', "'", StringGrammar, "'"),
|
||||||
RegionRule('string', '"', StringGrammar, '"'),
|
RegionRule('string', '"', StringGrammar, '"'),
|
||||||
]
|
]
|
||||||
|
@ -62,33 +62,33 @@ class Javascript(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
'continuation': ('red', 'default'),
|
'continuation': ('red', 'default'),
|
||||||
'function': ('blue', 'default'),
|
'js_function': ('blue', 'default'),
|
||||||
'class': ('green', 'default'),
|
'class': ('green', 'default'),
|
||||||
|
|
||||||
'reserved': ('cyan', 'default'),
|
'js_reserved': ('cyan', 'default'),
|
||||||
'nonreserved': ('cyan', 'default'),
|
'js_nonreserved': ('cyan', 'default'),
|
||||||
|
|
||||||
'delimiter': ('default', 'default'),
|
#'delimiter': ('default', 'default'),
|
||||||
'operator': ('default', 'default'),
|
#'operator': ('default', 'default'),
|
||||||
'integer': ('default', 'default'),
|
#'integer': ('default', 'default'),
|
||||||
'float': ('default', 'default'),
|
#'float': ('default', 'default'),
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
|
|
||||||
'regex.start': ('cyan', 'default'),
|
'js_regex.start': ('cyan', 'default'),
|
||||||
'regex.null': ('cyan', 'default'),
|
'js_regex.null': ('cyan', 'default'),
|
||||||
'regex.octal': ('magenta', 'default'),
|
'js_regex.octal': ('magenta', 'default'),
|
||||||
'regex.escaped': ('magenta', 'default'),
|
'js_regex.escaped': ('magenta', 'default'),
|
||||||
'regex.end': ('cyan', 'default'),
|
'js_regex.end': ('cyan', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
12
mode/lisp.py
12
mode/lisp.py
|
@ -40,12 +40,12 @@ class Lisp(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '('}
|
closetags = {')': '('}
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
26
mode/make.py
26
mode/make.py
|
@ -21,10 +21,10 @@ class MakeGrammar(Grammar):
|
||||||
#RegionRule(r'targets', r'^[^:= ]+ *:', Grammar, r';|\n', ShGrammar, r'\n'),
|
#RegionRule(r'targets', r'^[^:= ]+ *:', Grammar, r';|\n', ShGrammar, r'\n'),
|
||||||
RegionRule(r'actions', r'^ ', ShGrammar, r'\n'),
|
RegionRule(r'actions', r'^ ', ShGrammar, r'\n'),
|
||||||
|
|
||||||
PatternRule(r'variable', r'\$\([a-zA-Z0-9_]+\)'),
|
PatternRule(r'make_variable', r'\$\([a-zA-Z0-9_]+\)'),
|
||||||
PatternRule(r'variable', r'\${[a-zA-Z0-9_]+}'),
|
PatternRule(r'make_variable', r'\${[a-zA-Z0-9_]+}'),
|
||||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
RegionRule(r'make_string', r'"', StringGrammar, r'"'),
|
||||||
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
RegionRule(r'make_string', r"'", StringGrammar, r"'"),
|
||||||
]
|
]
|
||||||
|
|
||||||
class Make(mode.Fundamental):
|
class Make(mode.Fundamental):
|
||||||
|
@ -33,22 +33,22 @@ class Make(mode.Fundamental):
|
||||||
grammar = MakeGrammar
|
grammar = MakeGrammar
|
||||||
savetabs = True
|
savetabs = True
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'continuation': ('red', 'default'),
|
#'continuation': ('red', 'default'),
|
||||||
|
|
||||||
'targets.start': ('cyan', 'default'),
|
'targets.start': ('cyan', 'default'),
|
||||||
'assignment.start': ('yellow', 'default'),
|
'assignment.start': ('yellow', 'default'),
|
||||||
#'targets': ('cyan', 'default'),
|
#'targets': ('cyan', 'default'),
|
||||||
#'assignment': ('yellow', 'default'),
|
#'assignment': ('yellow', 'default'),
|
||||||
|
|
||||||
'variable': ('yellow', 'default'),
|
'make_variable': ('yellow', 'default'),
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
'make_string.start': ('green', 'default'),
|
||||||
'string.variable': ('yellow', 'default'),
|
'make_string.variable': ('yellow', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
'make_string.escaped': ('magenta', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
'make_string.null': ('green', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
'make_string.end': ('green', 'default'),
|
||||||
}
|
}
|
||||||
colors.update(Sh.colors)
|
#colors.update(Sh.colors)
|
||||||
|
|
||||||
install = Make.install
|
install = Make.install
|
||||||
|
|
|
@ -5,7 +5,7 @@ from lex import Grammar, PatternRule
|
||||||
|
|
||||||
class MuttGrammar(Grammar):
|
class MuttGrammar(Grammar):
|
||||||
rules = [
|
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'quoteb', pattern=r'^ *(?:(?: *>){3})*(?: *>){2}.*$'),
|
||||||
PatternRule(name=r'quotea', pattern=r'^ *(?:(?: *>){3})*(?: *>){1}.*$'),
|
PatternRule(name=r'quotea', pattern=r'^ *(?:(?: *>){3})*(?: *>){1}.*$'),
|
||||||
PatternRule(name=r'quotec', pattern=r'^ *(?:(?: *>){3})*(?: *>){3}.*$'),
|
PatternRule(name=r'quotec', pattern=r'^ *(?:(?: *>){3})*(?: *>){3}.*$'),
|
||||||
|
@ -21,7 +21,7 @@ class Mutt(mode.Fundamental):
|
||||||
modename = 'Mutt'
|
modename = 'Mutt'
|
||||||
grammar = MuttGrammar()
|
grammar = MuttGrammar()
|
||||||
colors = {
|
colors = {
|
||||||
'header': ('green', 'default', 'bold'),
|
'mutt_header': ('green', 'default', 'bold'),
|
||||||
'email': ('cyan', 'default', 'bold'),
|
'email': ('cyan', 'default', 'bold'),
|
||||||
'url': ('cyan', 'default', 'bold'),
|
'url': ('cyan', 'default', 'bold'),
|
||||||
'quotea': ('yellow', 'default', 'bold'),
|
'quotea': ('yellow', 'default', 'bold'),
|
||||||
|
|
16
mode/nasm.py
16
mode/nasm.py
|
@ -9,12 +9,12 @@ class StringGrammar(Grammar):
|
||||||
|
|
||||||
class NasmGrammar(Grammar):
|
class NasmGrammar(Grammar):
|
||||||
rules = [
|
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'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'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'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'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"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"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]+"),
|
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']
|
extensions = ['.s']
|
||||||
grammar = NasmGrammar
|
grammar = NasmGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'keyword': ('cyan', 'default', 'bold'),
|
'nasm_keyword': ('cyan', 'default', 'bold'),
|
||||||
'macros': ('blue', 'default', 'bold'),
|
'macros': ('blue', 'default', 'bold'),
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'registers': ('yellow', 'default'),
|
'registers': ('yellow', 'default'),
|
||||||
'instructions': ('magenta', 'default'),
|
'instructions': ('magenta', 'default'),
|
||||||
'label': ('blue', 'default'),
|
'nasm_label': ('blue', 'default'),
|
||||||
}
|
}
|
||||||
|
|
||||||
install = Nasm.install
|
install = Nasm.install
|
||||||
|
|
|
@ -25,7 +25,7 @@ class OcamlGrammar(Grammar):
|
||||||
|
|
||||||
PatternRule(r'delimiter', r"[()]"),
|
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', 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_])"),
|
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"'\\[0-9]{3}'"),
|
||||||
PatternRule(r'char', r"'\\x[0-9A-Fa-f]{2}'"),
|
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'label', r"~[a-z_]['a-zA-Z0-9_]*:"),
|
||||||
PatternRule(r'optlabel', 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',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '('}
|
closetags = {')': '('}
|
||||||
colors = {
|
colors = {
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
'linenum': ('red', 'default'),
|
'linenum': ('red', 'default'),
|
||||||
|
|
||||||
'keyword': ('cyan', 'default'),
|
'ocaml_keyword': ('cyan', 'default'),
|
||||||
|
|
||||||
#'builtin': ('magenta', 'default'),
|
#'builtin': ('magenta', 'default'),
|
||||||
#'builtin_exception': ('magenta', 'default'),
|
#'builtin_exception': ('magenta', 'default'),
|
||||||
#'builtin_function': ('magenta', 'default'),
|
#'builtin_function': ('magenta', 'default'),
|
||||||
|
|
||||||
'label': ('blue', 'default'),
|
'ocaml_label': ('blue', 'default'),
|
||||||
'optlabel': ('blue', 'default'),
|
'optlabel': ('blue', 'default'),
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
'ocaml_string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
'ocaml_string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
'ocaml_string.octal': ('magenta', 'default'),
|
||||||
'string.hex': ('magenta', 'default'),
|
'ocaml_string.hex': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
'ocaml_string.escaped': ('magenta', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
'ocaml_string.end': ('green', 'default'),
|
||||||
'char': ('green', 'default'),
|
#'char': ('green', 'default'),
|
||||||
'integer': ('default', 'default'),
|
#'integer': ('default', 'default'),
|
||||||
'float': ('default', 'default'),
|
#'float': ('default', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
56
mode/perl.py
56
mode/perl.py
|
@ -59,21 +59,21 @@ class PerlGrammar(Grammar):
|
||||||
PatternGroupRule(r'prototype', r'delimiter', r'\(', r'prototype', r'[\[\]\\@$%&*;]+', r'delimiter', '\)'),
|
PatternGroupRule(r'prototype', r'delimiter', r'\(', r'prototype', r'[\[\]\\@$%&*;]+', r'delimiter', '\)'),
|
||||||
|
|
||||||
PatternRule(r'comment', r'#.*$'),
|
PatternRule(r'comment', r'#.*$'),
|
||||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
RegionRule(r'perl_string', r'"', StringGrammar, r'"'),
|
||||||
RegionRule(r'string', r"'", Grammar, r"'"),
|
RegionRule(r'perl_string', r"'", Grammar, r"'"),
|
||||||
RegionRule(r'evalstring', r"`", StringGrammar, r"`"),
|
RegionRule(r'evalstring', r"`", StringGrammar, r"`"),
|
||||||
PatternRule(r'number', r'0?\.[0-9]+|[0-9]+(?:\.[0-9]+)?'),
|
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'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'length', r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),
|
||||||
PatternRule(r'cast', r'[\$\@\%\^\&](?= *{)'),
|
PatternRule(r'cast', r'[\$\@\%\^\&](?= *{)'),
|
||||||
PatternRule(r'scalar', r"\$[\[\]<>ab/'\"_@\?#\$!%^|&*()](?![A-Za-z0-9_])"),
|
PatternRule(r'scalar', r"\$[\[\]<>ab/'\"_@\?#\$!%^|&*()](?![A-Za-z0-9_])"),
|
||||||
PatternRule(r'array', r"@_"),
|
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'scalar', r"\$\$*[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),
|
||||||
PatternRule(r'array', r"@\$*[A-Za-z_](?:[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"[@%\$&\*](?={)"),
|
PatternRule(r'deref', r"[@%\$&\*](?={)"),
|
||||||
|
|
||||||
# match regexes
|
# match regexes
|
||||||
|
@ -94,10 +94,10 @@ class PerlGrammar(Grammar):
|
||||||
PatternRule(r'sub', r"(?<=sub )[a-zA-Z_][a-zA-Z_0-9]*"),
|
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'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'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'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'perl_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_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
|
# quote operator: qq(), qx() and qr() usually interpolate
|
||||||
RegionRule(r'quoted', r'q[rqx] *(?P<delim>\()', QuotedGrammar1, r'\)'),
|
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?#', Grammar, r'#'),
|
||||||
RegionRule(r'quoted', r'qw? *(?P<delim>[^ #])', Grammar, r'%(delim)s'),
|
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'perl_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_class', r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?=->)"),
|
||||||
|
|
||||||
# some basic stuff
|
# some basic stuff
|
||||||
PatternRule(r'delimiter', r"->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"),
|
PatternRule(r'delimiter', r"->|=>|(?<!:):(?!=:)|[,;=\?(){}\[\]\(\)]"),
|
||||||
|
@ -137,7 +137,7 @@ class PerlTabber(tab.StackTabber):
|
||||||
if not highlighter.tokens[y]:
|
if not highlighter.tokens[y]:
|
||||||
return False
|
return False
|
||||||
t = highlighter.tokens[y][0]
|
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):
|
def _handle_open_token(self, currlvl, y, i):
|
||||||
currlvl = tab.StackTabber._handle_open_token(self, currlvl, y, i)
|
currlvl = tab.StackTabber._handle_open_token(self, currlvl, y, i)
|
||||||
return currlvl
|
return currlvl
|
||||||
|
@ -176,16 +176,16 @@ class PerlTabber(tab.StackTabber):
|
||||||
elif fqname == 'pod.end':
|
elif fqname == 'pod.end':
|
||||||
self._opt_pop('pod')
|
self._opt_pop('pod')
|
||||||
currlvl = 0
|
currlvl = 0
|
||||||
elif fqname == 'string.start':
|
elif fqname == 'perl_string.start':
|
||||||
self._opt_append('string', None)
|
self._opt_append('string', None)
|
||||||
elif fqname == 'string.end':
|
elif fqname == 'perl_string.end':
|
||||||
self._opt_pop('string')
|
self._opt_pop('string')
|
||||||
if self.is_rightmost_token(y, i):
|
if self.is_rightmost_token(y, i):
|
||||||
self._opt_append('cont', currlvl + 4)
|
self._opt_append('cont', currlvl + 4)
|
||||||
if self.is_rightmost_token(y, i):
|
if self.is_rightmost_token(y, i):
|
||||||
if(not fqname.startswith('pod') and
|
if(not fqname.startswith('pod') and
|
||||||
not fqname.startswith('heredoc') and
|
not fqname.startswith('heredoc') and
|
||||||
not fqname.startswith('string') and
|
not fqname.startswith('perl_string') and
|
||||||
not fqname.startswith('endblock') and
|
not fqname.startswith('endblock') and
|
||||||
not fqname == 'eol' and
|
not fqname == 'eol' and
|
||||||
not fqname == 'comment' and
|
not fqname == 'comment' and
|
||||||
|
@ -206,7 +206,7 @@ class Perl(mode.Fundamental):
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
# comments
|
# comments
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'endblock.start': ('red', 'default'),
|
'endblock.start': ('red', 'default'),
|
||||||
'endblock.null': ('red', 'default'),
|
'endblock.null': ('red', 'default'),
|
||||||
'endblock.end': ('red', 'default'),
|
'endblock.end': ('red', 'default'),
|
||||||
|
@ -222,27 +222,27 @@ class Perl(mode.Fundamental):
|
||||||
# basic stuff
|
# basic stuff
|
||||||
'escaped': ('magenta', 'default'),
|
'escaped': ('magenta', 'default'),
|
||||||
'null': ('default', 'default'),
|
'null': ('default', 'default'),
|
||||||
'delimiter': ('default', 'default'),
|
#'delimiter': ('default', 'default'),
|
||||||
'sub': ('cyan', 'default'),
|
'sub': ('cyan', 'default'),
|
||||||
'prototype': ('magenta', 'default'),
|
'prototype': ('magenta', 'default'),
|
||||||
'number': ('default', 'default'),
|
'number': ('default', 'default'),
|
||||||
'operator': ('default', 'default'),
|
'operator': ('default', 'default'),
|
||||||
'noperator': ('magenta', 'default'),
|
'noperator': ('magenta', 'default'),
|
||||||
'endblock': ('red', 'default'),
|
'endblock': ('red', 'default'),
|
||||||
'keyword': ('magenta', 'default'),
|
'perl_keyword': ('magenta', 'default'),
|
||||||
'cast': ('yellow', 'default'),
|
'cast': ('yellow', 'default'),
|
||||||
'scalar': ('yellow', 'default'),
|
'scalar': ('yellow', 'default'),
|
||||||
'array': ('yellow', 'default'),
|
'array': ('yellow', 'default'),
|
||||||
'deref': ('yellow', 'default'),
|
'deref': ('yellow', 'default'),
|
||||||
'hash': ('yellow', 'default'),
|
'perl_hash': ('yellow', 'default'),
|
||||||
'hash_key': ('green', 'default'),
|
'hash_key': ('green', 'default'),
|
||||||
'function': ('cyan', 'default'),
|
'perl_function': ('cyan', 'default'),
|
||||||
'builtin': ('magenta', 'default'),
|
'perl_builtin': ('magenta', 'default'),
|
||||||
'method': ('cyan', 'default'),
|
'method': ('cyan', 'default'),
|
||||||
'bareword': ('default', 'default'),
|
'bareword': ('default', 'default'),
|
||||||
'label': ('cyan', 'default'),
|
'perl_label': ('cyan', 'default'),
|
||||||
'package': ('cyan', 'default'),
|
'package': ('cyan', 'default'),
|
||||||
'class': ('cyan', 'default'),
|
'perl_class': ('cyan', 'default'),
|
||||||
'use': ('cyan', 'default'),
|
'use': ('cyan', 'default'),
|
||||||
'require': ('cyan', 'default'),
|
'require': ('cyan', 'default'),
|
||||||
'method': ('cyan', 'default'),
|
'method': ('cyan', 'default'),
|
||||||
|
@ -256,11 +256,11 @@ class Perl(mode.Fundamental):
|
||||||
'evaldoc.end': ('cyan', 'default'),
|
'evaldoc.end': ('cyan', 'default'),
|
||||||
|
|
||||||
# strings
|
# strings
|
||||||
'string.start': ('green', 'default'),
|
'perl_string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
'perl_string.null': ('green', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
'perl_string.escaped': ('magenta', 'default'),
|
||||||
'string.deref': ('yellow', 'default'),
|
'perl_string.deref': ('yellow', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
'perl_string.end': ('green', 'default'),
|
||||||
|
|
||||||
# `` strings
|
# `` strings
|
||||||
'evalstring.start': ('cyan', 'default'),
|
'evalstring.start': ('cyan', 'default'),
|
||||||
|
@ -291,7 +291,7 @@ class Perl(mode.Fundamental):
|
||||||
'replace.deref': ('yellow', 'default'),
|
'replace.deref': ('yellow', 'default'),
|
||||||
'replace.length': ('yellow', 'default'),
|
'replace.length': ('yellow', 'default'),
|
||||||
'replace.scalar': ('yellow', 'default'),
|
'replace.scalar': ('yellow', 'default'),
|
||||||
'replace.hash': ('yellow', 'default'),
|
'replace.perl_hash': ('yellow', 'default'),
|
||||||
'replace.cast': ('yellow', 'default'),
|
'replace.cast': ('yellow', 'default'),
|
||||||
|
|
||||||
# translate regex
|
# translate regex
|
||||||
|
|
|
@ -19,9 +19,9 @@ class PythonGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
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'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'python_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'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"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_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'methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||||
PatternRule(r'functioncall', 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_]+__'),
|
PatternRule(r'system_identifier', r'__[a-zA-Z0-9_]+__'),
|
||||||
|
@ -64,7 +64,7 @@ class PythonTabber(tab.StackTabber):
|
||||||
return True
|
return True
|
||||||
tokens = self.get_tokens(y)
|
tokens = self.get_tokens(y)
|
||||||
t0 = tokens[0]
|
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
|
# if a line has no whitespace and beings with something like
|
||||||
# 'while','class','def','if',etc. then we can start at it
|
# 'while','class','def','if',etc. then we can start at it
|
||||||
return True
|
return True
|
||||||
|
@ -149,7 +149,7 @@ class PythonTabber(tab.StackTabber):
|
||||||
else:
|
else:
|
||||||
#self._pop()
|
#self._pop()
|
||||||
pass
|
pass
|
||||||
elif fqname == 'keyword':
|
elif fqname == 'python_keyword':
|
||||||
if token.string in self.endlevel_names:
|
if token.string in self.endlevel_names:
|
||||||
# we know we'll unindent at least once
|
# we know we'll unindent at least once
|
||||||
self._pop()
|
self._pop()
|
||||||
|
@ -188,25 +188,25 @@ class Python(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
'keyword': ('cyan', 'default'),
|
'python_keyword': ('cyan', 'default'),
|
||||||
'reserved': ('magenta', 'default'),
|
'python_reserved': ('magenta', 'default'),
|
||||||
'builtin': ('cyan', 'default'),
|
'python_builtin': ('cyan', 'default'),
|
||||||
'functionname': ('blue', 'default'),
|
'functionname': ('blue', 'default'),
|
||||||
'classname': ('green', 'default'),
|
'classname': ('green', 'default'),
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
'rawstring.start': ('green', 'default'),
|
'rawstring.start': ('green', 'default'),
|
||||||
'rawstring.null': ('green', 'default'),
|
'rawstring.null': ('green', 'default'),
|
||||||
'rawstring.escaped': ('green', 'default'),
|
'rawstring.escaped': ('green', 'default'),
|
||||||
'rawstring.end': ('green', 'default'),
|
'rawstring.end': ('green', 'default'),
|
||||||
'integer': ('default', 'default'),
|
#'integer': ('default', 'default'),
|
||||||
'float': ('default', 'default'),
|
#'float': ('default', 'default'),
|
||||||
'imaginary': ('default', 'default'),
|
#'imaginary': ('default', 'default'),
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'continuation': ('red', 'default'),
|
#'continuation': ('red', 'default'),
|
||||||
'system_identifier': ('cyan', 'default'),
|
'system_identifier': ('cyan', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
|
|
|
@ -35,7 +35,7 @@ class RSTGrammar(Grammar):
|
||||||
PatternRule(r'reference', r'[a-zA-Z]+_'),
|
PatternRule(r'reference', r'[a-zA-Z]+_'),
|
||||||
PatternRule(r'footnote', r'\[[0-9]+\]_'),
|
PatternRule(r'footnote', r'\[[0-9]+\]_'),
|
||||||
PatternRule(r'citation', r'\[.+?\]_'),
|
PatternRule(r'citation', r'\[.+?\]_'),
|
||||||
PatternRule(r'url', r'http://[^ ]+'),
|
PatternRule(r'rst_url', r'http://[^ ]+'),
|
||||||
|
|
||||||
PatternRule(r'bullet', r'^ *[-*+]'),
|
PatternRule(r'bullet', r'^ *[-*+]'),
|
||||||
PatternRule(r'enumeration', r'^ *(?:[0-9]+|#)\.'),
|
PatternRule(r'enumeration', r'^ *(?:[0-9]+|#)\.'),
|
||||||
|
@ -71,7 +71,7 @@ class RST(mode.Fundamental):
|
||||||
'reference': ('blue', 'default'),
|
'reference': ('blue', 'default'),
|
||||||
'footnote': ('blue', 'default'),
|
'footnote': ('blue', 'default'),
|
||||||
'citation': ('blue', 'default'),
|
'citation': ('blue', 'default'),
|
||||||
'url': ('blue', 'default'),
|
'rst_url': ('blue', 'default'),
|
||||||
|
|
||||||
'bullet': ('magenta', 'default'),
|
'bullet': ('magenta', 'default'),
|
||||||
'enumeration': ('magenta', 'default'),
|
'enumeration': ('magenta', 'default'),
|
||||||
|
|
|
@ -14,13 +14,13 @@ class SchemeGrammar(Grammar):
|
||||||
PatternRule(r'abbrev', r"'|`|,\@|,"),
|
PatternRule(r'abbrev', r"'|`|,\@|,"),
|
||||||
|
|
||||||
# from r5rs
|
# 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'scheme_boolean', r'#[tf]'),
|
||||||
PatternRule(r'char', r'#\\space|#\\newline|#\\.'),
|
PatternRule(r'scheme_char', r'#\\space|#\\newline|#\\.'),
|
||||||
PatternRule(r'number', '[+-]?[0-9][^ ()\n]+'),
|
PatternRule(r'scheme_number', '[+-]?[0-9][^ ()\n]+'),
|
||||||
PatternRule(r'number', '#[bodx][ie]?[^ ()\n]+'),
|
PatternRule(r'scheme_number', '#[bodx][ie]?[^ ()\n]+'),
|
||||||
PatternRule(r'number', '#[ie][bodx]?[^ ()\n]+'),
|
PatternRule(r'scheme_number', '#[ie][bodx]?[^ ()\n]+'),
|
||||||
|
|
||||||
PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][-a-zA-Z0-9!$%&*/:<=>?^_~+.@]*|\+|-|\.\.\.'),
|
PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][-a-zA-Z0-9!$%&*/:<=>?^_~+.@]*|\+|-|\.\.\.'),
|
||||||
]
|
]
|
||||||
|
@ -36,19 +36,18 @@ class Scheme(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '('}
|
closetags = {')': '('}
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
|
|
||||||
'keyword': ('cyan', 'default'),
|
'scheme_keyword': ('cyan', 'default'),
|
||||||
'builtin': ('cyan', 'default'),
|
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
'char': ('green', 'default'),
|
'scheme_char': ('green', 'default'),
|
||||||
'boolean': ('magenta', 'default'),
|
'scheme_boolean': ('magenta', 'default'),
|
||||||
'number': ('default', 'default'),
|
'scheme_number': ('default', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
38
mode/sh.py
38
mode/sh.py
|
@ -28,7 +28,7 @@ class CaseGrammar(Grammar):
|
||||||
|
|
||||||
class TestGrammar(Grammar):
|
class TestGrammar(Grammar):
|
||||||
rules = [
|
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'==|=|!=|<|>'),
|
||||||
PatternRule(r'binop', r'-(?:nt|ot|ef|eq|ne|lt|gt|le|ge)(?![a-zA-Z0-9_])'),
|
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_])'),
|
PatternRule(r'unop', r'-[a-zA-Z](?![a-zA-Z0-9_])'),
|
||||||
|
@ -47,10 +47,10 @@ class TestGrammar(Grammar):
|
||||||
|
|
||||||
class ShGrammar(Grammar):
|
class ShGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'),
|
PatternRule(r'sh_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_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'),
|
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'test', r'test', TestGrammar, r'\n'),
|
||||||
RegionRule(r'test2', r'\[', TestGrammar, r'\]'),
|
RegionRule(r'test2', r'\[', TestGrammar, r'\]'),
|
||||||
PatternRule(r'delimiter', r";;|[();{}|&><]"),
|
PatternRule(r'delimiter', r";;|[();{}|&><]"),
|
||||||
|
@ -82,7 +82,7 @@ class ShTabber(tab.StackTabber):
|
||||||
if not highlighter.tokens[y]:
|
if not highlighter.tokens[y]:
|
||||||
return False
|
return False
|
||||||
t = highlighter.tokens[y][0]
|
t = highlighter.tokens[y][0]
|
||||||
return t.name == 'function'
|
return t.name == 'sh_function'
|
||||||
def _handle_close_token(self, currlvl, y, i):
|
def _handle_close_token(self, currlvl, y, i):
|
||||||
s = self.get_token(y, i).string
|
s = self.get_token(y, i).string
|
||||||
if s == ')' and self.markers and self._peek_name() == "case":
|
if s == ')' and self.markers and self._peek_name() == "case":
|
||||||
|
@ -95,7 +95,7 @@ class ShTabber(tab.StackTabber):
|
||||||
fqname = token.fqname()
|
fqname = token.fqname()
|
||||||
if token.name == 'continuation':
|
if token.name == 'continuation':
|
||||||
self._opt_append("cont", currlvl + 4)
|
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
|
currlvl -= 4
|
||||||
elif token.name == 'eol':
|
elif token.name == 'eol':
|
||||||
self._opt_pop("cont")
|
self._opt_pop("cont")
|
||||||
|
@ -109,15 +109,15 @@ class Sh(mode.Fundamental):
|
||||||
detection = ['sh', 'bash']
|
detection = ['sh', 'bash']
|
||||||
grammar = ShGrammar
|
grammar = ShGrammar
|
||||||
tabbercls = ShTabber
|
tabbercls = ShTabber
|
||||||
opentokens = ('delimiter', 'reserved', 'case.start')
|
opentokens = ('delimiter', 'sh_reserved', 'case.start')
|
||||||
opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', 'case': 'esac'}
|
opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', 'case': 'esac'}
|
||||||
closetokens = ('delimiter', 'reserved', 'case.end')
|
closetokens = ('delimiter', 'sh_reserved', 'case.end')
|
||||||
closetags = {')': '(', ']': '[', '}': '{',
|
closetags = {')': '(', ']': '[', '}': '{',
|
||||||
'done': 'do', 'fi': 'then', 'esac': 'case'}
|
'done': 'do', 'fi': 'then', 'esac': 'case'}
|
||||||
colors = {
|
colors = {
|
||||||
'builtin': ('cyan', 'default', 'bold'),
|
'sh_builtin': ('cyan', 'default', 'bold'),
|
||||||
'function': ('magenta', 'default', 'bold'),
|
'sh_function': ('magenta', 'default', 'bold'),
|
||||||
'reserved': ('magenta', 'default', 'bold'),
|
'sh_reserved': ('magenta', 'default', 'bold'),
|
||||||
'variable': ('yellow', 'default', 'bold'),
|
'variable': ('yellow', 'default', 'bold'),
|
||||||
|
|
||||||
# case statements
|
# case statements
|
||||||
|
@ -125,16 +125,16 @@ class Sh(mode.Fundamental):
|
||||||
'case.middle0': ('magenta', 'default', 'bold'),
|
'case.middle0': ('magenta', 'default', 'bold'),
|
||||||
'case.end': ('magenta', 'default', 'bold'),
|
'case.end': ('magenta', 'default', 'bold'),
|
||||||
|
|
||||||
'delimiter': ('default', 'default', 'bold'),
|
#'delimiter': ('default', 'default', 'bold'),
|
||||||
'test.start': ('cyan', 'default', 'bold'),
|
'test.start': ('cyan', 'default', 'bold'),
|
||||||
'binop': ('magenta', 'default', 'bold'),
|
'binop': ('magenta', 'default', 'bold'),
|
||||||
'unop': ('magenta', 'default', 'bold'),
|
'unop': ('magenta', 'default', 'bold'),
|
||||||
|
|
||||||
'string.start': ('green', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.variable': ('yellow', 'default'),
|
#'string.variable': ('yellow', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
|
|
||||||
'eval.start': ('cyan', 'default'),
|
'eval.start': ('cyan', 'default'),
|
||||||
'eval.variable': ('yellow', 'default'),
|
'eval.variable': ('yellow', 'default'),
|
||||||
|
@ -146,8 +146,8 @@ class Sh(mode.Fundamental):
|
||||||
'neval.null': ('cyan', 'default'),
|
'neval.null': ('cyan', 'default'),
|
||||||
'neval.end': ('yellow', 'default'),
|
'neval.end': ('yellow', 'default'),
|
||||||
|
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'continuation': ('red', 'default'),
|
#'continuation': ('red', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
66
mode/sql.py
66
mode/sql.py
|
@ -9,16 +9,16 @@ class PlPgSqlGrammar(Grammar):
|
||||||
PatternRule(r'delimiter', r':=|[():;,\.\[\]]'),
|
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'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'sql_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'sql_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'(?: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'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_])'),
|
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'builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![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'string', "''", StringGrammar, "''"),
|
||||||
RegionRule(r'quoted', '"', StringGrammar, '"'),
|
RegionRule(r'sql_quoted', '"', StringGrammar, '"'),
|
||||||
PatternRule(r'variable', r'\$[1-9][0-9]*'),
|
PatternRule(r'sql_variable', r'\$[1-9][0-9]*'),
|
||||||
PatternRule(r'bareword', r'[A-Za-z0-9_]+'),
|
PatternRule(r'sql_bareword', r'[A-Za-z0-9_]+'),
|
||||||
PatternRule(r'empty', r'^ *\n$'),
|
PatternRule(r'empty', r'^ *\n$'),
|
||||||
PatternRule(r'eol', r'\n'),
|
PatternRule(r'eol', r'\n'),
|
||||||
]
|
]
|
||||||
|
@ -30,13 +30,13 @@ class FunctionGrammar(Grammar):
|
||||||
PatternRule(r'delimiter', r':=|[():;,\.\$\[\]]'),
|
PatternRule(r'delimiter', r':=|[():;,\.\$\[\]]'),
|
||||||
|
|
||||||
PatternRule(r'name', r'[a-zA-Z_][a-zA-Z0-9_]*(?=\()'),
|
PatternRule(r'name', r'[a-zA-Z_][a-zA-Z0-9_]*(?=\()'),
|
||||||
NocasePatternRule(r'keyword', r'(?:as|returns|language)'),
|
NocasePatternRule(r'sql_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_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_]+'),
|
NocasePatternRule(r'language', r'(?<=language ) *[a-zA-Z_][a-zA-Z0-9_]+'),
|
||||||
|
|
||||||
RegionRule(r'definition', "'", PlPgSqlGrammar, "'(?!')"),
|
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'empty', r'^ *\n$'),
|
||||||
PatternRule(r'eol', r'\n'),
|
PatternRule(r'eol', r'\n'),
|
||||||
]
|
]
|
||||||
|
@ -51,14 +51,14 @@ class SqlGrammar(Grammar):
|
||||||
NocaseRegionRule(r'function', r'create or replace function', FunctionGrammar, r';'),
|
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'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'sql_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'(?: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'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_])'),
|
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'builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![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'string', "'", StringGrammar, "'"),
|
||||||
RegionRule(r'quoted', '"', StringGrammar, '"'),
|
RegionRule(r'sql_quoted', '"', StringGrammar, '"'),
|
||||||
PatternRule(r'bareword', r'[A-Za-z0-9_]+'),
|
PatternRule(r'sql_bareword', r'[A-Za-z0-9_]+'),
|
||||||
PatternRule(r'empty', r'^ *\n$'),
|
PatternRule(r'empty', r'^ *\n$'),
|
||||||
PatternRule(r'eol', r'\n'),
|
PatternRule(r'eol', r'\n'),
|
||||||
]
|
]
|
||||||
|
@ -78,7 +78,7 @@ class SqlTabber(tab.StackTabber):
|
||||||
s = token.string.lower()
|
s = token.string.lower()
|
||||||
if token.name == 'delimiter' and s == ';':
|
if token.name == 'delimiter' and s == ';':
|
||||||
self._opt_pop('cont')
|
self._opt_pop('cont')
|
||||||
elif token.name == 'keyword':
|
elif token.name == 'sql_keyword':
|
||||||
if s == 'declare':
|
if s == 'declare':
|
||||||
self._append('declare', currlvl + 4)
|
self._append('declare', currlvl + 4)
|
||||||
elif s == 'begin':
|
elif s == 'begin':
|
||||||
|
@ -116,21 +116,23 @@ class Sql(mode.Fundamental):
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {
|
colors = {
|
||||||
'comment': ('red', 'default'),
|
#'comment': ('red', 'default'),
|
||||||
'operator': ('yellow', 'default'),
|
'sql_operator': ('yellow', 'default'),
|
||||||
'attribute': ('magenta', 'default'),
|
'attribute': ('magenta', 'default'),
|
||||||
'keyword': ('cyan', 'default'),
|
'sql_keyword': ('cyan', 'default'),
|
||||||
'pseudokeyword': ('cyan', 'default'),
|
'pseudokeyword': ('cyan', 'default'),
|
||||||
'type': ('green', 'default'),
|
'sql_type': ('green', 'default'),
|
||||||
'builtin': ('yellow', 'default'),
|
'sql_builtin': ('yellow', 'default'),
|
||||||
'quoted': ('yellow', 'default'),
|
'sql_quoted.start': ('yellow', 'default'),
|
||||||
'string.start': ('green', 'default'),
|
'sql_quoted.null': ('yellow', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
'sql_quoted.end': ('yellow', 'default'),
|
||||||
'string.escaped': ('magenta', 'default'),
|
#'string.start': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
#'string.null': ('green', 'default'),
|
||||||
'string.end': ('green', 'default'),
|
#'string.escaped': ('magenta', 'default'),
|
||||||
'variable': ('yellow', 'default'),
|
#'string.octal': ('magenta', 'default'),
|
||||||
'bareword': ('default', 'default'),
|
#'string.end': ('green', 'default'),
|
||||||
|
'sql_variable': ('yellow', 'default'),
|
||||||
|
'sql_bareword': ('default', 'default'),
|
||||||
|
|
||||||
'function.start': ('cyan', 'default'),
|
'function.start': ('cyan', 'default'),
|
||||||
'function.null': ('default', 'default'),
|
'function.null': ('default', 'default'),
|
||||||
|
@ -139,7 +141,7 @@ class Sql(mode.Fundamental):
|
||||||
'function.end': ('default', 'default'),
|
'function.end': ('default', 'default'),
|
||||||
|
|
||||||
'function.definition.start': ('magenta', 'default'),
|
'function.definition.start': ('magenta', 'default'),
|
||||||
'function.definition.bareword': ('magenta', 'default'),
|
'function.definition.sql_bareword': ('magenta', 'default'),
|
||||||
'function.definition.null': ('magenta', 'default'),
|
'function.definition.null': ('magenta', 'default'),
|
||||||
'function.definition.end': ('magenta', 'default'),
|
'function.definition.end': ('magenta', 'default'),
|
||||||
}
|
}
|
||||||
|
|
12
mode/text.py
12
mode/text.py
|
@ -39,12 +39,12 @@ class Text(mode.Fundamental):
|
||||||
extensions=['.txt']
|
extensions=['.txt']
|
||||||
grammar = TextGrammar
|
grammar = TextGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'misspelled': ('red', 'default'),
|
#'misspelled': ('red', 'default'),
|
||||||
'cont.start': ('default', 'default'),
|
#'cont.start': ('default', 'default'),
|
||||||
'cont.end': ('default', 'default'),
|
#'cont.end': ('default', 'default'),
|
||||||
'word': ('default', 'default'),
|
#'word': ('default', 'default'),
|
||||||
'punct': ('default', 'default'),
|
#'punct': ('default', 'default'),
|
||||||
'stuff': ('default', 'default'),
|
#'stuff': ('default', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
|
@ -4,8 +4,8 @@ from mode.text import WordRule, ContinuedRule
|
||||||
|
|
||||||
class Text2Grammar(Grammar):
|
class Text2Grammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(name=r'email', pattern=r'(?:^|(?<=[ :]))<?[^<>@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'),
|
PatternRule(name=r'text2_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_url', pattern=r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'),
|
||||||
ContinuedRule(),
|
ContinuedRule(),
|
||||||
WordRule(),
|
WordRule(),
|
||||||
PatternRule(r'punct', r'[^a-zA-Z0-9_]'),
|
PatternRule(r'punct', r'[^a-zA-Z0-9_]'),
|
||||||
|
@ -18,14 +18,14 @@ class Text2(mode.text.Text):
|
||||||
extensions = ['.txt']
|
extensions = ['.txt']
|
||||||
extensions = []
|
extensions = []
|
||||||
colors = {
|
colors = {
|
||||||
'email': ('cyan', 'default'),
|
'text2_email': ('cyan', 'default'),
|
||||||
'url': ('green', 'default'),
|
'text2_url': ('green', 'default'),
|
||||||
'misspelled': ('red', 'default'),
|
#'misspelled': ('red', 'default'),
|
||||||
'cont.start': ('default', 'default'),
|
#'cont.start': ('default', 'default'),
|
||||||
'cont.end': ('default', 'default'),
|
#'cont.end': ('default', 'default'),
|
||||||
'word': ('default', 'default'),
|
#'word': ('default', 'default'),
|
||||||
'punct': ('default', 'default'),
|
#'punct': ('default', 'default'),
|
||||||
'stuff': ('default', 'default'),
|
#'stuff': ('default', 'default'),
|
||||||
}
|
}
|
||||||
|
|
||||||
install = Text2.install
|
install = Text2.install
|
||||||
|
|
24
mode/tt.py
24
mode/tt.py
|
@ -25,7 +25,7 @@ class TemplateGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
||||||
RegionRule(r'directive', r'\[\%', DirectiveGrammar, r'%%\]'),
|
RegionRule(r'directive', r'\[\%', DirectiveGrammar, r'%%\]'),
|
||||||
RegionRule(r'tag', r'</?', TagGrammar, r'/?>'),
|
RegionRule(r'tt_tag', r'</?', TagGrammar, r'/?>'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class Template(mode.Fundamental):
|
class Template(mode.Fundamental):
|
||||||
|
@ -33,9 +33,9 @@ class Template(mode.Fundamental):
|
||||||
extensions = ['.tt']
|
extensions = ['.tt']
|
||||||
grammar = TemplateGrammar
|
grammar = TemplateGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
|
|
||||||
'directive.start': ('magenta', 'default'),
|
'directive.start': ('magenta', 'default'),
|
||||||
'directive.comment': ('red', 'default'),
|
'directive.comment': ('red', 'default'),
|
||||||
|
@ -48,14 +48,14 @@ class Template(mode.Fundamental):
|
||||||
'directive.null': ('magenta', 'default'),
|
'directive.null': ('magenta', 'default'),
|
||||||
'directive.end': ('magenta', 'default'),
|
'directive.end': ('magenta', 'default'),
|
||||||
|
|
||||||
'tag.start': ('default', 'default'),
|
'tt_tag.start': ('default', 'default'),
|
||||||
'tag.namespace': ('magenta', 'default'),
|
'tt_tag.namespace': ('magenta', 'default'),
|
||||||
'tag.name': ('blue', 'default'),
|
'tt_tag.name': ('blue', 'default'),
|
||||||
'tag.attrname': ('cyan', 'default'),
|
'tt_tag.attrname': ('cyan', 'default'),
|
||||||
'tag.string.start': ('green', 'default'),
|
'tt_tag.string.start': ('green', 'default'),
|
||||||
'tag.string.null': ('green', 'default'),
|
'tt_tag.string.null': ('green', 'default'),
|
||||||
'tag.string.end': ('green', 'default'),
|
'tt_tag.string.end': ('green', 'default'),
|
||||||
'tag.end': ('default', 'default'),
|
'tt_tag.end': ('default', 'default'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
24
mode/xml.py
24
mode/xml.py
|
@ -14,7 +14,7 @@ class XMLGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
# TODO: how does cdata work again?
|
# TODO: how does cdata work again?
|
||||||
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
RegionRule(r'comment', r'<!--', Grammar, r'-->'),
|
||||||
RegionRule(r'tag', r'<', TagGrammar, r'/?>'),
|
RegionRule(r'xml_tag', r'<', TagGrammar, r'/?>'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class XML(mode.Fundamental):
|
class XML(mode.Fundamental):
|
||||||
|
@ -22,17 +22,17 @@ class XML(mode.Fundamental):
|
||||||
extensions = ['.xml', '.xml.in']
|
extensions = ['.xml', '.xml.in']
|
||||||
grammar = XMLGrammar
|
grammar = XMLGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'comment.start': ('red', 'default'),
|
#'comment.start': ('red', 'default'),
|
||||||
'comment.null': ('red', 'default'),
|
#'comment.null': ('red', 'default'),
|
||||||
'comment.end': ('red', 'default'),
|
#'comment.end': ('red', 'default'),
|
||||||
'tag.start': ('default', 'default'),
|
'xml_tag.start': ('default', 'default'),
|
||||||
'tag.namespace': ('magenta', 'default'),
|
'xml_tag.namespace': ('magenta', 'default'),
|
||||||
'tag.name': ('blue', 'default'),
|
'xml_tag.name': ('blue', 'default'),
|
||||||
'tag.attrname': ('cyan', 'default'),
|
'xml_tag.attrname': ('cyan', 'default'),
|
||||||
'tag.string.start': ('green', 'default'),
|
'xml_tag.string.start': ('green', 'default'),
|
||||||
'tag.string.null': ('green', 'default'),
|
'xml_tag.string.null': ('green', 'default'),
|
||||||
'tag.string.end': ('green', 'default'),
|
'xml_tag.string.end': ('green', 'default'),
|
||||||
'tag.end': ('default', 'default'),
|
'xml_tag.end': ('default', 'default'),
|
||||||
}
|
}
|
||||||
|
|
||||||
install = XML.install
|
install = XML.install
|
||||||
|
|
Loading…
Reference in New Issue