code: def PyParseIntCast(string, location, tokens):
    
    # Cast the regular tokens.
    for index, token in enumerate(tokens):
      try:
        tokens[index] = int(token)
      except ValueError:
        logger.error('Unable to cast [{0:s}] to an int, setting to 0'.format(
            token))
        tokens[index] = 0
  
    # We also need to cast the dictionary built tokens.
    for key in tokens.keys():
      try:
        tokens[key] = int(tokens[key], 10)
      except ValueError:
        logger.error(
            'Unable to cast [{0:s} = {1:d}] to an int, setting to 0'.format(
                key, tokens[key]))
        tokens[key] = 0
docs: Return an integer from a string.
  
    This is a pyparsing callback method that converts the matched
    string into an integer.
  
    The method modifies the content of the tokens list and converts
    them all to an integer value.
  
    Args:
      string (str): original string.
      location (int): location in the string where the match was made.
      tokens (list[str]): extracted tokens, where the string to be converted
          is stored.