private ParseContext parseExpressions(Token[] tokens) throws InvalidQueryException {
    ParseContext ctx = new ParseContext(tokens);

    while (ctx.getCurrentTokensIndex() < tokens.length) {
      TOKEN_HANDLERS.get(tokens[ctx.getCurrentTokensIndex()].getType()).handleToken(ctx);
    }

    if (ctx.getPrecedenceLevel() != 0) {
      throw new InvalidQueryException("Invalid query string: mismatched parentheses.");
    }

    return ctx;
  }
Create parse context from an array of tokens. The parse context contains a list of expressions
and other information about the expressions an parsed tokens.

@param tokens  an array of tokens which represent the query,
               each token contains type and value information

@return a parse context which contains a list of expressions
@throws InvalidQueryException if unable to properly parse the tokens into a parse context
ambari-server/src/main/java/org/apache/ambari/server/api/predicate/QueryParser.java