<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def match_token(token, tok_type, tok_str=None):
 """Returns true if token is of the given type and, if a string is given, has that string."""

  return token.type == tok_type and (tok_str is None or token.string == tok_str)