Combine expression with prefix/postfix (usually SQL keyword) but only if expression is not
empty.

@param string $prefix
@param string $expression
@param string $postfix

@return string
490982
protected function optional(string $prefix, string $expression, string $postfix = ''): string
    {
        if (empty($expression)) {
            return '';
        }

        if ($prefix != "\n" && $prefix != ' ') {
            $prefix .= ' ';
        }

        return $prefix . $expression . $postfix;
    }
661163
public function compile($expression, CompilationContext $compilationContext)
    {
        /*
         * This variable is used to check if the compound and expression is evaluated as true or false:
         * Ensure that newly allocated variables are local-only (setReadOnly)
         */
        $this->setReadOnly(false);
        $returnVariable = $this->getExpected($compilationContext, $expression, false);
        /* Make sure that passed variables (passed symbol variables) are promoted */
        $returnVariable->setLocalOnly(false);

        if ('variable' != $returnVariable->getType() || 'return_value' == $returnVariable->getName()) {
            $returnVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
            if ($returnVariable->isTemporal()) {
                $returnVariable->skipInitVariant(2);
            }
        }

        $expr = new EvalExpression();
        $condition = $expr->optimize($expression['left'], $compilationContext);
        $compilationContext->codePrinter->output('if ('.$condition.') {');

        $compilationContext->codePrinter->increaseLevel();

        /**
         * Create an implicit 'let' operation to update the evaluated left operator.
         */
        $statement = new LetStatement([
            'type' => 'let',
            'assignments' => [
                [
                    'assign-type' => 'variable',
                    'variable' => $returnVariable->getName(),
                    'operator' => 'assign',
                    'expr' => $expression['right'],
                    'file' => $expression['file'],
                    'line' => $expression['line'],
                    'char' => $expression['char'],
                ],
            ],
        ]);
        $statement->compile($compilationContext);

        $compilationContext->codePrinter->decreaseLevel();
        $compilationContext->codePrinter->output('} else {');
        $compilationContext->codePrinter->increaseLevel();

        /**
         * Create an implicit 'let' operation to update the evaluated left operator.
         */
        $statement = new LetStatement([
            'type' => 'let',
            'assignments' => [
                [
                    'assign-type' => 'variable',
                    'variable' => $returnVariable->getName(),
                    'operator' => 'assign',
                    'expr' => $expression['extra'],
                    'file' => $expression['file'],
                    'line' => $expression['line'],
                    'char' => $expression['char'],
                ],
            ],
        ]);
        $statement->compile($compilationContext);

        $compilationContext->codePrinter->decreaseLevel();
        $compilationContext->codePrinter->output('}');

        return new CompiledExpression('variable', $returnVariable->getName(), $expression);
    }
860734
public function setPrefix(string $prefix)
    {
        foreach ($this->caches as $cache) {
            $cache->setPrefix($prefix);
        }
    }
1246372
protected function _formatPrefix($prefix)
    {
        if($prefix == "") {
            return $prefix;
        }

        $nsSeparator = (false !== strpos($prefix, '\\'))?'\\':'_';
        return rtrim($prefix, $nsSeparator) . $nsSeparator;
    }
385923
public function prefix($prefix)
    {
        if ($this->parent && $this->parent->getOption('prefix')) {
            $prefix = $this->parent->getOption('prefix') . $prefix;
        }

        return $this->option('prefix', $prefix);
    }
749809
public function hasPrefix(string $prefix):bool {
        if (0 !== $this->getLength() && "" === $prefix) return false;
        return true === (substr( $this->getValue(), 0, strlen($prefix)) === $prefix);
    }
310977
function prefixQuery( $regex, $query, $prefix = NULL ) {
		if( !isset( $prefix ) ) {
			return $query;
		}

		if( preg_match( $regex, $query, $match ) ) {
			$preamble = $match[1];
			$postamble = $match[5];
			$objectList = explode( ',', $match[3] );
			// $prefix = $prefix . '_';

			$prefixedList = '';

			foreach( $objectList as $object ) {
				if( $prefixedList !== '' ) {
					$prefixedList .= ', ';
				}

				$prefixedList .= $prefix . trim( $object );
			}

			$query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
		}

		return $query;
	}
782446
private function prefix($prefix)
    {
        if ($prefix) {
            $prefixLastChar = substr($prefix, -1);

            if ($prefixLastChar != '.' && $prefixLastChar != ':') {
                $prefix .= '.';
            }
        }

        return $prefix;
    }
1261925
private function fetchExpression($expression)
    {
        $selectors = explode(',', $expression);
        $paths = [];

        foreach ($selectors as $selector) {
            $selector = trim($selector);

            if (array_key_exists($selector, $this->compiledExpressions)) {
                $paths[] = $this->compiledExpressions[ $selector ];

                continue;
            }

            $this->compiledExpressions[ $selector ] = $this->fetchCssExpression($selector);

            $paths[] = $this->compiledExpressions[ $selector ];
        }

        return implode('|', $paths);
    }
313008
private static function buildRegex(string $expression, bool $is_prefix = false) : string
    {
        $regex  = self::REGEX_DELIMITER . '^';
        $regex .= preg_replace(array_keys(self::$datatypes), self::$datatypes, $expression);
        $regex .= $is_prefix ? '(.*)' : '';
        $regex .= '$' . self::REGEX_DELIMITER;
        return $regex;
    }
1127615
def p_postfix_expr(self, p):
        
        if len(p) == 2:
            p[0] = p[1]
        else:
            p[0] = self.asttypes.PostfixExpr(op=p[2], value=p[1])
            p[0].setpos(p, 2)
646070
public function postfix(string $value, string $postfix): string
    {
        if (substr($value, strlen($value) - strlen($postfix)) === $postfix) {
            return $value;
        }

        return $value . $postfix;
    }
637609
public function prependPrefix($prefix)
  {
    $this->deletePrefix($prefix);
    
    $prepend = array($prefix => $prefix);
    $this->_prefixes = array_merge($prepend, $this->_prefixes);
  }
1309481
public function addAnd($expression)
    {
        if ($this->currentField) {
            $this->expr[$this->currentField]['$and'][] = $this->ensureArray($expression);
        } else {
            $this->expr['$and'][] = $this->ensureArray($expression);
        }

        return $this;
    }
625417
public function setTablePrefix($prefix) {
        if ($prefix) {
            $prefix = trim($prefix, '_') . '_';
        }

        $this->tablePrefix = $prefix;

        return $this;
    }
515294
public static function checkUrlPrefix($prefix) {
        return isset(self::$prefix['check'][ $prefix ]) ? self::$prefix['check'][ $prefix ] : null;
    }
1113964
public function add(ExpressionContract $expression)
    {
        $this->typeCheck($expression);
        $this->applyRestrictions($expression);
        $this->_expressions[] = $expression;
        return $this;
    }