Exemple #1
0
 /**
  * Create a new instance
  * @param string $op the operator
  */
 public function __construct($op)
 {
     parent::__construct(Token::TOKEN_OPERATOR);
     if ($op == null) {
         throw new ExpressionException("Operator is unknown for token.");
     }
     $this->operator = $op;
 }
Exemple #2
0
 private function getOperator($symbol)
 {
     $op = null;
     if ($this->userOperators != null && array_key_exists($symbol, $this->userOperators)) {
         $op = $this->userOperators[$symbol];
     }
     if ($op == null && strlen($symbol) == 1) {
         $argc = $this->lastToken == null || $this->lastToken->getType() == Token::TOKEN_OPERATOR || $this->lastToken->getType() == Token::TOKEN_PARENTHESES_OPEN ? 1 : 2;
         $op = Operators::getBuiltinOperator($symbol[0], $argc);
     }
     return $op;
 }