am a4f6d228: Merge "Add a method for replacing tokens in the preprocessed headers"

* commit 'a4f6d2281f979c013080e28b1f658c2ba9a8e9f3':
  Add a method for replacing tokens in the preprocessed headers
This commit is contained in:
David Turner 2010-12-22 11:29:30 -08:00 committed by Android Git Automerger
commit 4ad2f19f14

View File

@ -1863,6 +1863,16 @@ class BlockList:
tokens = tokens[:-1] # remove trailing tokLN
self.blocks = [ Block(tokens) ] + self.blocks
def replaceTokens(self,replacements=dict()):
"""replace tokens according to the given dict
"""
for b in self.blocks:
if not b.isDirective():
for tok in b.tokens:
if tok.id == tokIDENT:
if tok.value in replacements:
tok.value = replacements[tok.value]
class BlockParser:
"""a class used to convert an input source file into a BlockList object"""