import color, mode2 from lex3 import Grammar, PatternRule, RegionRule class HexGrammar(Grammar): rules = [ PatternRule(r'zero', r"00"), PatternRule(r'printable', r"[2-7][0-9a-f]"), PatternRule(r'byte', r'[0-f][0-f]'), ] class Hex(mode2.Fundamental): grammar = HexGrammar colors = { 'zero': ('magenta', 'default'), 'printable': ('green', 'default'), 'byte': ('white', 'default'), } def __init__(self, w): mode2.Fundamental.__init__(self, w) def name(self): return "Hex"