예제 #1
0
 public function compare(Operator $op)
 {
     if ($this->priority < $op->getPriority()) {
         return -1;
     } else {
         if ($this->priority > $op->getPriority()) {
             return 1;
         } else {
             return 0;
         }
     }
 }
예제 #2
0
 /**
  * Return true if this operator has lower priority of operator $o.
  * 
  * @param \oat\beeme\Operator $o
  * @return boolean
  */
 public function hasLowerPriority(Operator $o)
 {
     $hasLowerPriority1 = Operator::O_LEFT_ASSOCIATIVE == $this->getAssociativity() && $this->getPriority() <= $o->getPriority();
     $hasLowerPriority2 = Operator::O_RIGHT_ASSOCIATIVE == $this->getAssociativity() && $this->getPriority() < $o->getPriority();
     return $hasLowerPriority1 || $hasLowerPriority2;
 }
예제 #3
0
 /**
  * Return true if this operator has lower priority of operator $o.
  * 
  * @param \Math\Operator $o
  * @return boolean
  */
 public function hasLowerPriority(Operator $o)
 {
     $hasLowerPriority = Operator::O_LEFT_ASSOCIATIVE == $o->getAssociativity() && $this->getPriority() == $o->getPriority() || $this->getPriority() < $o->getPriority();
     return $hasLowerPriority;
 }
예제 #4
0
 /**
  * @param Operator $operator
  * @return int
  */
 public function comparePriority(Operator $operator)
 {
     return $this->priority - $operator->getPriority();
 }