parser = $parser; $this->id = $id; $this->leftBindingPower = $leftBindingPower; } /** * Set the null denotation getter. * * @return $this */ public function setNullDenotationGetter(Closure $getter) { $this->nullDenotationGetter = $getter; return $this; } /** * Set the left denotation getter. * * @return $this */ public function setLeftDenotationGetter(Closure $getter) { $this->leftDenotationGetter = $getter; return $this; } /** * Get null denotation. * * @throws Exception\ParseException * @return Symbol */ public function getNullDenotation() { if ($this->nullDenotationGetter === null) { throw new Exception\ParseException(sprintf('Syntax error: %s', $this->id)); } /** @var callable $function */ $function = $this->nullDenotationGetter; return $function($this); } /** * Get left denotation. * * @param Symbol $left * @throws Exception\ParseException * @return Symbol */ public function getLeftDenotation($left) { if ($this->leftDenotationGetter === null) { throw new Exception\ParseException(sprintf('Unknown operator: %s', $this->id)); } /** @var callable $function */ $function = $this->leftDenotationGetter; return $function($this, $left); } }