import color, mode from lex import Grammar, PatternRule, RegionRule from mode.python import StringGrammar class ConsoleGrammar(Grammar): rules = [ PatternRule(r'mesg', r'^[A-Za-z].*$'), PatternRule(r'input', r'^>>>.*$'), PatternRule(r'input', r'^-->.*$'), #PatternRule(r'output', r'^ .*$'), RegionRule(r'py_string', r'"', StringGrammar, r'"'), RegionRule(r'py_string', r"'", StringGrammar, r"'"), PatternRule(r'bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'), ] class Console(mode.Fundamental): modename = 'Console' grammar = ConsoleGrammar() colors = { 'mesg': ('blue', 'default'), 'input': ('cyan', 'default'), 'output': ('default', 'default'), 'py_string.start': ('green', 'default'), 'py_string.octal': ('magenta', 'default'), 'py_string.escaped': ('magenta', 'default'), 'py_string.null': ('green', 'default'), 'py_string.end': ('green', 'default'), } install = Console.install