File: Synopsis/Processors/MacroFilter.py 1
2
3
4
5
6
7
8from Synopsis.Processor import *
9from Synopsis import ASG
10import re
11
12class MacroFilter(Processor, ASG.Visitor):
13 """A MacroFilter allows macros to be filtered, based on pattern matching.
14
15 Macros with matching names will be removed."""
16
17 pattern = Parameter('', 'Regular expression to match macro names with.')
18
19 def process(self, ir, **kwds):
20
21 self.set_parameters(kwds)
22 self._pattern = re.compile(self.pattern)
23 self.ir = self.merge_input(ir)
24
25 for decl in self.ir.asg.declarations[:]:
26 decl.accept(self)
27
28 return self.output_and_return_ir()
29
30 def visit_macro(self, node):
31
32 if self._pattern.match(node.name[-1]):
33
34 self.ir.asg.declarations.remove(node)
35
Generated on Thu Apr 16 16:27:13 2009 by
synopsis (version devel)