Esempio n. 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]
Esempio n. 2
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]