import color, mode2 from point2 import Point from lex3 import Grammar, PatternRule, RegionRule class MetadataGrammar(Grammar): rules = [ PatternRule(r'username', r'[a-zA-Z0-9_]+'), ] class BlameGrammar(Grammar): rules = [ RegionRule(r'metadata', r'^[0-9\.]+', MetadataGrammar, r'[0-9]{4}-[0-9]{2}-[0-9]{2}'), PatternRule(r'data', r'.+$'), ] class Blame(mode2.Fundamental): grammar = BlameGrammar def __init__(self, w): mode2.Fundamental.__init__(self, w) self.colors = { 'metadata.start': color.build('blue', 'default', 'bold'), 'metadata.username': color.build('cyan', 'default', 'bold'), 'metadata.end': color.build('green', 'default', 'bold'), } def name(self): return "Blame"