Example #1
0
 /**
  * @param  ConditionalPrimary $node
  * @param  Node[]             $filterExpressions
  * @return bool
  */
 private function primaryContainsFilter(ConditionalPrimary $node, $filterExpressions)
 {
     if ($node->isSimpleConditionalExpression() && ($node->simpleConditionalExpression instanceof LikeExpression || $node->simpleConditionalExpression instanceof ComparisonExpression)) {
         return $this->isExpressionInFilterExpressions($node->simpleConditionalExpression, $filterExpressions);
     }
     if ($node->isConditionalExpression()) {
         return $this->expressionContainsFilter($node->conditionalExpression, $filterExpressions);
     }
     return false;
 }
Example #2
0
 /**
  * ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
  * @todo Implementation incomplete: Recognition of SimpleConditionalExpression is incomplete.
  */
 public function _ConditionalPrimary()
 {
     $condPrimary = new AST\ConditionalPrimary();
     if ($this->_lexer->isNextToken('(')) {
         // Peek beyond the matching closing paranthesis ')'
         $numUnmatched = 1;
         $peek = $this->_lexer->peek();
         while ($numUnmatched > 0) {
             if ($peek['value'] == ')') {
                 --$numUnmatched;
             } else {
                 if ($peek['value'] == '(') {
                     ++$numUnmatched;
                 }
             }
             $peek = $this->_lexer->peek();
         }
         $this->_lexer->resetPeek();
         //TODO: This is not complete, what about LIKE/BETWEEN/...etc?
         $comparisonOps = array("=", "<", "<=", "<>", ">", ">=", "!=");
         if (in_array($peek['value'], $comparisonOps)) {
             $condPrimary->setSimpleConditionalExpression($this->_SimpleConditionalExpression());
         } else {
             $this->match('(');
             $conditionalExpression = $this->_ConditionalExpression();
             $this->match(')');
             $condPrimary->setConditionalExpression($conditionalExpression);
         }
     } else {
         $condPrimary->setSimpleConditionalExpression($this->_SimpleConditionalExpression());
     }
     return $condPrimary;
 }