示例#1
0
 def expand(self, values, previous):
     """
     Expand macro with actual values, returns a list of expanded tokens
     """
     tokens = []
     for token in self.tokens:
         if token.kind == IDENTIFIER and token.value in self.args:
             idx = self.args.index(token.value)
             value = values[idx]
             tokens += value
         else:
             tokens.append(token)
     return [Token(tok.kind, tok.value, add_previous(tok.location, previous)) for tok in tokens]
示例#2
0
文件: preprocess.py 项目: vmfox/vunit
 def expand(self, values, previous):
     """
     Expand macro with actual values, returns a list of expanded tokens
     """
     tokens = []
     for token in self.tokens:
         if token.kind == IDENTIFIER and token.value in self.args:
             idx = self.args.index(token.value)
             value = values[idx]
             tokens += value
         else:
             tokens.append(token)
     return [Token(tok.kind, tok.value, add_previous(tok.location, previous))
             for tok in tokens]