. */ /** * An abstract base class for the productions of the Doctrine Query Language * context-free grammar. * * @package Doctrine * @subpackage Query * @author Janne Vanhala * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org * @since 1.0 * @version $Revision$ */ abstract class Doctrine_Query_Production { /** * a parser object * * @var Doctrine_Query_Parser */ protected $_parser; /** * Creates a new production object. * * @param Doctrine_Query_Parser $parser a parser object */ public function __construct(Doctrine_Query_Parser $parser) { $this->_parser = $parser; } protected function _isNextToken($token) { $la = $this->_parser->lookahead; return ($la['type'] === $token || $la['value'] === $token); } /** * Executes a production with specified name and parameters. * * @param string $name production name * @param array $params an associative array containing parameter names and * their values * @return mixed */ public function __call($method, $args) { $this->_parser->getPrinter()->startProduction($method); $retval = $this->_parser->getProduction($method)->execute($args); $this->_parser->getPrinter()->endProduction(); return $retval; } /** * Executes this production using the specified parameters. * * @param array $params an associative array containing parameter names and * their values * @return mixed */ abstract public function execute(array $params = array()); }