branch : pmacs2
This commit is contained in:
moculus 2007-06-14 14:14:08 +00:00
parent e8f015574c
commit 028b58adc4
2 changed files with 15 additions and 13 deletions

View File

@ -19,15 +19,11 @@ class StringGrammar(Grammar):
class PythonGrammar(Grammar):
rules = [
PatternRule(
name=r'import',
pattern=r'(?:^|(?<= ))import(?= |$)',
),
PatternRule(
name=r'methodname',
name=r'functiondef',
pattern=r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*',
),
PatternRule(
name=r'classname',
name=r'classdef',
pattern=r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*',
),
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_])',
),
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_])',
),
PatternRule(
name=r'bound_method',
name=r'methodcall',
pattern=r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
),
PatternRule(
name=r'functioncall',
pattern=r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()',
),
PatternRule(
name=r'system_identifier',
pattern=r'__[a-zA-Z0-9_]+__',
@ -70,6 +71,7 @@ class PythonGrammar(Grammar):
name=r"operator",
pattern=r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%",
),
PatternRule(
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_])",

View File

@ -28,9 +28,9 @@ class Python(mode2.Fundamental):
self.colors = {
'keyword': color.build('cyan', 'default'),
'reserved': color.build('cyan', 'default'),
'builtin_method': color.build('cyan', 'default'),
'methodname': color.build('blue', 'default'),
'classname': color.build('green', 'default'),
'builtin': color.build('cyan', 'default'),
'functiondef': color.build('blue', 'default'),
'classdef': color.build('green', 'default'),
'string.start': color.build('green', 'default'),
'string.null': color.build('green', 'default'),