import color, mode2 from lex3 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'string', r'"', StringGrammar, r'"'), RegionRule(r'string', r"'", StringGrammar, r"'"), PatternRule(r'bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'), ] class Console(mode2.Fundamental): grammar = ConsoleGrammar() colors = { 'mesg': ('blue', 'default'), 'input': ('cyan', 'default'), 'output': ('default', 'default'), 'string.start': ('green', 'default'), 'string.octal': ('magenta', 'default'), 'string.escaped': ('magenta', 'default'), 'string.null': ('green', 'default'), 'string.end': ('green', 'default'), } def name(self): return "Console"