public static function convertExpr($expr)
    {
        preg_match_all('/(==|!=|<=|>=|&&|\|\||<<|>>|[-!?:+*\/&|^~%<>()n]|[0-9]+)/', $expr, $matches);
        $tokens = $matches[0];
        $expr = '';
        $stack = array();
        foreach ($tokens as $token) {
            if ($token == 'n') {
                $expr .= '$n';
            } elseif ($token == ':') {
                array_push($stack, ':');
                $expr .= ':(';
            } elseif ($token == '(') {
                array_push($stack, '(');
                $expr .= '(';
            } elseif ($token == ')') {
                while (count($stack) > 0) {
                    $c = array_pop($stack);
                    $expr .= ')';
                    if ($c == '(') {
                        break;
                    }
                }
            } else {
                $expr .= $token;
            }
        }
        while (count($stack) > 0) {
            array_pop($stack);
            $expr .= ')';
        }
        return $expr;
    }