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