Asserts that the next token in the stream matches the specified token.

@param token expected token
@throws ParseException
2124
public void assertToken(final int token) throws ParseException {
    try {
      if (nextToken() != token) {
        throw new ParseException("Expected [" + token + "], read [" +
                                  ttype + "] at " + lineno());
      }

      if (debug()) {
        if (token > 0) {
          debug("[" + (char)token + "]");
        } else {
          debug("[" + token + "]");
        }
      }
    } catch (IOException e) {
      throw new ParseException(e);
    }
  }
1177951
protected void parseAttribute(Token token) {
        // TODO this is a monster copy/paste - would be nicer to fix in the underlying library! :)
        token.setType(Type.ATTRIBUTE);

        parseName("attribute");

        if (pos == token.getStartOffset())
            throw new XMLParseException("Expected attribute name", source, pos);

        skipWhiteSpace();
        expect('=');
        skipWhiteSpace();

        char c = 0;
        if (pos < source.length())
            c = source.charAt(pos);
        if (c != '\'' && c != '"')
            throw new XMLParseException("Expected single or double quotes", source, pos);

        char endChar = c;
        boolean insideEntity = false;
        int errorPos = pos;

        while (true) {
            pos++;
            if (pos >= source.length()) {
                int i = Math.min(20, source.length() - token.getStartOffset());
                throw new XMLParseException("Missing end quote (" + endChar + ") of attribute: "
                        + lookAheadForErrorMessage(null, token.getStartOffset(), i), token);
            }

            c = source.charAt(pos);
            if (c == endChar)
                break;

            if (c == '<')
                throw new XMLParseException("Illegal character in attribute value: '" + c + "'", source, pos);

            if (c == '&') {
                insideEntity = true;
                errorPos = pos;
            } else if (c == ';') {
                verifyEntity(errorPos, pos + 1);
                insideEntity = false;
            } else {
                String msg = charValidator.isValid(source, pos);
                if (msg != null)
                    throw new XMLParseException("Illegal character found in attribute value. " + msg, source, pos);

                skipChar(c);
                pos--;
            }
        }

        if (insideEntity) {
            throw new XMLParseException("Missing ';' after '&': " + lookAheadForErrorMessage(null, errorPos, 20), source, errorPos);
        }

        // Skip end-char
        pos++;
    }
1019751
private void parseToken(String token) {
        int len = token.length();

        for (int i = 0; i < len; i++) {
            int chr = sr.read();
            if (chr == -1) {
                throw new IllegalArgumentException("EOF reached while reading token: " + token);
            }
            chr = Character.toLowerCase((char)chr);
            int loTokenChar = token.charAt(i);

            if (loTokenChar != chr) {
                throw new IllegalArgumentException("Expected token: " + token + " at position " + sr.getPosition());
            }
        }
    }
150423
public void strain(Text line) throws ParseException {
        try {
            Iterator<Text> it = line.split('=').iterator();
            it.next();

            Text token = it.next();
            it = token.split(' ').iterator();

            name = it.next();
            name.trim();

            sessionID = it.next();
            sessionID.trim();

            sessionVersion = it.next();
            sessionVersion.trim();

            networkType = it.next();
            networkType.trim();

            addressType = it.next();
            addressType.trim();

            address = it.next();
            address.trim();
        } catch (Exception e) {
            throw new ParseException("Could not parse origin", 0);
        }
    }
7427
Token parseTerm() throws ParseException {
		int ch = this.read();
		Token tok = null;
		if (ch == T_OR || ch == T_RPAREN || ch == T_EOF) {
			tok = Token.createEmpty();
		} else {
			tok = this.parseFactor();
			Token concat = null;
			while ((ch = this.read()) != T_OR && ch != T_RPAREN && ch != T_EOF) {
				if (concat == null) {
					concat = Token.createConcat();
					concat.addChild(tok);
					tok = concat;
				}
				concat.addChild(this.parseFactor());
				// tok = Token.createConcat(tok, this.parseFactor());
			}
		}
		if (ch == T_RPAREN) {
			parenCount--;
		}
		return tok;
	}
1071778
public Token expect(@Nonnull String expected, @Nonnull TokenValidator validator) throws IOException {
        if (!hasNext()) {
            throw eof("Expected %s, got end of file", expected);
        } else if (validator.validate(unreadToken)) {
            lastToken = unreadToken;
            unreadToken = null;
            return lastToken;
        }
        throw failure(unreadToken, "Expected %s, but got '%s'", expected, Strings.escape(unreadToken.asString()));
    }
238946
private static boolean expect(StringTokenizer tokenizer, String token) {
        if (!tokenizer.hasMoreTokens()) {
            return false;
        }
        String s = tokenizer.nextToken();
        if (DEBUG) {
            System.out.println("token=" + s);
        }
        return s.equals(token);
    }
1100083
function expect(value) {
  var token = lex();
  if (token.type !== TokenPunctuator || token.value !== value) {
    throwUnexpected(token);
  }
}
237500
final public void Boolean() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TRUE:
      AstTrue jjtn001 = new AstTrue(JJTTRUE);
      boolean jjtc001 = true;
      jjtree.openNodeScope(jjtn001);
      try {
        jj_consume_token(TRUE);
      } finally {
      if (jjtc001) {
        jjtree.closeNodeScope(jjtn001, true);
      }
      }
      break;
    case FALSE:
        AstFalse jjtn002 = new AstFalse(JJTFALSE);
        boolean jjtc002 = true;
        jjtree.openNodeScope(jjtn002);
      try {
        jj_consume_token(FALSE);
      } finally {
        if (jjtc002) {
          jjtree.closeNodeScope(jjtn002, true);
        }
      }
      break;
    default:
      jj_la1[51] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }
189701
public boolean validateToken(final String token) {
        try {
            final JwtParser jwtParser = Jwts.parser().setSigningKey(key);
            jwtParser.parse(token);
            this.subject = jwtParser.parseClaimsJws(token).getBody().getSubject();
            this.expiration = jwtParser.parseClaimsJws(token).getBody().getExpiration();
            return true;
        } catch (SignatureException e) {
            LOGGER.info(SecurityMarkers.SECURITY_FAILURE, "Received token that did not pass signature verification");
        } catch (ExpiredJwtException e) {
            LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, "Received expired token");
        } catch (MalformedJwtException e) {
            LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, "Received malformed token");
            LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, e.getMessage());
        } catch (UnsupportedJwtException | IllegalArgumentException e) {
            LOGGER.error(SecurityMarkers.SECURITY_FAILURE, e.getMessage());
        }
        return false;
    }
724211
protected final Token consumeToken(Symbol expected) throws ScanException, ParseException {
		if (token.getSymbol() != expected) {
			fail(expected);
		}
		return consumeToken();
	}
1091794
private static String readToken(Buffer buffer) {
    try {
      long tokenSize = buffer.indexOfElement(TOKEN_DELIMITERS);
      if (tokenSize == -1L) tokenSize = buffer.size();

      return tokenSize != 0L
          ? buffer.readUtf8(tokenSize)
          : null;
    } catch (EOFException e) {
      throw new AssertionError();
    }
  }
1193887
final public void Literal() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TRUE:
    case FALSE:
      Boolean();
      break;
    case FLOATING_POINT_LITERAL:
      FloatingPoint();
      break;
    case INTEGER_LITERAL:
      Integer();
      break;
    case STRING_LITERAL:
      String();
      break;
    case NULL:
      Null();
      break;
    default:
      jj_la1[50] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }
313826
private void expect(JsonToken expected) throws IOException {
        peek();
        if (token != expected) {
            throw new IllegalStateException("Expected " + expected + " but was " + peek());
        }
        advance();
    }
1065116
public boolean isAndExceptionGroupMatched(AnalyzedToken token) {
    for (PatternToken testAndGroup : andGroupList) {
      if (testAndGroup.isExceptionMatched(token)) {
        return true;
      }
    }
    return false;
  }
22396
private void getLastToken(StreamTokenizer tokenizer, boolean endOfFileOk) throws IOException, ParseException {
        if ((tokenizer.nextToken() != StreamTokenizer.TT_EOL) && ((tokenizer.ttype != StreamTokenizer.TT_EOF) || !endOfFileOk)) {
            throw new ParseException("end of line expected", tokenizer.lineno());
        }
    }
671636
public void expect(final char expectedChar) throws ParseException {
        final int next = getc();
        if (next != expectedChar) {
            throw new ParseException(this, "Expected '" + expectedChar + "'; got '" + (char) next + "'");
        }
    }