| Total Complexity | 92 |
| Total Lines | 728 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like ExpressionParser often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ExpressionParser, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 39 | class ExpressionParser |
||
| 40 | { |
||
| 41 | const RECURSION_LIMIT = 200; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * The Lexical analyzer |
||
| 45 | * |
||
| 46 | * @var ExpressionLexer |
||
| 47 | */ |
||
| 48 | private $_lexer; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * The current recursion depth |
||
| 52 | * |
||
| 53 | * @var int |
||
| 54 | */ |
||
| 55 | private $_recursionDepth; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * The ResourceType on which $filter condition needs to be applied |
||
| 59 | * |
||
| 60 | * @var ResourceType |
||
| 61 | */ |
||
| 62 | private $_resourceType; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var bool |
||
| 66 | */ |
||
| 67 | private $_isPHPExpressionProvider; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * True if the filter expression contains level 2 property access, for example |
||
| 71 | * Customers?$filter=Address/LineNumber eq 12 |
||
| 72 | * Customer?$filter=Order/OrderID gt 1234 |
||
| 73 | * False otherwise. |
||
| 74 | * |
||
| 75 | * @var bool |
||
| 76 | */ |
||
| 77 | private $_hasLevel2PropertyInTheExpression; |
||
| 78 | |||
| 79 | |||
| 80 | /** |
||
| 81 | * Construct a new instance of ExpressionParser |
||
| 82 | * |
||
| 83 | * @param string $text The expression to parse. |
||
| 84 | * @param ResourceType $resourceType The resource type of the resource targeted by the resource path. |
||
| 85 | * @param bool $isPHPExpressionProvider |
||
| 86 | * |
||
| 87 | * TODO Expression parser should not depend on the fact that end user is implementing IExpressionProvider or not. |
||
| 88 | */ |
||
| 89 | public function __construct($text, ResourceType $resourceType, $isPHPExpressionProvider) |
||
| 90 | { |
||
| 91 | $this->_lexer = new ExpressionLexer($text); |
||
| 92 | $this->_resourceType = $resourceType; |
||
| 93 | $this->_isPHPExpressionProvider = $isPHPExpressionProvider; |
||
| 94 | $this->_hasLevel2PropertyInTheExpression = false; |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Checks whether the expression contains level 2 property access. |
||
| 99 | * |
||
| 100 | * @return boolean |
||
| 101 | */ |
||
| 102 | public function hasLevel2Property() |
||
| 103 | { |
||
| 104 | return $this->_hasLevel2PropertyInTheExpression; |
||
|
|
|||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Get the current token from lexer |
||
| 109 | * |
||
| 110 | * @return ExpressionToken |
||
| 111 | */ |
||
| 112 | private function _getCurrentToken() |
||
| 113 | { |
||
| 114 | return $this->_lexer->getCurrentToken(); |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Set the current token in lexer |
||
| 119 | * |
||
| 120 | * @param ExpressionToken $token The token to set as current token. |
||
| 121 | * |
||
| 122 | * @return void |
||
| 123 | */ |
||
| 124 | private function _setCurrentToken($token) |
||
| 125 | { |
||
| 126 | $this->_lexer->setCurrentToken($token); |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Resets parser with new expression string. |
||
| 131 | * |
||
| 132 | * @param string $text Reset the expression to parse. |
||
| 133 | * |
||
| 134 | * @return void |
||
| 135 | */ |
||
| 136 | public function resetParser($text) |
||
| 137 | { |
||
| 138 | $this->_lexer = new ExpressionLexer($text); |
||
| 139 | $this->_recursionDepth = 0; |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Parse the expression in filter option. |
||
| 144 | * |
||
| 145 | * @return AbstractExpression |
||
| 146 | */ |
||
| 147 | public function parseFilter() |
||
| 148 | { |
||
| 149 | return $this->_parseExpression(); |
||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Start parsing the expression |
||
| 154 | * |
||
| 155 | * @return AbstractExpression |
||
| 156 | */ |
||
| 157 | private function _parseExpression() |
||
| 158 | { |
||
| 159 | $this->_recurseEnter(); |
||
| 160 | $expr = $this->_parseLogicalOr(); |
||
| 161 | $this->_recurseLeave(); |
||
| 162 | return $expr; |
||
| 163 | } |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Parse logical or (or) |
||
| 167 | * |
||
| 168 | * @return AbstractExpression |
||
| 169 | */ |
||
| 170 | private function _parseLogicalOr() |
||
| 171 | { |
||
| 172 | $this->_recurseEnter(); |
||
| 173 | $left = $this->_parseLogicalAnd(); |
||
| 174 | while ($this->_tokenIdentifierIs(ODataConstants::KEYWORD_OR)) { |
||
| 175 | $logicalOpToken = clone $this->_getCurrentToken(); |
||
| 176 | $this->_lexer->nextToken(); |
||
| 177 | $right = $this->_parseLogicalAnd(); |
||
| 178 | FunctionDescription::verifyLogicalOpArguments($logicalOpToken, $left, $right); |
||
| 179 | $left = new LogicalExpression( |
||
| 180 | $left, $right, ExpressionType::OR_LOGICAL |
||
| 181 | ); |
||
| 182 | } |
||
| 183 | |||
| 184 | $this->_recurseLeave(); |
||
| 185 | return $left; |
||
| 186 | } |
||
| 187 | |||
| 188 | /** |
||
| 189 | * Parse logical and (and). |
||
| 190 | * |
||
| 191 | * @return AbstractExpression |
||
| 192 | */ |
||
| 193 | private function _parseLogicalAnd() |
||
| 194 | { |
||
| 195 | $this->_recurseEnter(); |
||
| 196 | $left = $this->_parseComparison(); |
||
| 197 | while ($this->_tokenIdentifierIs(ODataConstants::KEYWORD_AND)) { |
||
| 198 | $logicalOpToken = clone $this->_getCurrentToken(); |
||
| 199 | $this->_lexer->nextToken(); |
||
| 200 | $right = $this->_parseComparison(); |
||
| 201 | FunctionDescription::verifyLogicalOpArguments($logicalOpToken, $left, $right); |
||
| 202 | $left = new LogicalExpression($left, $right, ExpressionType::AND_LOGICAL); |
||
| 203 | } |
||
| 204 | |||
| 205 | $this->_recurseLeave(); |
||
| 206 | return $left; |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Parse comparison operation (eq, ne, gt, ge, lt, le) |
||
| 211 | * TODO: http://host/service/Products?$filter=Name in ('Milk', 'Cheese') |
||
| 212 | * TODO: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html |
||
| 213 | * @return AbstractExpression |
||
| 214 | */ |
||
| 215 | private function _parseComparison() |
||
| 216 | { |
||
| 217 | $this->_recurseEnter(); |
||
| 218 | $left = $this->_parseAdditive(); |
||
| 219 | while ($this->_getCurrentToken()->isComparisonOperator()) { |
||
| 220 | $comparisonToken = clone $this->_getCurrentToken(); |
||
| 221 | $this->_lexer->nextToken(); |
||
| 222 | $right = $this->_parseAdditive(); |
||
| 223 | $left = self::_generateComparisonExpression( |
||
| 224 | $left, $right, |
||
| 225 | $comparisonToken, $this->_isPHPExpressionProvider |
||
| 226 | ); |
||
| 227 | } |
||
| 228 | |||
| 229 | $this->_recurseLeave(); |
||
| 230 | return $left; |
||
| 231 | } |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Parse additive operation (add, sub). |
||
| 235 | * |
||
| 236 | * @return AbstractExpression |
||
| 237 | */ |
||
| 238 | private function _parseAdditive() |
||
| 239 | { |
||
| 240 | $this->_recurseEnter(); |
||
| 241 | $left = $this->_parseMultiplicative(); |
||
| 242 | while ($this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_ADD) |
||
| 243 | || $this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_SUB)) { |
||
| 244 | $additiveToken = clone $this->_getCurrentToken(); |
||
| 245 | $this->_lexer->nextToken(); |
||
| 246 | $right = $this->_parseMultiplicative(); |
||
| 247 | $opReturnType = FunctionDescription::verifyAndPromoteArithmeticOpArguments($additiveToken, $left, $right); |
||
| 248 | if ($additiveToken->identifierIs(ODataConstants::KEYWORD_ADD)) { |
||
| 249 | $left = new ArithmeticExpression($left, $right, ExpressionType::ADD, $opReturnType); |
||
| 250 | } else { |
||
| 251 | $left = new ArithmeticExpression($left, $right, ExpressionType::SUBTRACT, $opReturnType); |
||
| 252 | } |
||
| 253 | } |
||
| 254 | |||
| 255 | $this->_recurseLeave(); |
||
| 256 | return $left; |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Parse multipicative operators (mul, div, mod) |
||
| 261 | * |
||
| 262 | * @return AbstractExpression |
||
| 263 | */ |
||
| 264 | private function _parseMultiplicative() |
||
| 265 | { |
||
| 266 | $this->_recurseEnter(); |
||
| 267 | $left = $this->_parseUnary(); |
||
| 268 | while ($this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_MULTIPLY) |
||
| 269 | || $this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_DIVIDE) |
||
| 270 | || $this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_MODULO) |
||
| 271 | ) { |
||
| 272 | $multiplicativeToken = clone $this->_getCurrentToken(); |
||
| 273 | $this->_lexer->nextToken(); |
||
| 274 | $right = $this->_parseUnary(); |
||
| 275 | $opReturnType = FunctionDescription::verifyAndPromoteArithmeticOpArguments( |
||
| 276 | $multiplicativeToken, $left, $right |
||
| 277 | ); |
||
| 278 | if ($multiplicativeToken->identifierIs(ODataConstants::KEYWORD_MULTIPLY)) { |
||
| 279 | $left = new ArithmeticExpression($left, $right, ExpressionType::MULTIPLY, $opReturnType); |
||
| 280 | } else if ($multiplicativeToken->identifierIs(ODataConstants::KEYWORD_DIVIDE)) { |
||
| 281 | $left = new ArithmeticExpression($left, $right, ExpressionType::DIVIDE, $opReturnType); |
||
| 282 | } else { |
||
| 283 | $left = new ArithmeticExpression($left, $right, ExpressionType::MODULO, $opReturnType); |
||
| 284 | } |
||
| 285 | } |
||
| 286 | |||
| 287 | $this->_recurseLeave(); |
||
| 288 | return $left; |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Parse unary operator (- ,not) |
||
| 293 | * |
||
| 294 | * @return AbstractExpression |
||
| 295 | */ |
||
| 296 | private function _parseUnary() |
||
| 297 | { |
||
| 298 | $this->_recurseEnter(); |
||
| 299 | |||
| 300 | if ($this->_getCurrentToken()->Id == ExpressionTokenId::MINUS |
||
| 301 | || $this->_getCurrentToken()->identifierIs(ODataConstants::KEYWORD_NOT) |
||
| 302 | ) { |
||
| 303 | $op = clone $this->_getCurrentToken(); |
||
| 304 | $this->_lexer->nextToken(); |
||
| 305 | if ($op->Id == ExpressionTokenId::MINUS |
||
| 306 | && (ExpressionLexer::isNumeric($this->_getCurrentToken()->Id)) |
||
| 307 | ) { |
||
| 308 | $numberLiteral = $this->_getCurrentToken(); |
||
| 309 | $numberLiteral->Text = '-' . $numberLiteral->Text; |
||
| 310 | $numberLiteral->Position = $op->Position; |
||
| 311 | $v = $this->_getCurrentToken(); |
||
| 312 | $this->_setCurrentToken($numberLiteral); |
||
| 313 | $this->_recurseLeave(); |
||
| 314 | return $this->_parsePrimary(); |
||
| 315 | } |
||
| 316 | |||
| 317 | $expr = $this->_parsePrimary(); |
||
| 318 | FunctionDescription::validateUnaryOpArguments($op, $expr); |
||
| 319 | if ($op->Id == ExpressionTokenId::MINUS) { |
||
| 320 | $expr = new UnaryExpression($expr, ExpressionType::NEGATE, $expr->getType()); |
||
| 321 | } else { |
||
| 322 | $expr = new UnaryExpression($expr, ExpressionType::NOT_LOGICAL, new Boolean()); |
||
| 323 | } |
||
| 324 | |||
| 325 | $this->_recurseLeave(); |
||
| 326 | return $expr; |
||
| 327 | } |
||
| 328 | |||
| 329 | $this->_recurseLeave(); |
||
| 330 | return $this->_parsePrimary(); |
||
| 331 | } |
||
| 332 | |||
| 333 | /** |
||
| 334 | * Start parsing the primary. |
||
| 335 | * |
||
| 336 | * @return AbstractExpression |
||
| 337 | */ |
||
| 338 | private function _parsePrimary() |
||
| 339 | { |
||
| 340 | $this->_recurseEnter(); |
||
| 341 | $expr = $this->_parsePrimaryStart(); |
||
| 342 | while (true) { |
||
| 343 | if ($this->_getCurrentToken()->Id == ExpressionTokenId::SLASH) { |
||
| 344 | $this->_lexer->nextToken(); |
||
| 345 | $expr = $this->_parsePropertyAccess($expr); |
||
| 346 | } else { |
||
| 347 | break; |
||
| 348 | } |
||
| 349 | } |
||
| 350 | |||
| 351 | $this->_recurseLeave(); |
||
| 352 | return $expr; |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * Parse primary tokens [literals, identifiers (e.g. function call), open param for sub expressions] |
||
| 357 | * |
||
| 358 | * |
||
| 359 | * @return AbstractExpression |
||
| 360 | */ |
||
| 361 | private function _parsePrimaryStart() |
||
| 362 | { |
||
| 363 | switch ($this->_lexer->getCurrentToken()->Id) { |
||
| 364 | case ExpressionTokenId::BOOLEAN_LITERAL: |
||
| 365 | return $this->_parseTypedLiteral(new Boolean()); |
||
| 366 | case ExpressionTokenId::DATETIME_LITERAL: |
||
| 367 | return $this->_parseTypedLiteral(new DateTime()); |
||
| 368 | case ExpressionTokenId::DECIMAL_LITERAL: |
||
| 369 | return $this->_parseTypedLiteral(new Decimal()); |
||
| 370 | case ExpressionTokenId::NULL_LITERAL: |
||
| 371 | return $this->_parseNullLiteral(); |
||
| 372 | case ExpressionTokenId::IDENTIFIER: |
||
| 373 | return $this->_parseIdentifier(); |
||
| 374 | case ExpressionTokenId::STRING_LITERAL: |
||
| 375 | return $this->_parseTypedLiteral(new StringType()); |
||
| 376 | case ExpressionTokenId::INT64_LITERAL: |
||
| 377 | return $this->_parseTypedLiteral(new Int64()); |
||
| 378 | case ExpressionTokenId::INTEGER_LITERAL: |
||
| 379 | return $this->_parseTypedLiteral(new Int32()); |
||
| 380 | case ExpressionTokenId::DOUBLE_LITERAL: |
||
| 381 | return $this->_parseTypedLiteral(new Double()); |
||
| 382 | case ExpressionTokenId::SINGLE_LITERAL: |
||
| 383 | return $this->_parseTypedLiteral(new Single()); |
||
| 384 | case ExpressionTokenId::GUID_LITERAL: |
||
| 385 | return $this->_parseTypedLiteral(new Guid()); |
||
| 386 | case ExpressionTokenId::BINARY_LITERAL: |
||
| 387 | throw new NotImplementedException( |
||
| 388 | 'Support for binary is not implemented' |
||
| 389 | ); |
||
| 390 | //return $this->_parseTypedLiteral(new Binary()); |
||
| 391 | case ExpressionTokenId::OPENPARAM: |
||
| 392 | return $this->_parseParenExpression(); |
||
| 393 | default: |
||
| 394 | throw ODataException::createSyntaxError("Expression expected."); |
||
| 395 | } |
||
| 396 | } |
||
| 397 | |||
| 398 | /** |
||
| 399 | * Parse Sub expression. |
||
| 400 | * |
||
| 401 | * @return AbstractExpression |
||
| 402 | */ |
||
| 403 | private function _parseParenExpression() |
||
| 404 | { |
||
| 405 | if ($this->_getCurrentToken()->Id != ExpressionTokenId::OPENPARAM) { |
||
| 406 | throw ODataException::createSyntaxError("Open parenthesis expected."); |
||
| 407 | } |
||
| 408 | |||
| 409 | $this->_lexer->nextToken(); |
||
| 410 | $expr = $this->_parseExpression(); |
||
| 411 | if ($this->_getCurrentToken()->Id != ExpressionTokenId::CLOSEPARAM) { |
||
| 412 | throw ODataException::createSyntaxError("Close parenthesis expected."); |
||
| 413 | } |
||
| 414 | |||
| 415 | $this->_lexer->nextToken(); |
||
| 416 | return $expr; |
||
| 417 | } |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Parse an identifier |
||
| 421 | * |
||
| 422 | * @return AbstractExpression |
||
| 423 | */ |
||
| 424 | private function _parseIdentifier() |
||
| 425 | { |
||
| 426 | $this->_validateToken(ExpressionTokenId::IDENTIFIER); |
||
| 427 | |||
| 428 | // An open paren here would indicate calling a method |
||
| 429 | $identifierIsFunction = $this->_lexer->peekNextToken()->Id == ExpressionTokenId::OPENPARAM; |
||
| 430 | if ($identifierIsFunction) { |
||
| 431 | return $this->_parseIdentifierAsFunction(); |
||
| 432 | } else { |
||
| 433 | return $this->_parsePropertyAccess(null); |
||
| 434 | } |
||
| 435 | } |
||
| 436 | |||
| 437 | /** |
||
| 438 | * Parse a property access |
||
| 439 | * |
||
| 440 | * @param PropertyAccessExpression $parentExpression Parent expression. |
||
| 441 | * |
||
| 442 | * @throws ODataException |
||
| 443 | * |
||
| 444 | * @return PropertyAccessExpression |
||
| 445 | */ |
||
| 446 | private function _parsePropertyAccess($parentExpression) |
||
| 482 | } |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Try to parse an identifier which is followed by an opern bracket as |
||
| 486 | * astoria URI function call. |
||
| 487 | * |
||
| 488 | * @return AbstractExpression |
||
| 489 | * |
||
| 490 | * @throws ODataException |
||
| 491 | */ |
||
| 492 | private function _parseIdentifierAsFunction() |
||
| 493 | { |
||
| 494 | $functionToken = clone $this->_getCurrentToken(); |
||
| 495 | $functions = FunctionDescription::verifyFunctionExists($functionToken); |
||
| 496 | $this->_lexer->nextToken(); |
||
| 497 | $paramExpressions = $this->_parseArgumentList(); |
||
| 498 | $function = FunctionDescription::verifyFunctionCallOpArguments( |
||
| 499 | $functions, $paramExpressions, $functionToken |
||
| 500 | ); |
||
| 501 | return new FunctionCallExpression($function, $paramExpressions); |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * Start parsing argument list of a function-call |
||
| 506 | * |
||
| 507 | * @return array<AbstractExpression> |
||
| 508 | */ |
||
| 509 | private function _parseArgumentList() |
||
| 510 | { |
||
| 511 | if ($this->_getCurrentToken()->Id != ExpressionTokenId::OPENPARAM) { |
||
| 512 | throw ODataException::createSyntaxError("Open parenthesis expected."); |
||
| 513 | } |
||
| 514 | |||
| 515 | $this->_lexer->nextToken(); |
||
| 516 | $args |
||
| 517 | = $this->_getCurrentToken()->Id != ExpressionTokenId::CLOSEPARAM |
||
| 518 | ? $this->_parseArguments() : array(); |
||
| 519 | if ($this->_getCurrentToken()->Id != ExpressionTokenId::CLOSEPARAM) { |
||
| 520 | throw ODataException::createSyntaxError("Close parenthesis expected."); |
||
| 521 | } |
||
| 522 | |||
| 523 | $this->_lexer->nextToken(); |
||
| 524 | return $args; |
||
| 525 | } |
||
| 526 | |||
| 527 | /** |
||
| 528 | * Parse arguments of a function-call. |
||
| 529 | * |
||
| 530 | * @return array<AbstractExpression> |
||
| 531 | */ |
||
| 532 | private function _parseArguments() |
||
| 533 | { |
||
| 534 | $argList = array(); |
||
| 535 | while (true) { |
||
| 536 | $argList[] = $this->_parseExpression(); |
||
| 537 | if ($this->_getCurrentToken()->Id != ExpressionTokenId::COMMA) { |
||
| 538 | break; |
||
| 539 | } |
||
| 540 | |||
| 541 | $this->_lexer->nextToken(); |
||
| 542 | } |
||
| 543 | |||
| 544 | return $argList; |
||
| 545 | } |
||
| 546 | |||
| 547 | /** |
||
| 548 | * Parse primitive type literal. |
||
| 549 | * |
||
| 550 | * @param IType $targetType Expected type of the current literal. |
||
| 551 | * |
||
| 552 | * @return AbstractExpression |
||
| 553 | * |
||
| 554 | * @throws ODataException |
||
| 555 | */ |
||
| 556 | private function _parseTypedLiteral(IType $targetType) |
||
| 557 | { |
||
| 558 | $literal = $this->_lexer->getCurrentToken()->Text; |
||
| 559 | $outVal = null; |
||
| 560 | if (!$targetType->validate($literal, $outVal)) { |
||
| 561 | throw ODataException::createSyntaxError( |
||
| 562 | Messages::expressionParserUnrecognizedLiteral( |
||
| 563 | $targetType->getFullTypeName(), |
||
| 564 | $literal, |
||
| 565 | $this->_lexer->getCurrentToken()->Position |
||
| 566 | ) |
||
| 567 | ); |
||
| 568 | } |
||
| 569 | |||
| 570 | $result = new ConstantExpression($outVal, $targetType); |
||
| 571 | $this->_lexer->nextToken(); |
||
| 572 | return $result; |
||
| 573 | } |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Parse null literal. |
||
| 577 | * |
||
| 578 | * @return ConstantExpression |
||
| 579 | */ |
||
| 580 | private function _parseNullLiteral() |
||
| 584 | } |
||
| 585 | |||
| 586 | /** |
||
| 587 | * Check the current token is of a specific kind |
||
| 588 | * |
||
| 589 | * @param ExpressionTokenId $expressionTokenId Token to check |
||
| 590 | * with current token. |
||
| 591 | * |
||
| 592 | * @return boolean |
||
| 593 | */ |
||
| 594 | private function _tokenIdentifierIs($expressionTokenId) |
||
| 595 | { |
||
| 596 | return $this->_getCurrentToken()->identifierIs($expressionTokenId); |
||
| 597 | } |
||
| 598 | |||
| 599 | /** |
||
| 600 | * Validate the current token |
||
| 601 | * |
||
| 602 | * @param ExpressionTokenId $expressionTokenId Token to check |
||
| 603 | * with current token. |
||
| 604 | * |
||
| 605 | * @return void |
||
| 606 | * |
||
| 607 | * @throws ODataException |
||
| 608 | */ |
||
| 609 | private function _validateToken($expressionTokenId) |
||
| 613 | } |
||
| 614 | } |
||
| 615 | |||
| 616 | /** |
||
| 617 | * Increment recursion count and throw error if beyond limit |
||
| 618 | * |
||
| 619 | * @return void |
||
| 620 | * |
||
| 621 | * @throws ODataException If max recursion limit hits. |
||
| 622 | */ |
||
| 623 | private function _recurseEnter() |
||
| 624 | { |
||
| 625 | $this->_recursionDepth++; |
||
| 626 | if ($this->_recursionDepth == self::RECURSION_LIMIT) { |
||
| 627 | throw ODataException::createSyntaxError("Recursion limit reached."); |
||
| 628 | } |
||
| 629 | } |
||
| 630 | |||
| 631 | /** |
||
| 632 | * Decrement recursion count |
||
| 633 | * |
||
| 634 | * @return void |
||
| 635 | */ |
||
| 636 | private function _recurseLeave() |
||
| 637 | { |
||
| 638 | $this->_recursionDepth--; |
||
| 639 | } |
||
| 640 | |||
| 641 | /** |
||
| 642 | * Generates Comparison Expression |
||
| 643 | * |
||
| 644 | * @param AbstractExpression $left The LHS expression. |
||
| 645 | * @param AbstractExpression $right The RHS expression. |
||
| 646 | * @param ExpressionToken $expressionToken The comparison expression token. |
||
| 647 | * @param boolean $isPHPExpressionProvider |
||
| 648 | * |
||
| 649 | * @return AbstractExpression |
||
| 650 | */ |
||
| 651 | private static function _generateComparisonExpression($left, $right, $expressionToken, $isPHPExpressionProvider) |
||
| 767 | ); |
||
| 768 | } |
||
| 769 | } |
||
| 770 | |||
| 771 | } |
||
| 772 |