parent
a50a2b0d19
commit
4037fe17f3
|
@ -10,68 +10,68 @@ from method.shell import Exec
|
|||
|
||||
class StringGrammar1(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule(r'escaped', r'\\.'),
|
||||
PatternRule(r'data', r"[^\\']+"),
|
||||
PatternRule('octal', r'\\[0-7]{3}'),
|
||||
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule('escaped', r'\\.'),
|
||||
PatternRule('data', r"[^\\']+"),
|
||||
]
|
||||
class StringGrammar2(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule(r'escaped', r'\\.'),
|
||||
PatternRule(r'data', r'[^\\"]+'),
|
||||
PatternRule('octal', r'\\[0-7]{3}'),
|
||||
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule('escaped', r'\\.'),
|
||||
PatternRule('data', r'[^\\"]+'),
|
||||
]
|
||||
class StringGrammar3(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule(r'escaped', r'\\.'),
|
||||
PatternRule(r'data', r"(?:[^\\']|'(?!')|''(?!'))+"),
|
||||
PatternRule('octal', r'\\[0-7]{3}'),
|
||||
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule('escaped', r'\\.'),
|
||||
PatternRule('data', r"(?:[^\\']|'(?!')|''(?!'))+"),
|
||||
]
|
||||
class StringGrammar4(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule(r'escaped', r'\\.'),
|
||||
PatternRule(r'data', r'(?:[^\\"]|"(?!")|""(?!"))+'),
|
||||
PatternRule('octal', r'\\[0-7]{3}'),
|
||||
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||
PatternRule('escaped', r'\\.'),
|
||||
PatternRule('data', r'(?:[^\\"]|"(?!")|""(?!"))+'),
|
||||
]
|
||||
|
||||
class PythonGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule(r'classname', r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule(r'python.reserved', r'(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'),
|
||||
PatternRule(r'python.keyword', r'(?:yield|with|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('functionname', '(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule('classname', '(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule('python.reserved', '(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'),
|
||||
PatternRule('python.keyword', '(?:yield|with|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])'),
|
||||
PatternRule(r"python.builtin", r'(?<!\.)(?:zip|xrange|vars|unicode|unichr|type|tuple|super|sum|str|staticmethod|sorted|slice|setattr|set|round|repr|reduce|raw_input|range|property|pow|ord|open|oct|object|max|min|map|long|locals|list|len|iter|issubclass|isinstance|int|input|id|hex|hash|hasattr|globals|getattr|frozenset|float|filter|file|execfile|eval|enumerate|divmod|dir|dict|delattr|complex|compile|coerce|cmp|classmethod|chr|callable|bool)(?![a-zA-Z0-9_])'),
|
||||
PatternRule(r'methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||
PatternRule(r'functioncall', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||
PatternRule(r'system_identifier', r'__[a-zA-Z0-9_]+__'),
|
||||
PatternRule(r'private_identifier', r'__[a-zA-Z0-9_]*'),
|
||||
PatternRule(r'hidden_identifier', r'_[a-zA-Z0-9_]*'),
|
||||
PatternRule('methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||
PatternRule('functioncall', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||
PatternRule('system_identifier', '__[a-zA-Z0-9_]+__'),
|
||||
PatternRule('private_identifier', '__[a-zA-Z0-9_]*'),
|
||||
PatternRule('hidden_identifier', '_[a-zA-Z0-9_]*'),
|
||||
|
||||
RegionRule(r'rawstring', r'r"""', StringGrammar4, r'"""'),
|
||||
RegionRule(r'rawstring', r"r'''", StringGrammar3, r"'''"),
|
||||
RegionRule(r'rawstring', r'r"', StringGrammar2, r'"'),
|
||||
RegionRule(r'rawstring', r"r'", StringGrammar1, r"'"),
|
||||
RegionRule(r'string', r'u?"""', StringGrammar4, r'"""'),
|
||||
RegionRule(r'string', r"u?'''", StringGrammar3, r"'''"),
|
||||
RegionRule(r'string', r'u?"', StringGrammar2, r'"'),
|
||||
RegionRule(r'string', r"u?'", StringGrammar1, r"'"),
|
||||
RegionRule('rawstring', 'r"""', StringGrammar4, '"""'),
|
||||
RegionRule('rawstring', "r'''", StringGrammar3, "'''"),
|
||||
RegionRule('rawstring', 'r"', StringGrammar2, '"'),
|
||||
RegionRule('rawstring', "r'", StringGrammar1, "'"),
|
||||
RegionRule('string', 'u?"""', StringGrammar4, '"""'),
|
||||
RegionRule('string', "u?'''", StringGrammar3, "'''"),
|
||||
RegionRule('string', 'u?"', StringGrammar2, '"'),
|
||||
RegionRule('string', "u?'", StringGrammar1, "'"),
|
||||
|
||||
PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule(r'delimiter', r'\(|\)|\[|\]|{|}|@|,|:|\.|`|=|;|\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|>>=|<<=|\*\*='),
|
||||
PatternRule('identifier', '[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule('delimiter', r'\(|\)|\[|\]|{|}|@|,|:|\.|`|=|;|\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|>>=|<<=|\*\*='),
|
||||
PatternRule(r"integer", r"(?<![\.0-9a-zA-Z_])(?:0|-?[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])"),
|
||||
PatternRule(r"float", r"(?<![\.0-9a-zA-Z_])(?:-?[0-9]+\.[0-9]*|-?\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|-?\.[0-9]+)[eE][\+-]?[0-9]+)(?![\.0-9a-zA-Z_])"),
|
||||
PatternRule(r"imaginary", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+|(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)[jJ])(?![\.0-9a-zA-Z_])"),
|
||||
|
||||
PatternRule(r"operator", r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
||||
|
||||
OverridePatternRule(r'comment', r'#@@:(?P<token>[.a-zA-Z0-9_]+):(?P<mode>[.a-zA-Z0-9_]+) *$'),
|
||||
PatternRule(r'comment', r'#.*$'),
|
||||
PatternRule(r'continuation', r'\\\n$'),
|
||||
PatternRule(r'spaces', r' +'),
|
||||
PatternRule(r'eol', r'\n$'),
|
||||
OverridePatternRule('comment', '#@@:(?P<token>[.a-zA-Z0-9_]+):(?P<mode>[.a-zA-Z0-9_]+) *$'),
|
||||
PatternRule('comment', '#.*$'),
|
||||
PatternRule('continuation', r'\\\n$'),
|
||||
PatternRule('spaces', ' +'),
|
||||
PatternRule('eol', r'\n$'),
|
||||
]
|
||||
|
||||
class PythonTabber(tab.StackTabber):
|
||||
|
|
Loading…
Reference in New Issue