Returns an Expression that evaluates this statement followed by the given expression.
6858
final Expression then(final Expression expression) {
    return new Expression(expression.resultType(), expression.features()) {
      @Override
      protected void doGen(CodeBuilder adapter) {
        Statement.this.gen(adapter);
        expression.gen(adapter);
      }
    };
  }
124219
public String resolveExpression(String expression) {
        StringBuilder result = new StringBuilder(expression.length());

        int position = 0;
        while (position < expression.length()) {
            char c = expression.charAt(position);
            if (c == '#') {
                int beginningSeparatorPosition = position;
                int endingSeparatorPosition = expression.indexOf('#', beginningSeparatorPosition + 1);
                if (endingSeparatorPosition == -1) {
                    throw new IllegalStateException("Invalid expression '" + expression + "', no ending '#' after beginning '#' at position " + beginningSeparatorPosition);
                }
                String key = expression.substring(beginningSeparatorPosition + 1, endingSeparatorPosition);
                Callable<String> expressionProcessor = expressionEvaluators.get(key);
                String value;
                if (expressionProcessor == null) {
                    value = "#unsupported_expression#";
                    logger.info("Unsupported expression '" + key + "'");
                } else {
                    try {
                        value = expressionProcessor.call();
                    } catch (Exception e) {
                        value = "#expression_error#";
                        logger.warn("Error evaluating expression '" + key + "'", e);
                    }
                }
                appendEscapedNonAlphaNumericChars(value, false, result);
                position = endingSeparatorPosition + 1;

            } else {
                result.append(c);
                position++;
            }
        }
        logger.trace("resolveExpression({}): {}", expression, result);
        return result.toString();

    }
294451
function evaluate(expr) {
            if (expr.substring(0, 2) === '==') {
                return 'write(JSON.stringify('+expr.substring(2).trim()+'));\n';
            } else if (expr.substring(0, 1) === '=') {
                return 'write('+expr.substring(1).trim()+');\n';
            } else if (expr.substring(0, 3) === '...') {
                expr = '//...\n'+expr.substring(3).trim()+'\n//.';
            }
            if (expr !== '') {
                return expr+'\n';
            }
            return '';
        }
986222
def evaluate_expression(self, expression, context, strategy=EvaluationStrategy.COMPLETE):
        
        from .gen.ExcellentLexer import ExcellentLexer
        from .gen.ExcellentParser import ExcellentParser

        stream = InputStream(expression)
        lexer = ExcellentLexer(stream)
        tokens = CommonTokenStream(lexer)

        parser = ExcellentParser(tokens)
        parser._errHandler = BailErrorStrategy()

        try:
            tree = parser.parse()

            if logger.isEnabledFor(logging.DEBUG):
                logger.debug("Expression '%s' parsed as %s" % (expression, tree.toStringTree()))
        except ParseCancellationException as ex:
            message = None
            if ex.args and isinstance(ex.args[0], NoViableAltException):
                token = ex.args[0].offendingToken
                if token is not None and token.type != ExcellentParser.EOF:
                    message = "Expression error at: %s" % token.text

            if message is None:
                message = "Expression is invalid"

            raise EvaluationError(message, ex)

        if strategy == EvaluationStrategy.RESOLVE_AVAILABLE:
            resolved = self._resolve_available(tokens, context)
            if resolved is not None:
                return resolved

        visitor = ExcellentVisitor(self._function_manager, context)
        return visitor.visit(tree)
380892
function resolveExpression(expression) {
    // return empty string for undefined
    if (expression === undefined) {
        return "";
    }
    // return placeholder for promise
    if (isPromise(expression)) {
        // recursively resolve
        return "[promise]";
    }
    // return placeholder for function
    if (typeof expression === "function") {
        return "[function]";
    }
    // handle arrays
    if (Array.isArray(expression)) {
        var items = [];
        // resolve each item (might be promises as well)
        for (var _i = 0, expression_1 = expression; _i < expression_1.length; _i++) {
            var expressionItem = expression_1[_i];
            items.push(resolveExpression(expressionItem));
        }
        // join with newline
        return items.join("\n");
    }
    // return unmodified if got a string
    if (typeof expression === "string") {
        return expression;
    }
    // convert to string if got a number
    if (typeof expression === "number") {
        return expression.toString();
    }
    // return stringified value, handles circular references
    return flatted_1.stringify(expression, undefined, 2);
}
1203672
public static Expression position(Expression expression, String substring) {
        return x("POSITION(" + expression.toString() + ", \"" + substring + "\")");
    }
1070558
private Object evaluateRoleExpression(ActionBean bean, String expression)
	{
		try
		{
			LOG.debug("Evaluating expression: '" + expression + '\'');

			// This is somewhat of a hack until the ExpressionEvaluator becomes more accessible.
			ParameterName name = new ParameterName("security");
			List<Object> values = new ArrayList<Object>();
			values.add(null);
			ValidationMetadata metadata = new ValidationMetadata("security").expression(expression);
			ValidationErrors errors = new ValidationErrors();

			ExpressionValidator.evaluate(bean, name, values, metadata, errors);

			return errors.isEmpty();
		}
		catch (Exception exc)
		{
			throw new StripesRuntimeException(exc);
		}
	}
1239840
def evaluate_impl(expression, params=None):
    ''''''

    which = expression.which()

    if which == 'literal':
        return capnp.Promise(expression.literal)
    elif which == 'previousResult':
        return read_value(expression.previousResult)
    elif which == 'parameter':
        assert expression.parameter < len(params)
        return capnp.Promise(params[expression.parameter])
    elif which == 'call':
        call = expression.call
        func = call.function

        # Evaluate each parameter.
        paramPromises = [evaluate_impl(param, params) for param in call.params]

        joinedParams = capnp.join_promises(paramPromises)
        # When the parameters are complete, call the function.
        ret = (joinedParams
               .then(lambda vals: func.call(vals))
               .then(lambda result: result.value))

        return ret
    else:
        raise ValueError("Unknown expression type: " + which)
477807
private Expression parseComparisonExpression() {
    Token token = tokens.lookahead();
    Expression expr;
    switch (token.type) {
      case EQUAL:
        tokens.consume();
        expr = new Equal(parseVersion());
        break;
      case NOT_EQUAL:
        tokens.consume();
        expr = new NotEqual(parseVersion());
        break;
      case GREATER:
        tokens.consume();
        expr = new Greater(parseVersion());
        break;
      case GREATER_EQUAL:
        tokens.consume();
        expr = new GreaterOrEqual(parseVersion());
        break;
      case LESS:
        tokens.consume();
        expr = new Less(parseVersion());
        break;
      case LESS_EQUAL:
        tokens.consume();
        expr = new LessOrEqual(parseVersion());
        break;
      default:
        expr = new Equal(parseVersion());
    }
    return expr;
  }
598543
public Object resolveExpression(String expression) {
    if (StringUtils.isBlank(expression)) {
      return null;
    }

    interpreter.getContext().addResolvedExpression(expression.trim());

    try {
      String elExpression = EXPRESSION_START_TOKEN + expression.trim() + EXPRESSION_END_TOKEN;
      ValueExpression valueExp = expressionFactory.createValueExpression(elContext, elExpression, Object.class);
      Object result = valueExp.getValue(elContext);

      validateResult(result);

      return result;

    } catch (PropertyNotFoundException e) {
      interpreter.addError(new TemplateError(ErrorType.WARNING, ErrorReason.UNKNOWN, ErrorItem.PROPERTY, e.getMessage(), "", interpreter.getLineNumber(), interpreter.getPosition(), e,
          BasicTemplateErrorCategory.UNKNOWN, ImmutableMap.of("exception", e.getMessage())));
    } catch (TreeBuilderException e) {
      int position = interpreter.getPosition() + e.getPosition();
      // replacing the position in the string like this isn't great, but JUEL's parser does not allow passing in a starting position
      String errorMessage = StringUtils.substringAfter(e.getMessage(), "': ").replaceFirst("position [0-9]+", "position " + position);
      interpreter.addError(TemplateError.fromException(new TemplateSyntaxException(expression.substring(e.getPosition() - EXPRESSION_START_TOKEN.length()),
          "Error parsing '" + expression + "': " + errorMessage, interpreter.getLineNumber(), position, e)));
    }
    catch (ELException e) {
      if (e.getCause() != null && e.getCause() instanceof DeferredValueException) {
        throw (DeferredValueException) e.getCause();
      }
      if (e.getCause() != null && e.getCause() instanceof TemplateSyntaxException) {
        interpreter.addError(TemplateError.fromException((TemplateSyntaxException) e.getCause()));
      }
      else if (e.getCause() != null && e.getCause() instanceof InvalidInputException) {
        interpreter.addError(TemplateError.fromInvalidInputException((InvalidInputException) e.getCause()));
      }
      else if (e.getCause() != null && e.getCause() instanceof InvalidArgumentException) {
        interpreter.addError(TemplateError.fromInvalidArgumentException((InvalidArgumentException) e.getCause()));
      }
      else {
        interpreter.addError(TemplateError.fromException(new TemplateSyntaxException(expression, e.getMessage(), interpreter.getLineNumber(), e)));
      }
    }
    catch (DisabledException e) {
      interpreter.addError(new TemplateError(ErrorType.FATAL, ErrorReason.DISABLED, ErrorItem.FUNCTION, e.getMessage(), expression, interpreter.getLineNumber(), interpreter.getPosition(), e));
    } catch (UnknownTokenException e) {
      // Re-throw the exception because you only get this when the config failOnUnknownTokens is enabled.
      throw e;
    } catch (DeferredValueException e) {
      // Re-throw so that it can be handled in JinjavaInterpreter
      throw e;
    } catch (InvalidInputException e) {
      interpreter.addError(TemplateError.fromInvalidInputException(e));
    } catch (InvalidArgumentException e) {
      interpreter.addError(TemplateError.fromInvalidArgumentException(e));
    } catch (Exception e) {
      interpreter.addError(TemplateError.fromException(new InterpretException(
          String.format("Error resolving expression [%s]: " + getRootCauseMessage(e), expression), e, interpreter.getLineNumber(), interpreter.getPosition())));
    }

    return null;
  }
363992
def eval_expression(value):
    
    start = eval_function(value.ts_expression[0])
    interval = eval_interval(value.ts_expression[2])
    op = value.ts_expression[1]
    if op == "+":
        return start + interval
    elif op == "-":
        return start - interval
    else:
        raise SyntaxError("Unrecognized operator %r" % op)
885073
private CompositeExpression parseMoreExpressions(CompositeExpression expr) {
        if (tokens.positiveLookahead(AND)) {
            tokens.consume();
            expr = expr.and(parseSemVerExpression());
        } else if (tokens.positiveLookahead(OR)) {
            tokens.consume();
            expr = expr.or(parseSemVerExpression());
        }
        return expr;
    }
499821
private ExpressionStatementTree parseExpressionStatement() {
    SourcePosition start = getTreeStartLocation();
    ParseTree expression = parseExpression();
    eatPossibleImplicitSemiColon();
    return new ExpressionStatementTree(getTreeLocation(start), expression);
  }
518014
def evaluate(self):
        

        try:
            self.condition = self.terms.prune(ConditionBinOp)
        except AttributeError:
            raise ValueError("cannot process expression [{expr}], [{slf}] "
                             "is not a valid condition".format(expr=self.expr,
                                                               slf=self))
        try:
            self.filter = self.terms.prune(FilterBinOp)
        except AttributeError:
            raise ValueError("cannot process expression [{expr}], [{slf}] "
                             "is not a valid filter".format(expr=self.expr,
                                                            slf=self))

        return self.condition, self.filter
362596
private static Expression getExpression(String expression) {
		if (isTemplate(expression)) {
			logger.warn("#{...} syntax is not required for this run-time expression "
					+ "and is deprecated in favor of a simple expression string");
			return new SpelExpressionParser().parseExpression(expression, PARSER_CONTEXT);
		}
		return new SpelExpressionParser().parseExpression(expression);
	}
116328
public Expression<Short> eq(short value) {
		String valueString = "'" + value + "'";
		return new Expression<Short>(this, Operation.eq, valueString);
	}
289205
public static AbstractExpression evaluateExpression(AbstractExpression expr) {
        if (expr == null) {
            return null;
        }

        // Evaluate children first
        expr.setLeft(evaluateExpression(expr.getLeft()));
        expr.setRight(evaluateExpression(expr.getRight()));

        // Evaluate self
        if (ExpressionType.CONJUNCTION_AND == expr.getExpressionType()) {
            if (ExpressionType.VALUE_CONSTANT == expr.getLeft().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getLeft())) {
                    return expr.getRight();
                } else {
                    return expr.getLeft();
                }
            }
            if (ExpressionType.VALUE_CONSTANT == expr.getRight().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getRight())) {
                    return expr.getLeft();
                } else {
                    return expr.getRight();
                }
            }
        } else if (ExpressionType.CONJUNCTION_OR == expr.getExpressionType()) {
            if (ExpressionType.VALUE_CONSTANT == expr.getLeft().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getLeft())) {
                    return expr.getLeft();
                } else {
                    return expr.getRight();
                }
            }
            if (ExpressionType.VALUE_CONSTANT == expr.getRight().getExpressionType()) {
                if (ConstantValueExpression.isBooleanTrue(expr.getRight())) {
                    return expr.getRight();
                } else {
                    return expr.getLeft();
                }
            }
        } else if (ExpressionType.OPERATOR_NOT == expr.getExpressionType()) {
            AbstractExpression leftExpr = expr.getLeft();
            // function expressions can also return boolean. So the left child expression
            // can be expression which are not constant value expressions, so don't
            // evaluate every left child expr as constant value expression
            if ((VoltType.BOOLEAN == leftExpr.getValueType()) &&
                    (leftExpr instanceof ConstantValueExpression)) {
                if (ConstantValueExpression.isBooleanTrue(leftExpr)) {
                    return ConstantValueExpression.getFalse();
                } else {
                    return ConstantValueExpression.getTrue();
                }
            } else if (ExpressionType.OPERATOR_NOT == leftExpr.getExpressionType()) {
                return leftExpr.getLeft();
            } else if (ExpressionType.CONJUNCTION_OR == leftExpr.getExpressionType()) {
                // NOT (.. OR .. OR ..) => NOT(..) AND NOT(..) AND NOT(..)
                AbstractExpression l = new OperatorExpression(ExpressionType.OPERATOR_NOT, leftExpr.getLeft(), null);
                AbstractExpression r = new OperatorExpression(ExpressionType.OPERATOR_NOT, leftExpr.getRight(), null);
                leftExpr = new OperatorExpression(ExpressionType.CONJUNCTION_AND, l, r);
                return evaluateExpression(leftExpr);
            }
            // NOT (expr1 AND expr2) => (NOT expr1) || (NOT expr2)
            // The above case is probably not interesting to do for short circuit purpose
        }
        return expr;
    }