creates string representing infix expression
540633
public String createInfix(Expression root)
    {
        String str = "";
        String closeParen = "";
        String leftOpenParen = "";
        String leftCloseParen = "";

        if(root == null) {
            return str;
        }

        if (ExpressionParser.isOperand(root.getType(), var)) {
            str += root.getType();

        }
        else if(root.getType().equals("$")) {
            str += "-";
        }
        else if(ExpressionParser.isFunction(root.getType())) { // does not include unary minus
            str += root.getType();
            str += "(";
            closeParen = ")";
        }
        else { // is operator
            int parentPrecedence = ExpressionParser.getPrecedence(root.getType());

            str += root.getType();
            if(ExpressionParser.isOperator(root.getLeftChild().getType()) && (ExpressionParser.getPrecedence(root.getLeftChild().getType()) < parentPrecedence)) {
                leftOpenParen = "(";
                leftCloseParen = ")";
            }
			else if(ExpressionParser.isOperator(root.getRightChild().getType()) && (ExpressionParser.getPrecedence(root.getRightChild().getType()) < parentPrecedence)) {
					str += "(";
					closeParen = ")";

            }
        }

        return leftOpenParen + createInfix(root.getLeftChild()) + leftCloseParen + str + createInfix(root.getRightChild()) + closeParen;
    }
500298
function nfx($expr) {

        $index = 0;
        $stack = new EvalMathStack;
        $output = array(); // postfix form of expression, to be passed to pfx()
        $expr = trim(strtolower($expr));
        // MDL-14274: new operators for comparison added.
        $ops   = array('+', '-', '*', '/', '^', '_', '>', '<', '<=', '>=', '==');
        $ops_r = array('+'=>0,'-'=>0,'*'=>0,'/'=>0,'^'=>1); // right-associative operator?
        $ops_p = array('+'=>0,'-'=>0,'*'=>1,'/'=>1,'_'=>1,'^'=>2, '>'=>3, '<'=>3, '<='=>3, '>='=>3, '=='=>3); // operator precedence

        $expecting_op = false; // we use this in syntax-checking the expression
                               // and determining when a - is a negation

        if (preg_match("/[^\w\s+*^\/()\.,-<>=]/", $expr, $matches)) { // make sure the characters are all good
            return $this->trigger(get_string('illegalcharactergeneral', 'mathslib', $matches[0]));
        }

        while(1) { // 1 Infinite Loop ;)
            // MDL-14274 Test two character operators.
            $op = substr($expr, $index, 2);
            if (!in_array($op, $ops)) {
                // MDL-14274 Get one character operator.
                $op = substr($expr, $index, 1); // get the first character at the current index
            }
            // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand
            $ex = preg_match('/^('.self::$namepat.'\(?|\d+(?:\.\d*)?(?:(e[+-]?)\d*)?|\.\d+|\()/', substr($expr, $index), $match);
            //===============
            if ($op == '-' and !$expecting_op) { // is it a negation instead of a minus?
                $stack->push('_'); // put a negation on the stack
                $index++;
            } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack
                return $this->trigger(get_string('illegalcharacterunderscore', 'mathslib')); // but not in the input expression
            //===============
            } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack?
                if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis?
                    if (!$this->allowimplicitmultiplication){
                        return $this->trigger(get_string('implicitmultiplicationnotallowed', 'mathslib'));
                    } else {// it's an implicit multiplication
                        $op = '*';
                        $index--;
                    }
                }
                // heart of the algorithm:
                while($stack->count > 0 and ($o2 = $stack->last()) and in_array($o2, $ops) and ($ops_r[$op] ? $ops_p[$op] < $ops_p[$o2] : $ops_p[$op] <= $ops_p[$o2])) {
                    $output[] = $stack->pop(); // pop stuff off the stack into the output
                }
                // many thanks: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_algorithm_in_detail
                $stack->push($op); // finally put OUR operator onto the stack
                $index += strlen($op);
                $expecting_op = false;
            //===============
            } elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis?
                while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last (
                    if (is_null($o2)) return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
                    else $output[] = $o2;
                }
                if (preg_match('/^('.self::$namepat.')\($/', $stack->last(2), $matches)) { // did we just close a function?
                    $fnn = $matches[1]; // get the function name
                    $arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you)
                    $fn = $stack->pop();
                    $output[] = array('fn'=>$fn, 'fnn'=>$fnn, 'argcount'=>$arg_count); // send function to output
                    if (in_array($fnn, $this->fb)) { // check the argument count
                        if($arg_count > 1) {
                            $a= new stdClass();
                            $a->expected = 1;
                            $a->given = $arg_count;
                            return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
                        }
                    } elseif ($this->get_native_function_name($fnn)) {
                        $fnn = $this->get_native_function_name($fnn); // Resolve synonyms.

                        $counts = $this->fc[$fnn];
                        if (in_array(-1, $counts) and $arg_count > 0) {}
                        elseif (!in_array($arg_count, $counts)) {
                            $a= new stdClass();
                            $a->expected = implode('/',$this->fc[$fnn]);
                            $a->given = $arg_count;
                            return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
                        }
                    } elseif (array_key_exists($fnn, $this->f)) {
                        if ($arg_count != count($this->f[$fnn]['args'])) {
                            $a= new stdClass();
                            $a->expected = count($this->f[$fnn]['args']);
                            $a->given = $arg_count;
                            return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
                        }
                    } else { // did we somehow push a non-function on the stack? this should never happen
                        return $this->trigger(get_string('internalerror', 'mathslib'));
                    }
                }
                $index++;
            //===============
            } elseif ($op == ',' and $expecting_op) { // did we just finish a function argument?
                while (($o2 = $stack->pop()) != '(') {
                    if (is_null($o2)) return $this->trigger(get_string('unexpectedcomma', 'mathslib')); // oops, never had a (
                    else $output[] = $o2; // pop the argument expression stuff and push onto the output
                }
                // make sure there was a function
                if (!preg_match('/^('.self::$namepat.')\($/', $stack->last(2), $matches))
                    return $this->trigger(get_string('unexpectedcomma', 'mathslib'));
                $stack->push($stack->pop()+1); // increment the argument count
                $stack->push('('); // put the ( back on, we'll need to pop back to it again
                $index++;
                $expecting_op = false;
            //===============
            } elseif ($op == '(' and !$expecting_op) {
                $stack->push('('); // that was easy
                $index++;
                $allow_neg = true;
            //===============
            } elseif ($ex and !$expecting_op) { // do we now have a function/variable/number?
                $expecting_op = true;
                $val = $match[1];
                if (preg_match('/^('.self::$namepat.')\($/', $val, $matches)) { // may be func, or variable w/ implicit multiplication against parentheses...
                    if (in_array($matches[1], $this->fb) or
                                array_key_exists($matches[1], $this->f) or
                                $this->get_native_function_name($matches[1])){ // it's a func
                        $stack->push($val);
                        $stack->push(1);
                        $stack->push('(');
                        $expecting_op = false;
                    } else { // it's a var w/ implicit multiplication
                        $val = $matches[1];
                        $output[] = $val;
                    }
                } else { // it's a plain old var or num
                    $output[] = $val;
                }
                $index += strlen($val);
            //===============
            } elseif ($op == ')') {
                //it could be only custom function with no params or general error
                if ($stack->last() != '(' or $stack->last(2) != 1) return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
                if (preg_match('/^('.self::$namepat.')\($/', $stack->last(3), $matches)) { // did we just close a function?
                    $stack->pop();// (
                    $stack->pop();// 1
                    $fn = $stack->pop();
                    $fnn = $matches[1]; // get the function name
                    $fnn = $this->get_native_function_name($fnn); // Resolve synonyms.
                    $counts = $this->fc[$fnn];
                    if (!in_array(0, $counts)){
                        $a= new stdClass();
                        $a->expected = $this->fc[$fnn];
                        $a->given = 0;
                        return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
                    }
                    $output[] = array('fn'=>$fn, 'fnn'=>$fnn, 'argcount'=>0); // send function to output
                    $index++;
                    $expecting_op = true;
                } else {
                    return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
                }
            //===============
            } elseif (in_array($op, $ops) and !$expecting_op) { // miscellaneous error checking
                return $this->trigger(get_string('unexpectedoperator', 'mathslib', $op));
            } else { // I don't even want to know what you did to get here
                return $this->trigger(get_string('anunexpectederroroccured', 'mathslib'));
            }
            if ($index == strlen($expr)) {
                if (in_array($op, $ops)) { // did we end with an operator? bad.
                    return $this->trigger(get_string('operatorlacksoperand', 'mathslib', $op));
                } else {
                    break;
                }
            }
            while (substr($expr, $index, 1) == ' ') { // step the index past whitespace (pretty much turns whitespace
                $index++;                             // into implicit multiplication if no operator is there)
            }

        }
        while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output
            if ($op == '(') return $this->trigger(get_string('expectingaclosingbracket', 'mathslib')); // if there are (s on the stack, ()s were unbalanced
            $output[] = $op;
        }
        return $output;
    }
337338
function createStringifier (pp, spaces) {
  return function stringify (value) {
    var visitor = prettyPrintVisitor(pp, spaces)
    traverse(value, visitor)
    return visitor.result
  }
}
525419
function defineFix(valueToken, valueInfo) {
            const text = valueToken.htmlValue
            if (text !== valueToken.value) {
                // can not fix
                return undefined
            }
            const quoteChar = GET_FIX_QUOTE_CHARS[option](valueInfo)

            const quotePattern = quoteChar === '"' ? /"/gu : /'/gu
            const quoteEscaped = quoteChar === '"' ? "&quot;" : "&apos;"
            return fixer => {
                const replacement =
                    quoteChar +
                    valueInfo.content.replace(quotePattern, quoteEscaped) +
                    quoteChar
                return fixer.replaceText(valueToken, replacement)
            }
        }
1265352
function(arrayOfValues) {
        var i = 0,
            currentLength,
            finishedString = '';

        for (; i < arrayOfValues.length; i++) {
            currentLength = i + 1;

            if (currentLength === arrayOfValues.length) {
                finishedString += ' and ' + arrayOfValues[i];
            }
            else if (i === 0) {
                finishedString += arrayOfValues[i];
            }
            else {
                finishedString += ', ' + arrayOfValues[i];
            }
        }

        return finishedString;
    }
462478
def strnum(prefix: str, num: int, suffix: str = "") -> str:
    
    return "{}{}{}".format(prefix, num, suffix)
587041
private String createExpressionKey(String suffix) {
		String[] parts = suffix.split("_");
		StringBuilder ret = new StringBuilder("[if ");
		boolean ieAdded = false;
		for (String part : parts) {
			if ("".equals(part)) {
				continue;
			}
			if ("ie".equals(part)) {
				break;
			} else if (Pattern.matches("(lt|lte|gt|gte)", part)) {
				ret.append(part).append(" ");
			} else {
				ret.append("IE ").append(part);
				ieAdded = true;
			}
		}
		if (!ieAdded)
			ret.append("IE");
		ret.append("]");
		return ret.toString();
	}
207992
def _build_str_from_expression(exp_items):
    
    time_delta_base, unit, method = exp_items
    if unit not in _KEY_TIME_MAPPING:
        return None
    delta = datetime.timedelta(seconds=int(time_delta_base) * _KEY_TIME_MAPPING[unit])
    now = datetime.datetime.now()
    return datetime.datetime.strftime(now + (delta, -delta)[u'前' == method], STARDAND_FORMAT)
443445
function getSuffix( $where, $orderBy = array(), $limitCount = null, $limitOffset = null ) {

        $suffix = "";

        if ( !empty( $where ) ) {

            $suffix .= " WHERE " . implode( " AND ", $where );

        }

        if ( !empty( $orderBy ) ) {

            $suffix .= " ORDER BY " . implode( ", ", $orderBy );

        }

        if ( isset( $limitCount ) ) {

            $suffix .= " LIMIT " . intval( $limitCount );

            if ( isset( $limitOffset ) ) {

                $suffix .= " OFFSET " . intval( $limitOffset );

            }

        }

        return $suffix;

    }
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);
    }
138827
private void appendAffix(StringBuffer buffer, String affix, boolean localized) {
        boolean needQuote;
        if (localized) {
            needQuote = affix.indexOf(symbols.getZeroDigit()) >= 0
                || affix.indexOf(symbols.getGroupingSeparator()) >= 0
                || affix.indexOf(symbols.getDecimalSeparator()) >= 0
                || affix.indexOf(symbols.getPercent()) >= 0
                || affix.indexOf(symbols.getPerMill()) >= 0
                || affix.indexOf(symbols.getDigit()) >= 0
                || affix.indexOf(symbols.getPatternSeparator()) >= 0
                || affix.indexOf(symbols.getMinusSign()) >= 0
                || affix.indexOf(CURRENCY_SIGN) >= 0;
        } else {
            needQuote = affix.indexOf(PATTERN_ZERO_DIGIT) >= 0
                || affix.indexOf(PATTERN_GROUPING_SEPARATOR) >= 0
                || affix.indexOf(PATTERN_DECIMAL_SEPARATOR) >= 0
                || affix.indexOf(PATTERN_PERCENT) >= 0
                || affix.indexOf(PATTERN_PER_MILLE) >= 0
                || affix.indexOf(PATTERN_DIGIT) >= 0
                || affix.indexOf(PATTERN_SEPARATOR) >= 0
                || affix.indexOf(PATTERN_MINUS) >= 0
                || affix.indexOf(CURRENCY_SIGN) >= 0;
        }
        if (needQuote) buffer.append('\'');
        if (affix.indexOf('\'') < 0) buffer.append(affix);
        else {
            for (int j=0; j<affix.length(); ++j) {
                char c = affix.charAt(j);
                buffer.append(c);
                if (c == '\'') buffer.append(c);
            }
        }
        if (needQuote) buffer.append('\'');
    }
255387
def tostring(self, inject):
        """"""
        return inject(self, '\n'.join(document.tostring(inject) for document in self.documents))
1241938
function buildDontEnumFix() {
  if (!({toString:1}).propertyIsEnumerable('toString')) {
    var forEachEnumerableProperty = forEachProperty;
    forEachProperty = function(obj, fn) {
      forEachEnumerableProperty(obj, fn);
      for (var i = 0, key; key = DONT_ENUM_PROPS[i]; i++) {
        if (hasOwn(obj, key)) {
          if(fn.call(obj, obj[key], key, obj) === false) break;
        }
      }
    };
  }
}
1154335
public String getExpressionString() {
        StringBuffer buf = new StringBuffer();
        buf.append(mPrefix.getExpressionString());

        for (int i = 0; mSuffixes != null && i < mSuffixes.size(); i++) {
            ValueSuffix suffix = (ValueSuffix) mSuffixes.get(i);
            buf.append(suffix.getExpressionString());
        }

        return buf.toString();
    }
277142
def visitConcatenation(self, ctx):
        
        arg1 = conversions.to_string(self.visit(ctx.expression(0)), self._eval_context)
        arg2 = conversions.to_string(self.visit(ctx.expression(1)), self._eval_context)
        return arg1 + arg2
787397
public Expression<String> in(String[] value) {
		String listString = "";
		Boolean firstString = true;
		for (String v : value) {
			if (firstString) {
				listString = listString.concat("('").concat(v).concat("'");
				firstString = false;
			} else {
				listString = listString.concat(", '").concat(v).concat("'");
			}
		}
		listString = listString.concat(")");
		return new Expression<String>(this, Operation.in, listString);
	}
163518
String getPattern() {
        final StringBuilder result = new StringBuilder();

        if (myPrefix != null) {
            result.append(myPrefix);
        }
        if (mySuffixes != null) {
            result.append("*");
            for (final Literal sub : mySuffixes) {
                result.append(sub);
                result.append("*");
            }
        }
        if (myPostfix != null) {
            result.append(myPostfix);
        }
        return result.toString();
    }