parent
e8f015574c
commit
028b58adc4
|
@ -19,15 +19,11 @@ class StringGrammar(Grammar):
|
||||||
class PythonGrammar(Grammar):
|
class PythonGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'import',
|
name=r'functiondef',
|
||||||
pattern=r'(?:^|(?<= ))import(?= |$)',
|
|
||||||
),
|
|
||||||
PatternRule(
|
|
||||||
name=r'methodname',
|
|
||||||
pattern=r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*',
|
pattern=r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'classname',
|
name=r'classdef',
|
||||||
pattern=r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*',
|
pattern=r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*',
|
||||||
),
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
|
@ -39,13 +35,18 @@ class PythonGrammar(Grammar):
|
||||||
pattern=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_])',
|
pattern=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(
|
PatternRule(
|
||||||
name=r"builtin_method",
|
name=r"builtin",
|
||||||
pattern=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_])',
|
pattern=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(
|
PatternRule(
|
||||||
name=r'bound_method',
|
name=r'methodcall',
|
||||||
pattern=r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
|
pattern=r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
|
||||||
),
|
),
|
||||||
|
PatternRule(
|
||||||
|
name=r'functioncall',
|
||||||
|
pattern=r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
|
||||||
|
),
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r'system_identifier',
|
name=r'system_identifier',
|
||||||
pattern=r'__[a-zA-Z0-9_]+__',
|
pattern=r'__[a-zA-Z0-9_]+__',
|
||||||
|
@ -70,6 +71,7 @@ class PythonGrammar(Grammar):
|
||||||
name=r"operator",
|
name=r"operator",
|
||||||
pattern=r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%",
|
pattern=r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%",
|
||||||
),
|
),
|
||||||
|
|
||||||
PatternRule(
|
PatternRule(
|
||||||
name=r"integer",
|
name=r"integer",
|
||||||
pattern=r"(?<![\.0-9a-zA-Z_])(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])",
|
pattern=r"(?<![\.0-9a-zA-Z_])(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])",
|
||||||
|
|
|
@ -26,11 +26,11 @@ class Python(mode2.Fundamental):
|
||||||
self.default_color = color.build('default', 'default')
|
self.default_color = color.build('default', 'default')
|
||||||
|
|
||||||
self.colors = {
|
self.colors = {
|
||||||
'keyword': color.build('cyan', 'default'),
|
'keyword': color.build('cyan', 'default'),
|
||||||
'reserved': color.build('cyan', 'default'),
|
'reserved': color.build('cyan', 'default'),
|
||||||
'builtin_method': color.build('cyan', 'default'),
|
'builtin': color.build('cyan', 'default'),
|
||||||
'methodname': color.build('blue', 'default'),
|
'functiondef': color.build('blue', 'default'),
|
||||||
'classname': color.build('green', 'default'),
|
'classdef': color.build('green', 'default'),
|
||||||
|
|
||||||
'string.start': color.build('green', 'default'),
|
'string.start': color.build('green', 'default'),
|
||||||
'string.null': color.build('green', 'default'),
|
'string.null': color.build('green', 'default'),
|
||||||
|
|
Loading…
Reference in New Issue