Create a String expression from a Expression

@param expr
@param pos
@return String expression
160347
public static ExprString toExprString(Expression expr) {
	if (expr instanceof ExprString) return (ExprString) expr;
	if (expr instanceof Literal) return expr.getFactory().createLitString(((Literal) expr).getString(), expr.getStart(), expr.getEnd());
	return new CastString(expr);
    }
1029344
function parseExpressionAt(input, pos, options) {
  var p = new _state.Parser(options, input, pos);
  p.nextToken();
  return p.parseExpression();
}
933304
@Override
    public Q addFlag(Position position, String prefix, Expression<?> expr) {
        Expression<?> flag = Expressions.template(expr.getType(), prefix + "{0}", expr);
        return queryMixin.addFlag(new QueryFlag(position, flag));
    }
72314
public static DataExpr parseDataExpr(String expr) {
    try {
      return (DataExpr) parse(expr);
    } catch (ClassCastException e) {
      throw new IllegalArgumentException("invalid data expression: " + expr, e);
    }
  }
122963
private TemplateExpression processJavaExpression(String expressionString) {
    Expression expression;
    try {
      expression = JavaParser.parseExpression(expressionString);
    } catch (ParseProblemException parseException) {
      logger.error("Couldn't parse Expression, make sure it is valid Java.",
          expressionString);
      throw parseException;
    }

    resolveTypesUsingImports(expression);
    resolveStaticMethodsUsingImports(expression);

    checkMethodNames(expression);

    // Find the parameters used by the expression
    List<VariableInfo> expressionParameters = new LinkedList<>();
    findExpressionParameters(expression, expressionParameters);

    // If there is a cast first, we use this as the type of our expression
    if (currentProp == null) {
      expression = getTypeFromCast(expression);
    }

    // Update the expression as it might have been changed
    expressionString = expression.toString();

    // Add the resulting expression to our result
    return result.addExpression(expressionString,
        currentExpressionReturnType,
        currentProp == null,
        expressionParameters);
  }
432817
def visit_expr(self, node, parent):
        """"""
        newnode = nodes.Expr(node.lineno, node.col_offset, parent)
        newnode.postinit(self.visit(node.value, newnode))
        return newnode
1160627
private void fromExpression(PatternDescrBuilder<?> pattern) throws RecognitionException {
        String expr = conditionalOrExpression();
        if (state.failed)
            return;

        if (state.backtracking == 0) {
            pattern.from().expression(expr);
            if (input.LA(1) != DRL6Lexer.EOF) {
                helper.emit(Location.LOCATION_LHS_BEGIN_OF_CONDITION);
            }
        }
    }
161617
function parsePostfixExpression() {
  var expr = parseLeftHandSideExpressionAllowCall();

  if (lookahead.type === TokenPunctuator) {
    if ((match('++') || match('--'))) {
      throw new Error(DISABLED);
    }
  }

  return expr;
}
561455
public boolean setExpr(String str){
		Loc loc=new Loc();
		loc.v=0;
		int num1,num2,op;
		num1=chn2Num(str,loc);
		if(num1<0)
			return false;
		op=chn2Op(str,loc);
		if(op<0)
			return false;
		num2=chn2Num(str,loc);
		if(num2<0)
			return false;
		if(!this.checkSuffix(str, loc))
			return false;
		this.num1=num1;
		this.num2=num2;
		this.op=op;
		return true;
	}
370866
function createExpressionStatement(lhs, node) {
        var ret;
        ret = replaceInStatement(
            RP + "1 = " + RP + "2", lhs, node
        );
        transferLoc(ret[0].expression, node);
        return ret;
    }
1066369
def p_field_expr(p):
    
    p[0] = node.expr(
        op=".",
        args=node.expr_list([
            p[1], node.ident(
                name=p[2], lineno=p.lineno(2), lexpos=p.lexpos(2))
        ]))
2259
def create_and_push_expression(token, expressions):
    
    if token == 'and':
        right_expr = expressions.pop()
        expressions.append(And(expressions.pop(), right_expr))
    elif token == 'or':
        right_expr = expressions.pop()
        expressions.append(Or(expressions.pop(), right_expr))
    elif token == 'not':
        expressions.append(Not(expressions.pop()))
    else:
        expressions.append(Literal(token))
936588
public Expression compile(int opPos) throws TransformerException
  {

    int op = getOp(opPos);

    Expression expr = null;
    // System.out.println(getPatternString()+"op: "+op);
    switch (op)
    {
    case OpCodes.OP_XPATH :
      expr = compile(opPos + 2); break;
    case OpCodes.OP_OR :
      expr = or(opPos); break;
    case OpCodes.OP_AND :
      expr = and(opPos); break;
    case OpCodes.OP_NOTEQUALS :
      expr = notequals(opPos); break;
    case OpCodes.OP_EQUALS :
      expr = equals(opPos); break;
    case OpCodes.OP_LTE :
      expr = lte(opPos); break;
    case OpCodes.OP_LT :
      expr = lt(opPos); break;
    case OpCodes.OP_GTE :
      expr = gte(opPos); break;
    case OpCodes.OP_GT :
      expr = gt(opPos); break;
    case OpCodes.OP_PLUS :
      expr = plus(opPos); break;
    case OpCodes.OP_MINUS :
      expr = minus(opPos); break;
    case OpCodes.OP_MULT :
      expr = mult(opPos); break;
    case OpCodes.OP_DIV :
      expr = div(opPos); break;
    case OpCodes.OP_MOD :
      expr = mod(opPos); break;
//    case OpCodes.OP_QUO :
//      expr = quo(opPos); break;
    case OpCodes.OP_NEG :
      expr = neg(opPos); break;
    case OpCodes.OP_STRING :
      expr = string(opPos); break;
    case OpCodes.OP_BOOL :
      expr = bool(opPos); break;
    case OpCodes.OP_NUMBER :
      expr = number(opPos); break;
    case OpCodes.OP_UNION :
      expr = union(opPos); break;
    case OpCodes.OP_LITERAL :
      expr = literal(opPos); break;
    case OpCodes.OP_VARIABLE :
      expr = variable(opPos); break;
    case OpCodes.OP_GROUP :
      expr = group(opPos); break;
    case OpCodes.OP_NUMBERLIT :
      expr = numberlit(opPos); break;
    case OpCodes.OP_ARGUMENT :
      expr = arg(opPos); break;
    case OpCodes.OP_EXTFUNCTION :
      expr = compileExtension(opPos); break;
    case OpCodes.OP_FUNCTION :
      expr = compileFunction(opPos); break;
    case OpCodes.OP_LOCATIONPATH :
      expr = locationPath(opPos); break;
    case OpCodes.OP_PREDICATE :
      expr = null; break;  // should never hit this here.
    case OpCodes.OP_MATCHPATTERN :
      expr = matchPattern(opPos + 2); break;
    case OpCodes.OP_LOCATIONPATHPATTERN :
      expr = locationPathPattern(opPos); break;
    case OpCodes.OP_QUO:
      error(XPATHErrorResources.ER_UNKNOWN_OPCODE,
            new Object[]{ "quo" });  //"ERROR! Unknown op code: "+m_opMap[opPos]);
      break;
    default :
      error(XPATHErrorResources.ER_UNKNOWN_OPCODE,
            new Object[]{ Integer.toString(getOp(opPos)) });  //"ERROR! Unknown op code: "+m_opMap[opPos]);
    }
//    if(null != expr)
//      expr.setSourceLocator(m_locator);

    return expr;
  }
1135216
public static String listInsertAt(String list, int pos, String value, String delimiter, boolean ignoreEmpty) throws ExpressionException {
	if (pos < 1) throw new ExpressionException("invalid string list index [" + (pos) + "]");

	char[] del = delimiter.toCharArray();
	char c;
	StringBuilder result = new StringBuilder();
	String end = "";
	int len;

	// remove at start
	if (ignoreEmpty) {
	    outer: while (list.length() > 0) {
		c = list.charAt(0);
		for (int i = 0; i < del.length; i++) {
		    if (c == del[i]) {
			list = list.substring(1);
			result.append(c);
			continue outer;
		    }
		}
		break;
	    }
	}

	// remove at end
	if (ignoreEmpty) {
	    outer: while (list.length() > 0) {
		c = list.charAt(list.length() - 1);
		for (int i = 0; i < del.length; i++) {
		    if (c == del[i]) {
			len = list.length();
			list = list.substring(0, len - 1 < 0 ? 0 : len - 1);
			end = c + end;
			continue outer;
		    }

		}
		break;
	    }
	}

	len = list.length();
	int last = 0;

	int count = 0;
	outer: for (int i = 0; i < len; i++) {
	    c = list.charAt(i);
	    for (int y = 0; y < del.length; y++) {
		if (c == del[y]) {

		    if (!ignoreEmpty || last < i) {
			if (pos == ++count) {
			    result.append(value);
			    result.append(del[0]);
			}
		    }
		    result.append(list.substring(last, i));
		    result.append(c);
		    last = i + 1;
		    continue outer;
		}
	    }
	}
	count++;
	if (last <= len) {
	    if (pos == count) {
		result.append(value);
		result.append(del[0]);
	    }

	    result.append(list.substring(last));
	}
	if (pos > count) {
	    throw new ExpressionException("invalid string list index [" + (pos) + "], indexes go from 1 to " + (count));

	}

	return result + end;
    }
15906
def p_expr1(p):
    
    p[0] = node.expr(op=p[1], args=node.expr_list([p[2]]))
710833
function parseExpr(source) {
    if (!source) {
        return;
    }

    if (typeof source === 'object' && source.type) {
        return source;
    }

    var expr = readTertiaryExpr(new Walker(source));
    expr.raw = source;
    return expr;
}
764116
static final Parser<Expression> castOrExpression(Parser<Expression> expr) {
    Parser<Expression> explicitCast =
        Parsers.sequence(paren(TypeLiteralParser.TYPE_LITERAL), expr, CastExpression::new);
    return explicitCast.or(paren(expr));
  }