parent
a50a2b0d19
commit
4037fe17f3
|
@ -10,68 +10,68 @@ from method.shell import Exec
|
||||||
|
|
||||||
class StringGrammar1(Grammar):
|
class StringGrammar1(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
PatternRule('octal', r'\\[0-7]{3}'),
|
||||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||||
PatternRule(r'escaped', r'\\.'),
|
PatternRule('escaped', r'\\.'),
|
||||||
PatternRule(r'data', r"[^\\']+"),
|
PatternRule('data', r"[^\\']+"),
|
||||||
]
|
]
|
||||||
class StringGrammar2(Grammar):
|
class StringGrammar2(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
PatternRule('octal', r'\\[0-7]{3}'),
|
||||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||||
PatternRule(r'escaped', r'\\.'),
|
PatternRule('escaped', r'\\.'),
|
||||||
PatternRule(r'data', r'[^\\"]+'),
|
PatternRule('data', r'[^\\"]+'),
|
||||||
]
|
]
|
||||||
class StringGrammar3(Grammar):
|
class StringGrammar3(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
PatternRule('octal', r'\\[0-7]{3}'),
|
||||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||||
PatternRule(r'escaped', r'\\.'),
|
PatternRule('escaped', r'\\.'),
|
||||||
PatternRule(r'data', r"(?:[^\\']|'(?!')|''(?!'))+"),
|
PatternRule('data', r"(?:[^\\']|'(?!')|''(?!'))+"),
|
||||||
]
|
]
|
||||||
class StringGrammar4(Grammar):
|
class StringGrammar4(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
PatternRule('octal', r'\\[0-7]{3}'),
|
||||||
PatternRule(r'hex', r'\\x[0-9a-fA-F]{2}'),
|
PatternRule('hex', r'\\x[0-9a-fA-F]{2}'),
|
||||||
PatternRule(r'escaped', r'\\.'),
|
PatternRule('escaped', r'\\.'),
|
||||||
PatternRule(r'data', r'(?:[^\\"]|"(?!")|""(?!"))+'),
|
PatternRule('data', r'(?:[^\\"]|"(?!")|""(?!"))+'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class PythonGrammar(Grammar):
|
class PythonGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
PatternRule('functionname', '(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
PatternRule(r'classname', r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
PatternRule('classname', '(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
PatternRule(r'python.reserved', r'(?:True|None|False|Exception|self)(?![a-zA-Z0-9_])'),
|
PatternRule('python.reserved', '(?: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('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"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('methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||||
PatternRule(r'functioncall', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
PatternRule('functioncall', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||||
PatternRule(r'system_identifier', r'__[a-zA-Z0-9_]+__'),
|
PatternRule('system_identifier', '__[a-zA-Z0-9_]+__'),
|
||||||
PatternRule(r'private_identifier', r'__[a-zA-Z0-9_]*'),
|
PatternRule('private_identifier', '__[a-zA-Z0-9_]*'),
|
||||||
PatternRule(r'hidden_identifier', r'_[a-zA-Z0-9_]*'),
|
PatternRule('hidden_identifier', '_[a-zA-Z0-9_]*'),
|
||||||
|
|
||||||
RegionRule(r'rawstring', r'r"""', StringGrammar4, r'"""'),
|
RegionRule('rawstring', 'r"""', StringGrammar4, '"""'),
|
||||||
RegionRule(r'rawstring', r"r'''", StringGrammar3, r"'''"),
|
RegionRule('rawstring', "r'''", StringGrammar3, "'''"),
|
||||||
RegionRule(r'rawstring', r'r"', StringGrammar2, r'"'),
|
RegionRule('rawstring', 'r"', StringGrammar2, '"'),
|
||||||
RegionRule(r'rawstring', r"r'", StringGrammar1, r"'"),
|
RegionRule('rawstring', "r'", StringGrammar1, "'"),
|
||||||
RegionRule(r'string', r'u?"""', StringGrammar4, r'"""'),
|
RegionRule('string', 'u?"""', StringGrammar4, '"""'),
|
||||||
RegionRule(r'string', r"u?'''", StringGrammar3, r"'''"),
|
RegionRule('string', "u?'''", StringGrammar3, "'''"),
|
||||||
RegionRule(r'string', r'u?"', StringGrammar2, r'"'),
|
RegionRule('string', 'u?"', StringGrammar2, '"'),
|
||||||
RegionRule(r'string', r"u?'", StringGrammar1, r"'"),
|
RegionRule('string', "u?'", StringGrammar1, "'"),
|
||||||
|
|
||||||
PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
PatternRule('identifier', '[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
PatternRule(r'delimiter', r'\(|\)|\[|\]|{|}|@|,|:|\.|`|=|;|\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|>>=|<<=|\*\*='),
|
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"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"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"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"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
PatternRule(r"operator", r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
||||||
|
|
||||||
OverridePatternRule(r'comment', r'#@@:(?P<token>[.a-zA-Z0-9_]+):(?P<mode>[.a-zA-Z0-9_]+) *$'),
|
OverridePatternRule('comment', '#@@:(?P<token>[.a-zA-Z0-9_]+):(?P<mode>[.a-zA-Z0-9_]+) *$'),
|
||||||
PatternRule(r'comment', r'#.*$'),
|
PatternRule('comment', '#.*$'),
|
||||||
PatternRule(r'continuation', r'\\\n$'),
|
PatternRule('continuation', r'\\\n$'),
|
||||||
PatternRule(r'spaces', r' +'),
|
PatternRule('spaces', ' +'),
|
||||||
PatternRule(r'eol', r'\n$'),
|
PatternRule('eol', r'\n$'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class PythonTabber(tab.StackTabber):
|
class PythonTabber(tab.StackTabber):
|
||||||
|
|
Loading…
Reference in New Issue