| <nonparenthesized value expression primary>
489446
Expression XreadValueExpressionPrimary() {

        Expression e;

        e = XreadSimpleValueExpressionPrimary();

        if (e != null) {
            return e;
        }

        if (token.tokenType == Tokens.OPENBRACKET) {
            read();

            e = XreadValueExpression();

            readThis(Tokens.CLOSEBRACKET);
        } else {
            return null;
        }

        return e;
    }
1130714
private Expression handleThisSuffix(Java7Parser.PrimaryContext primaryContext, AdapterParameters adapterParameters) {
        /*
            thisSuffix
            locals [int operationType]
                :   (LBRACKET expression RBRACKET)+                     {$operationType = 1;}
                |   arguments                                           {$operationType = 2;}
                |   DOT nonWildcardTypeArguments Identifier arguments   {$operationType = 3;}
                |   innerCreator                                        {$operationType = 4;}
                ;


        //this.m.m.m[].class;        // 0 :   (LBRACKET RBRACKET)+ DOT CLASS                      // ClassOrInterfaceType ClassOrInterfaceType ClassOrInterfaceType ReferenceType ClassExpr
        this.m.m.m[1];             // 1 |   (LBRACKET expression RBRACKET)+                     // NameExpr FieldAccessExpr FieldAccessExpr ArrayAccessExpr
        this.m.m.m("");            // 2 |   arguments                                           // NameExpr FieldAccessExpr MethodCallExpr
        //this.m.m.m.class;          // 3 |   DOT CLASS                                           // ClassOrInterfaceType ClassOrInterfaceType ClassOrInterfaceType ReferenceType ClassExpr
        this.m.m.<T>m("");         // 4 |   DOT nonWildcardTypeArguments Identifier arguments   // NameExpr FieldAccessExpr MethodCallExpr
        this.m.m.m.this;           // 5 |   DOT THIS                                            // NameExpr FieldAccessExpr FieldAccessExpr ThisExpr
        //m.m.super("");      // 6 |   DOT SUPER arguments

        */

        ThisExpr thisExpr = new ThisExpr();
        Expression leftExpression = thisExpr;

        for (int i = 0; i < primaryContext.Identifier().size(); i++) {
            FieldAccessExpr fieldAccessExpr = new FieldAccessExpr();
            fieldAccessExpr.setField(primaryContext.Identifier(i).getText());
            fieldAccessExpr.setScope(leftExpression);
            leftExpression = fieldAccessExpr;
        }

        // if thisSuffix is null/not specified
        if (primaryContext.thisSuffix() == null) {
            return leftExpression;
        }

        ClassOrInterfaceType rootType = new ClassOrInterfaceType();

        if (primaryContext.Identifier() != null && primaryContext.Identifier().size() > 0) {
            rootType.setName(primaryContext.Identifier(0).getText());
        }

        switch (primaryContext.thisSuffix().operationType) {
            case 1:
                for (int i = 0; i < primaryContext.thisSuffix().LBRACKET().size(); i++) {
                    ArrayAccessExpr arrayAccessExpr = new ArrayAccessExpr();
                    arrayAccessExpr.setName(leftExpression);
                    arrayAccessExpr.setIndex(Adapters.getExpressionContextAdapter().adapt(primaryContext.thisSuffix().expression(i), adapterParameters));
                    leftExpression = arrayAccessExpr;
                }

                return leftExpression;
            case 2:
                MethodCallExpr methodCallExpr = new MethodCallExpr();

                if (leftExpression instanceof FieldAccessExpr) {
                    methodCallExpr.setName(((FieldAccessExpr)leftExpression).getField());

                    // Set the leftExpression back one since we're changing the top one to a method call
                    leftExpression = ((FieldAccessExpr) leftExpression).getScope();
                    methodCallExpr.setScope(leftExpression);
                }

                if (methodCallExpr.getName() == null) {
                    throw new RuntimeException("Syntax Error: possibly calling 'this' as a method with arguments.  Something like 'this(\"\")'");
                }

                methodCallExpr.setArgs(Adapters.getArgumentsContextAdapter().adapt(primaryContext.thisSuffix().arguments(), adapterParameters));
                leftExpression = methodCallExpr;

                return leftExpression;
            case 3:
                List<Type> typeList = Adapters.getTypeListContextAdapter().adapt(primaryContext.thisSuffix().nonWildcardTypeArguments().typeList(), adapterParameters);

                MethodCallExpr typeArgMethodCallExpr = new MethodCallExpr();
                typeArgMethodCallExpr.setName(primaryContext.thisSuffix().Identifier().getText());
                typeArgMethodCallExpr.setTypeArgs(typeList);
                typeArgMethodCallExpr.setScope(leftExpression);
                typeArgMethodCallExpr.setArgs(Adapters.getArgumentsContextAdapter().adapt(primaryContext.thisSuffix().arguments(), adapterParameters));
                leftExpression = typeArgMethodCallExpr;

                return leftExpression;
            case 4:
                ObjectCreationExpr objectCreationExpr = Adapters.getInnerCreatorContextAdapter().adapt(primaryContext.thisSuffix().innerCreator(), adapterParameters);
                objectCreationExpr.setScope(leftExpression);
                return objectCreationExpr;
        }

        return null;
    }
202492
@Nullable
  private static Object convertPrimitiveField(Group g, int fieldIndex, boolean binaryAsString)
  {
    PrimitiveType pt = (PrimitiveType) g.getType().getFields().get(fieldIndex);
    if (pt.isRepetition(Type.Repetition.REPEATED) && g.getFieldRepetitionCount(fieldIndex) > 1) {
      List<Object> vals = new ArrayList<>();
      for (int i = 0; i < g.getFieldRepetitionCount(fieldIndex); i++) {
        vals.add(convertPrimitiveField(g, fieldIndex, i, binaryAsString));
      }
      return vals;
    }
    return convertPrimitiveField(g, fieldIndex, 0, binaryAsString);
  }
1193644
static BaseFloatColumnValueSelector makeColumnValueSelectorWithFloatDefault(
      final ColumnSelectorFactory metricFactory,
      final ExprMacroTable macroTable,
      @Nullable final String fieldName,
      @Nullable final String fieldExpression,
      final float nullValue
  )
  {
    if ((fieldName == null) == (fieldExpression == null)) {
      throw new IllegalArgumentException("");
    }
    if (fieldName != null) {
      return metricFactory.makeColumnValueSelector(fieldName);
    } else {
      final Expr expr = Parser.parse(fieldExpression, macroTable);
      final ColumnValueSelector<ExprEval> baseSelector = ExpressionSelectors.makeExprEvalSelector(metricFactory, expr);
      class ExpressionFloatColumnSelector implements FloatColumnSelector
      {
        @Override
        public float getFloat()
        {
          // Although baseSelector.getObject is nullable
          // exprEval returned from Expression selectors is never null.
          final ExprEval exprEval = baseSelector.getObject();
          return exprEval.isNumericNull() ? nullValue : (float) exprEval.asDouble();
        }

        @Override
        public void inspectRuntimeShape(RuntimeShapeInspector inspector)
        {
          inspector.visit("baseSelector", baseSelector);
        }

        @Override
        public boolean isNull()
        {
          final ExprEval exprEval = baseSelector.getObject();
          return exprEval == null || exprEval.isNumericNull();
        }
      }
      return new ExpressionFloatColumnSelector();
    }
  }
1296739
public final void ternaryExpression() throws RecognitionException {
		ParserRuleReturnScope ts =null;
		ParserRuleReturnScope fs =null;

		 ternOp++; 
		try {
			// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:175:5: ( QUESTION ts= expression COLON fs= expression )
			// src/main/resources/org/drools/compiler/lang/DRL5Expressions.g:175:7: QUESTION ts= expression COLON fs= expression
			{
			match(input,QUESTION,FOLLOW_QUESTION_in_ternaryExpression854); if (state.failed) return;
			pushFollow(FOLLOW_expression_in_ternaryExpression858);
			ts=expression();
			state._fsp--;
			if (state.failed) return;
			match(input,COLON,FOLLOW_COLON_in_ternaryExpression860); if (state.failed) return;
			pushFollow(FOLLOW_expression_in_ternaryExpression864);
			fs=expression();
			state._fsp--;
			if (state.failed) return;
			}

		}

		catch (RecognitionException re) {
		    throw re;
		}

		finally {
			// do for sure before leaving
			 ternOp--; 
		}
	}
742075
function expression(rbp, initial) {
    var left, isArray = false, isObject = false, isLetExpr = false;

    // if current expression is a let expression
    if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") {
      if (!state.option.inMoz(true)) {
        warning("W118", state.tokens.next, "let expressions");
      }
      isLetExpr = true;
      // create a new block scope we use only for the current expression
      funct["(blockscope)"].stack();
      advance("let");
      advance("(");
      state.syntax["let"].fud.call(state.syntax["let"].fud, false);
      advance(")");
    }

    if (state.tokens.next.id === "(end)")
      error("E006", state.tokens.curr);

    var isDangerous =
      state.option.asi &&
      state.tokens.prev.line < state.tokens.curr.line &&
      _.contains(["]", ")"], state.tokens.prev.id) &&
      _.contains(["[", "("], state.tokens.curr.id);

    if (isDangerous)
      warning("W014", state.tokens.curr, state.tokens.curr.id);

    advance();

    if (initial) {
      anonname = "anonymous";
      funct["(verb)"] = state.tokens.curr.value;
    }

    if (initial === true && state.tokens.curr.fud) {
      left = state.tokens.curr.fud();
    } else {
      if (state.tokens.curr.nud) {
        left = state.tokens.curr.nud();
      } else {
        error("E030", state.tokens.curr, state.tokens.curr.id);
      }

      while (rbp < state.tokens.next.lbp && !isEndOfExpr()) {
        isArray = state.tokens.curr.value === "Array";
        isObject = state.tokens.curr.value === "Object";

        // #527, new Foo.Array(), Foo.Array(), new Foo.Object(), Foo.Object()
        // Line breaks in IfStatement heads exist to satisfy the checkJSHint
        // "Line too long." error.
        if (left && (left.value || (left.first && left.first.value))) {
          // If the left.value is not "new", or the left.first.value is a "."
          // then safely assume that this is not "new Array()" and possibly
          // not "new Object()"...
          if (left.value !== "new" ||
            (left.first && left.first.value && left.first.value === ".")) {
            isArray = false;
            // ...In the case of Object, if the left.value and state.tokens.curr.value
            // are not equal, then safely assume that this not "new Object()"
            if (left.value !== state.tokens.curr.value) {
              isObject = false;
            }
          }
        }

        advance();

        if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
          warning("W009", state.tokens.curr);
        }

        if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
          warning("W010", state.tokens.curr);
        }

        if (left && state.tokens.curr.led) {
          left = state.tokens.curr.led(left);
        } else {
          error("E033", state.tokens.curr, state.tokens.curr.id);
        }
      }
    }
    if (isLetExpr) {
      funct["(blockscope)"].unstack();
    }
    return left;
  }
1097224
final public void NonLiteral() throws ParseException {
    if (jj_2_6(5)) {
      LambdaExpressionOrInvocation();
    } else {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LPAREN:
        jj_consume_token(LPAREN);
        Expression();
        jj_consume_token(RPAREN);
        break;
      default:
        jj_la1[39] = jj_gen;
        if (jj_2_7(2147483647)) {
          Function();
        } else {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case IDENTIFIER:
            Identifier();
            break;
          default:
            jj_la1[40] = jj_gen;
            if (jj_2_8(3)) {
              SetData();
            } else {
              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
              case LBRACK:
                ListData();
                break;
              case START_SET_OR_MAP:
                MapData();
                break;
              default:
                jj_la1[41] = jj_gen;
                jj_consume_token(-1);
                throw new ParseException();
              }
            }
          }
        }
      }
    }
  }
1179333
function parseUnaryExpression() {
        var token, expr;

        if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
            expr = parsePostfixExpression();
        } else if (match('+') || match('-') || match('!')) {
            token = lex();
            expr = parseUnaryExpression();
            expr = delegate.createUnaryExpression(token.value, expr);
        } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
            throwError({}, Messages.UnexpectedToken);
        } else {
            expr = parsePostfixExpression();
        }

        return expr;
    }
423313
final public Expression ValuePrefix() throws ParseException {
  Expression ret;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case INTEGER_LITERAL:
    case FLOATING_POINT_LITERAL:
    case STRING_LITERAL:
    case TRUE:
    case FALSE:
    case NULL:
      ret = Literal();
      break;
    case LPAREN:
      jj_consume_token(LPAREN);
      ret = Expression();
      jj_consume_token(RPAREN);
      break;
    default:
      jj_la1[27] = jj_gen;
      if (jj_2_1(2147483647)) {
        ret = FunctionInvocation();
      } else {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case IDENTIFIER:
          ret = NamedValue();
          break;
        default:
          jj_la1[28] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
    }
      {if (true) return ret;}
    throw new Error("Missing return statement in function");
  }
257678
private ParseTree parseCoverParenthesizedExpressionAndArrowParameterList() {
    if (peekType(1) == TokenType.FOR) {
      return parseGeneratorComprehension();
    }

    SourcePosition start = getTreeStartLocation();
    eat(TokenType.OPEN_PAREN);
    // Case ( )
    if (peek(TokenType.CLOSE_PAREN)) {
      eat(TokenType.CLOSE_PAREN);
      if (peek(TokenType.ARROW)) {
        return new FormalParameterListTree(getTreeLocation(start), ImmutableList.<ParseTree>of());
      } else {
        reportError("invalid parenthesized expression");
        return new MissingPrimaryExpressionTree(getTreeLocation(start));
      }
    }
    // Case ( ... BindingIdentifier )
    if (peek(TokenType.SPREAD)) {
      ImmutableList<ParseTree> params = ImmutableList.of(
          parseParameter(ParamContext.IMPLEMENTATION));
      eat(TokenType.CLOSE_PAREN);
      if (peek(TokenType.ARROW)) {
        return new FormalParameterListTree(getTreeLocation(start), params);
      } else {
        reportError("invalid parenthesized expression");
        return new MissingPrimaryExpressionTree(getTreeLocation(start));
      }
    }
    // For either of the two remaining cases:
    //     ( Expression )
    //     
    // we can parse as an expression.
    ParseTree result = parseExpression();
    // If it follows witha comma, we must be in the
    //     
    // case.
    if (peek(TokenType.COMMA)) {
      eat(TokenType.COMMA);
      // Since we already parsed as an expression, we will guaranteed reparse this expression
      // as an arrow function parameter list, but just leave it as a comma expression for now.
      result = new CommaExpressionTree(
          getTreeLocation(start),
          ImmutableList.of(result, parseParameter(ParamContext.IMPLEMENTATION)));
    }
    eat(TokenType.CLOSE_PAREN);
    return new ParenExpressionTree(getTreeLocation(start), result);
  }
652684
Expression XreadSimpleValueExpressionPrimary() {

        Expression e;

        e = XreadUnsignedValueSpecificationOrNull();

        if (e != null) {
            return e;
        }

        switch (token.tokenType) {

            case Tokens.OPENBRACKET :
                int position = getPosition();

                read();

                int subqueryPosition = getPosition();

                readOpenBrackets();

                switch (token.tokenType) {

                    case Tokens.TABLE :
                    case Tokens.VALUES :
                    case Tokens.SELECT :
                        SubQuery sq = null;

                        rewind(subqueryPosition);

                        try {
                            sq = XreadSubqueryBody(false,
                                                   OpTypes.SCALAR_SUBQUERY);

                            readThis(Tokens.CLOSEBRACKET);
                        } catch (HsqlException ex) {
                            compileContext.resetSubQueryLevel();
                            ex.setLevel(compileContext.subQueryDepth);

                            if (lastError == null
                                    || lastError.getLevel() < ex.getLevel()) {
                                lastError = ex;
                            }

                            rewind(position);

                            return null;
                        }

                        // A VoltDB extension to adapt to the hsqldb 2.3.2 change for fuller subquery support.
                        SubQuery td = sq;
                        // End of VoltDB extension
                        // BEGIN Cherry-picked code change from hsqldb-2.3.2
                        if (td.queryExpression.isSingleColumn()) {
                            e = new Expression(OpTypes.SCALAR_SUBQUERY, td);
                        } else {
                            e = new Expression(OpTypes.ROW_SUBQUERY, td);
                        }

                        return e;
                        /* Disable 5 lines ...
                        if (!sq.queryExpression.isSingleColumn()) {
                            throw Error.error(ErrorCode.W_01000);
                        }

                        return new Expression(OpTypes.SCALAR_SUBQUERY, sq);
                        ... disabled 5 lines. */
                        // END Cherry-picked code change from hsqldb-2.3.2

                    default :
                        rewind(position);

                        return null;
                }
            case Tokens.ASTERISK :
                e = new ExpressionColumn(token.namePrePrefix,
                                         token.namePrefix);

                recordExpressionForToken((ExpressionColumn) e);
                read();

                return e;

            case Tokens.CASEWHEN :
                return readCaseWhenExpression();

            case Tokens.CASE :
                return readCaseExpression();

            case Tokens.NULLIF :
                return readNullIfExpression();

            case Tokens.COALESCE :
            case Tokens.IFNULL :
                return readCoalesceExpression();

            case Tokens.CAST :
            case Tokens.CONVERT :
                return readCastExpression();

            case Tokens.DATE :
            case Tokens.TIME :
            case Tokens.TIMESTAMP :
            case Tokens.INTERVAL :
                e = readDateTimeIntervalLiteral();

                if (e != null) {
                    return e;
                }
                break;

            case Tokens.ANY :
            case Tokens.SOME :
            case Tokens.EVERY :
            case Tokens.COUNT :
            case Tokens.APPROX_COUNT_DISTINCT :
            case Tokens.MAX :
            case Tokens.MIN :
            case Tokens.SUM :
            case Tokens.AVG :
            case Tokens.STDDEV_POP :
            case Tokens.STDDEV_SAMP :
            case Tokens.VAR_POP :
            case Tokens.VAR_SAMP :
            case Tokens.RANK :
            case Tokens.DENSE_RANK:
            case Tokens.ROW_NUMBER:
                return readAggregate();

            case Tokens.NEXT :
                return readSequenceExpression();

            case Tokens.LEFT :
            case Tokens.RIGHT :
                // CLI function names
                break;


            default :
                if (isCoreReservedKey()) {
                    throw unexpectedToken();
                }
        }

        return readColumnOrFunctionExpression();
    }
312132
function optimiseMemberExpression(parent, offset) {
  if (offset === 0) return;

  var newExpr;
  var prop = parent.property;

  if (t.isLiteral(prop)) {
    prop.value += offset;
    prop.raw = String(prop.value);
  } else {
    // // UnaryExpression, BinaryExpression
    newExpr = t.binaryExpression("+", prop, t.literal(offset));
    parent.property = newExpr;
  }
}
1284948
function parseUnaryExpression() {
        var token, expr, startToken;

        if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
            expr = parsePostfixExpression();
        } else if (match('++') || match('--')) {
            startToken = lookahead;
            token = lex();
            expr = inheritCoverGrammar(parseUnaryExpression);
            // ECMA-262 11.4.4, 11.4.5
            if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
                tolerateError(Messages.StrictLHSPrefix);
            }

            if (!isAssignmentTarget) {
                tolerateError(Messages.InvalidLHSInAssignment);
            }
            expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
            isAssignmentTarget = isBindingElement = false;
        } else if (match('+') || match('-') || match('~') || match('!')) {
            startToken = lookahead;
            token = lex();
            expr = inheritCoverGrammar(parseUnaryExpression);
            expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
            isAssignmentTarget = isBindingElement = false;
        } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
            startToken = lookahead;
            token = lex();
            expr = inheritCoverGrammar(parseUnaryExpression);
            expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
            if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
                tolerateError(Messages.StrictDelete);
            }
            isAssignmentTarget = isBindingElement = false;
        } else {
            expr = parsePostfixExpression();
        }

        return expr;
    }
1000499
Expression XreadBooleanPrimaryOrNull() {

        Expression e = null;
        int        position;

        switch (token.tokenType) {

            case Tokens.EXISTS :
            case Tokens.UNIQUE :
                return XreadPredicate();

            case Tokens.ROW :
                read();
                readThis(Tokens.OPENBRACKET);

                e = XreadRowElementList(true);

                readThis(Tokens.CLOSEBRACKET);
                break;

            default :
                position = getPosition();

                try {
                    e = XreadAllTypesCommonValueExpression(false);
                } catch (HsqlException ex) {
                    ex.setLevel(compileContext.subQueryDepth);

                    if (lastError == null
                            || lastError.getLevel() < ex.getLevel()) {
                        lastError = ex;
                    }

                    rewind(position);
                }
        }

        if (e == null && token.tokenType == Tokens.OPENBRACKET) {
            read();

            position = getPosition();

            try {
                e = XreadRowElementList(true);

                readThis(Tokens.CLOSEBRACKET);
            } catch (HsqlException ex) {
                ex.setLevel(compileContext.subQueryDepth);

                if (lastError == null
                        || lastError.getLevel() < ex.getLevel()) {
                    lastError = ex;
                }

                rewind(position);

                e = XreadBooleanValueExpression();

                readThis(Tokens.CLOSEBRACKET);
            }
        }

        if (e != null) {
            e = XreadPredicateRightPart(e);
        }

        return e;
    }
1104900
long firstCEWithPrimaryAtLeast(long p) {
        if(p == 0) { return 0; }
        int index = findP(p);
        if(p != (elements[index] & 0xffffff00L)) {
            for(;;) {
                p = elements[++index];
                if((p & SEC_TER_DELTA_FLAG) == 0) {
                    // First primary after p. We must not be in a primary range.
                    assert((p & PRIMARY_STEP_MASK) == 0);
                    break;
                }
            }
        }
        // The code above guarantees that p has at most 3 bytes: (p & 0xff) == 0.
        return (p << 32) | Collation.COMMON_SEC_AND_TER_CE;
    }
855768
public void setPrimitive(Type type, int val) {
        if (type.hasValue()) {
            this.type = type;
            this.value = val;
            this.left = null;
            this.right = null;
            this.query = null;
        } else {
            throw new IllegalArgumentException("Value provided for non-value "
                                               + "expression type!");
        }
    }
845586
@Override
	public void visitIntegerLessThan(Expr.IntegerLessThan expr, Boolean consumed) {
		visitExpression(expr.getFirstOperand(),false);
		visitExpression(expr.getSecondOperand(),false);
	}