Пример #1
0
 /**
  * Parse unary operator (- ,not)
  * 
  * @return AbstractExpression
  */
 private function _parseUnary()
 {
     $this->_recurseEnter();
     if ($this->_getCurrentToken()->Id == ExpressionTokenId::MINUS || $this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_NOT)) {
         $op = clone $this->_getCurrentToken();
         $this->_lexer->nextToken();
         if ($op->Id == ExpressionTokenId::MINUS && ExpressionLexer::isNumeric($this->_getCurrentToken()->Id)) {
             $numberLiteral = $this->_getCurrentToken();
             $numberLiteral->Text = '-' . $numberLiteral->Text;
             $numberLiteral->Position = $op->Position;
             $v = $this->_getCurrentToken();
             $this->_setCurrentToken($numberLiteral);
             $this->_recurseLeave();
             return $this->_parsePrimary();
         }
         $expr = $this->_parsePrimary();
         FunctionDescription::validateUnaryOpArguments($op, $expr);
         if ($op->Id == ExpressionTokenId::MINUS) {
             $expr = new UnaryExpression($expr, ExpressionType::NEGATE, $expr->getType());
         } else {
             $expr = new UnaryExpression($expr, ExpressionType::NOT_LOGICAL, new Boolean());
         }
         $this->_recurseLeave();
         return $expr;
     }
     $this->_recurseLeave();
     return $this->_parsePrimary();
 }
Пример #2
0
 /**
  * Checks whether this token is a valid token for a key value.
  * 
  * @return boolean True if this token represent valid key value
  *                 False otherwise.
  */
 public function isKeyValueToken()
 {
     return $this->Id == ExpressionTokenId::BINARY_LITERAL || $this->Id == ExpressionTokenId::BOOLEAN_LITERAL || $this->Id == ExpressionTokenId::DATETIME_LITERAL || $this->Id == ExpressionTokenId::GUID_LITERAL || $this->Id == ExpressionTokenId::STRING_LITERAL || ExpressionLexer::isNumeric($this->Id);
 }