/** * @param string $name * @param integer $arity */ public function __construct($name, $arity) { parent::__construct(self::PRIORITY_FUNCTION); $this->name = $name; $this->arity = $arity; $this->function = null; $this->closed = false; }
/** * @param string $sign */ public function __construct($sign) { parent::__construct(self::PRIORITY_MINUS); $this->sign = $sign; }
/** * @param TokenOperator $tokenOperator */ public function pushOperator($tokenOperator) { //If priority of the new operator //is lower than or equal to that of the previous, if any, //then pop the stack up to the nearest operator //of lower priority strictly, or up to left parenthesis. if (!$tokenOperator instanceof TokenLParen && !$tokenOperator instanceof TokenFunction && !$tokenOperator instanceof TokenLBracket) { while (sizeof($this->stackOperators) > 0) { $operator = $this->stackOperators[sizeof($this->stackOperators) - 1]; if ($operator instanceof TokenLParen) { break; } if ($operator instanceof TokenFunction && !$operator->isClosed()) { break; } if ($tokenOperator->getPriority() <= $operator->getPriority()) { array_pop($this->stackOperators); $nbOperands = $operator->getNumOperands(); if ($nbOperands) { // Check that we have enough operands on the stack. if (sizeof($this->stackRP) < $nbOperands) { $message = $this->getViewFile()->getFilename() . '(' . $this->getViewLine() . '): Missing operand in expression: ' . $this->expression; throw new LexerSyntaxErrorException('', $this->getViewFile()->getFilename(), $this->getViewLine()); } $operator->setOperands(array_splice($this->stackRP, sizeof($this->stackRP) - $nbOperands, $nbOperands)); } $this->stackRP[] = $operator; if ($operator instanceof TokenFunction) { array_pop($this->stackFunctions); break; } } else { break; } } } $this->stackOperators[] = $tokenOperator; if ($tokenOperator instanceof TokenFunction) { $this->stackFunctions[] =& $tokenOperator; } $this->setStateEmpty(); }
public function __construct() { parent::__construct(self::PRIORITY_MUL_DIV); }
/** * @param string $sign */ public function __construct() { parent::__construct(self::PRIORITY_MINUS); }
public function __construct() { parent::__construct(self::PRIORITY_LEFT_PAREN); }