Пример #1
0
 /**
  * ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression )
  *
  * @return \Doctrine\ORM\Query\AST\ComparisonExpression
  */
 public function ComparisonExpression()
 {
     $peek = $this->_lexer->glimpse();
     $leftExpr = $this->ArithmeticExpression();
     $operator = $this->ComparisonOperator();
     $rightExpr = $this->_isNextAllAnySome() ? $this->QuantifiedExpression() : $this->ArithmeticExpression();
     return new AST\ComparisonExpression($leftExpr, $operator, $rightExpr);
 }
Пример #2
0
 /**
  * NewObjectArg ::= ScalarExpression | "(" Subselect ")"
  *
  * @return mixed
  */
 public function NewObjectArg()
 {
     $token = $this->lexer->lookahead;
     $peek = $this->lexer->glimpse();
     if ($token['type'] === Lexer::T_OPEN_PARENTHESIS && $peek['type'] === Lexer::T_SELECT) {
         $this->match(Lexer::T_OPEN_PARENTHESIS);
         $expression = $this->Subselect();
         $this->match(Lexer::T_CLOSE_PARENTHESIS);
         return $expression;
     }
     return $this->ScalarExpression();
 }
 /**
  * NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | AggregateExpression | FunctionDeclaration | IdentificationVariable | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"
  *
  * @return \Doctrine\ORM\Query\AST\NullComparisonExpression
  */
 public function NullComparisonExpression()
 {
     switch (true) {
         case $this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER):
             $this->match(Lexer::T_INPUT_PARAMETER);
             $expr = new AST\InputParameter($this->lexer->token['value']);
             break;
         case $this->lexer->isNextToken(Lexer::T_NULLIF):
             $expr = $this->NullIfExpression();
             break;
         case $this->lexer->isNextToken(Lexer::T_COALESCE):
             $expr = $this->CoalesceExpression();
             break;
         case $this->isAggregateFunction($this->lexer->lookahead['type']):
             $expr = $this->AggregateExpression();
             break;
         case $this->isFunction():
             $expr = $this->FunctionDeclaration();
             break;
         default:
             // We need to check if we are in a IdentificationVariable or SingleValuedPathExpression
             $glimpse = $this->lexer->glimpse();
             if ($glimpse['type'] === Lexer::T_DOT) {
                 $expr = $this->SingleValuedPathExpression();
                 // Leave switch statement
                 break;
             }
             $lookaheadValue = $this->lexer->lookahead['value'];
             // Validate existing component
             if (!isset($this->queryComponents[$lookaheadValue])) {
                 $this->semanticalError('Cannot add having condition on undefined result variable.');
             }
             // Validating ResultVariable
             if (!isset($this->queryComponents[$lookaheadValue]['resultVariable'])) {
                 $this->semanticalError('Cannot add having condition on a non result variable.');
             }
             $expr = $this->ResultVariable();
             break;
     }
     $nullCompExpr = new AST\NullComparisonExpression($expr);
     $this->match(Lexer::T_IS);
     if ($this->lexer->isNextToken(Lexer::T_NOT)) {
         $this->match(Lexer::T_NOT);
         $nullCompExpr->not = true;
     }
     $this->match(Lexer::T_NULL);
     return $nullCompExpr;
 }