. */ /** * SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression} * * @author Guilherme Blanco * @author Janne Vanhala * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org * @since 2.0 * @version $Revision$ */ class Doctrine_ORM_Query_Parser_SelectClause extends Doctrine_ORM_Query_ParserRule { protected $_AST = null; protected $_selectExpressions = array(); public function syntax() { // SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression} $this->_AST = $this->AST('SelectClause'); $this->_parser->match(Doctrine_ORM_Query_Token::T_SELECT); // Inspecting if we are in a DISTINCT query if ($this->_isNextToken(Doctrine_ORM_Query_Token::T_DISTINCT)) { $this->_parser->match(Doctrine_ORM_Query_Token::T_DISTINCT); $this->_AST->setIsDistinct(true); } // Process SelectExpressions (1..N) $this->_selectExpressions[] = $this->parse('SelectExpression'); while ($this->_isNextToken(Doctrine_ORM_Query_Token::T_COMMA)) { $this->_parser->match(Doctrine_ORM_Query_Token::T_COMMA); $this->_selectExpressions[] = $this->parse('SelectExpression'); } } public function semantical() { // We need to validate each SelectExpression for ($i = 0, $l = count($this->_selectExpressions); $i < $l; $i++) { $this->_AST->addSelectExpression($this->_selectExpressions[$i]->semantical()); } // Return AST node return $this->_AST; } }