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

This commit is contained in:
David Turner 2010-12-20 02:43:26 -08:00 committed by Android Code Review
commit a4f6d2281f

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"""