@Override
    public void _handleToken(String token, ScanContext ctx) throws InvalidQueryException {
      if (token.equals(")")) {
        ctx.decrementBracketScore(1);
      } else if (token.endsWith("(")) {
        // .endsWith() is used because of tokens ".matches(",".in(" and".isEmpty("
        ctx.incrementBracketScore(1);
      }

      String tokenValue = token;
      if (ctx.getBracketScore() > 0) {
        Deque<Token> intermediateTokens = ctx.getIntermediateTokens();
        if (intermediateTokens !=null && !intermediateTokens.isEmpty()) {
          Token lastToken = intermediateTokens.peek();
          if (lastToken.getType() == Token.TYPE.VALUE_OPERAND) {
            intermediateTokens.pop();
            tokenValue = lastToken.getValue() + token;
          }
        }
        ctx.pushIntermediateToken(new Token(Token.TYPE.VALUE_OPERAND, tokenValue));
      }

      if (ctx.getBracketScore() == 0) {
        ctx.addIntermediateTokens();
        ctx.addToken(new Token(Token.TYPE.BRACKET_CLOSE, ")"));
      }
    }
Complex Value Operand token handler.
Supports values that span multiple tokens.
ambari-server/src/main/java/org/apache/ambari/server/api/predicate/QueryLexer.java