Returns true if token is of the given type and, if a string is given, has that string.
549990
def match_token(token, tok_type, tok_str=None):
  """"""
  return token.type == tok_type and (tok_str is None or token.string == tok_str)
14242
public static boolean isValid(String token)
    {
        if (token == null || token.length() == 0)
        {
            return false;
        }

        int len = token.length();

        for (int i = 0; i < len; ++i)
        {
            if (isSeparator(token.charAt(i)))
            {
                return false;
            }
        }

        return true;
    }
926948
public static boolean hasCharset(String ctype)
    {
        if (ctype == null)
        {
            return false;
        }
        Matcher matcher = CHARSET_PATT.matcher(ctype);
        if (matcher.find())
        {
            return true;
        }
        else
        {
            return false;
        }
    }
427292
function isType(type, string) {
    if (isString(string) || isNumber(string)) {
        if (_regex.regex[type] && type !== 'default') {
            string = String(string);
            return _regex.regex[type].test(string);
        } else {
            throw Error('unknown type ' + type);
        }
    } else {
        throw Error('type should be string or number');
    }
}
940370
public static boolean hasViewer(String type) {
        return s_viewers.containsKey(type) || type.endsWith("+xml")
                && s_viewers.containsKey("text/xml");
    }
195659
public function lookaheadTypeIs(int $type): bool
    {
        return isset($this->tokens[$this->position]) && $this->tokens[$this->position]->typeEquals($type);
    }
1017638
def is_text_type(text):
    
    if isinstance(text, six.text_type) or isinstance(text, six.string_types):
        return True

    return False
1262378
static boolean isSimpleOperatorType(Token type) {
    switch (type) {
      case ADD:
      case BITAND:
      case BITNOT:
      case BITOR:
      case BITXOR:
      case COMMA:
      case DIV:
      case EQ:
      case EXPONENT:
      case GE:
      case GETELEM:
      case GETPROP:
      case GT:
      case IN:
      case INSTANCEOF:
      case LE:
      case LSH:
      case LT:
      case MOD:
      case MUL:
      case NE:
      case NOT:
      case RSH:
      case SHEQ:
      case SHNE:
      case SUB:
      case TYPEOF:
      case VOID:
      case POS:
      case NEG:
      case URSH:
        return true;

      default:
        return false;
    }
  }
691599
public static boolean isPrimitive(String type) {
        boolean isPrimitive = false;
        if ( "byte".equals( type ) || "char".equals( type ) || "double".equals( type ) || "float".equals( type ) || "int".equals( type ) || "long".equals( type ) || "short".equals( type ) || "boolean".equals( type ) || "void".equals( type ) ) {
            isPrimitive = true;
        }
        return isPrimitive;
    }
681729
public static boolean isPrimitiveLike(Type t)
  {
    if(isNumber(t)) {
      return true;
    }
    if(isBoolean(t)) {
      return true;
    }
    if(isEnum(t)) {
      return true;
    }
    if(isCharacter(t)) {
      return true;
    }
    if(isDate(t)) {
      return true;
    }
    if(t == String.class) {
      return true;
    }
    return false;
  }
512991
public boolean isMatched(AnalyzedToken token) {
    if (testWhitespace && !isWhitespaceBefore(token)) {
      return false;
    }
    boolean posNegation = posToken != null && posToken.negation;
    if (testString) {
      return isStringTokenMatched(token) ^ negation &&
             isPosTokenMatched(token) ^ posNegation;
    } else {
      return !negation &&
             isPosTokenMatched(token) ^ posNegation;
    }
  }
86588
private boolean tokenTextsDoNotMatch(Token token1, Token token2) {
        return !token1.getText().equals(token2.getText());
    }
237937
public static boolean isDCL(final TokenType primaryTokenType, final TokenType secondaryTokenType) {
        return STATEMENT_PREFIX.contains(primaryTokenType) || (PRIMARY_STATEMENT_PREFIX.contains(primaryTokenType) && SECONDARY_STATEMENT_PREFIX.contains(secondaryTokenType));
    }
573478
public boolean recordThisType(JSTypeExpression type) {
    if (type != null && !hasAnySingletonTypeTags() &&
        !currentInfo.hasThisType()) {
      currentInfo.setThisType(type);
      populated = true;
      return true;
    } else {
      return false;
    }
  }
413630
public function acceptToken($type, &$token = null)
    {
        $token = $this->peek();
        if (! isset($token[0]) or $token[0] != $type) {
            return false;
        }
        $this->pop();
        return true;
    }
37156
public boolean accepts(String type) {
        if (m_acceptsAll) {
            return true;
        }
        String[] parts = type.split("/");
        if (parts.length != 2) {
            return false;
        }
        for (String element : m_types) {
            if (element.equals(parts[0] + "/*") || element.equals(type)) {
                return true;
            }
        }
        return false;
    }
148624
def is_base_tuple(type_str):
    
    try:
        abi_type = grammar.parse(type_str)
    except exceptions.ParseError:
        return False

    return isinstance(abi_type, grammar.TupleType) and abi_type.arrlist is None