import re import sys import clint class catch_exception(clint.Rule): def initialize(self): self.pattern = re.compile(".*catch\W*\(.*? +(?P&?)\W*.*?\)") def pre_cpp(self,line): match = self.pattern.match(line) if match: if match.group('reference') != '&': self.message("Exception should be caught be reference") def finalize(self): pass if __name__ == "__main__": lineno=0 rule = macros() file = open(sys.argv[1]) for line in file.readlines(): lineno = lineno + 1 rule.parse(line)