/** * 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; }