. */ /** * 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($paramHolder) { // 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', $paramHolder); while ($this->_isNextToken(',')) { $this->_parser->match(','); $this->_selectExpressions[] = $this->parse('SelectExpression', $paramHolder); } } public function semantical($paramHolder) { // We need to validate each SelectExpression for ($i = 0, $l = count($this->_selectExpressions); $i < $l; $i++) { $this->_AST->addSelectExpression($this->_selectExpressions[$i]->semantical($paramHolder)); } // Return AST node return $this->_AST; } }