Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def consume_if2(self, token_type, *token_types):
  2. tokens = []
  3.  
  4. for first, second in pairwise(chain([token_type], token_types)):
  5. if self.match(first):
  6. tokens.append(self.current())
  7. else:
  8. return False, tokens
  9.  
  10. if self.match_next(second):
  11. self.advance()
  12. else:
  13. return False, tokens
  14. tokens.append(self.next())
  15. return True, tokens
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement