|
551 | 551 | var node = {type: "Field", name: token.value}; |
552 | 552 | if (this._lookahead(0) === TOK_LPAREN) { |
553 | 553 | throw new Error("Quoted identifier not allowed for function names."); |
554 | | - } else { |
555 | | - return node; |
556 | 554 | } |
| 555 | + return node; |
557 | 556 | case TOK_NOT: |
558 | 557 | right = this.expression(bindingPower.Not); |
559 | 558 | return {type: "NotExpression", children: [right]}; |
|
587 | 586 | right = this._parseProjectionRHS(bindingPower.Star); |
588 | 587 | return {type: "Projection", |
589 | 588 | children: [{type: "Identity"}, right]}; |
590 | | - } else { |
591 | | - return this._parseMultiselectList(); |
592 | 589 | } |
| 590 | + return this._parseMultiselectList(); |
593 | 591 | case TOK_CURRENT: |
594 | 592 | return {type: TOK_CURRENT}; |
595 | 593 | case TOK_EXPREF: |
|
621 | 619 | if (this._lookahead(0) !== TOK_STAR) { |
622 | 620 | right = this._parseDotRHS(rbp); |
623 | 621 | return {type: "Subexpression", children: [left, right]}; |
624 | | - } else { |
625 | | - // Creating a projection. |
626 | | - this._advance(); |
627 | | - right = this._parseProjectionRHS(rbp); |
628 | | - return {type: "ValueProjection", children: [left, right]}; |
629 | 622 | } |
| 623 | + // Creating a projection. |
| 624 | + this._advance(); |
| 625 | + right = this._parseProjectionRHS(rbp); |
| 626 | + return {type: "ValueProjection", children: [left, right]}; |
630 | 627 | case TOK_PIPE: |
631 | 628 | right = this.expression(bindingPower.Pipe); |
632 | 629 | return {type: TOK_PIPE, children: [left, right]}; |
|
680 | 677 | if (token.type === TOK_NUMBER || token.type === TOK_COLON) { |
681 | 678 | right = this._parseIndexExpression(); |
682 | 679 | return this._projectIfSlice(left, right); |
683 | | - } else { |
684 | | - this._match(TOK_STAR); |
685 | | - this._match(TOK_RBRACKET); |
686 | | - right = this._parseProjectionRHS(bindingPower.Star); |
687 | | - return {type: "Projection", children: [left, right]}; |
688 | 680 | } |
| 681 | + this._match(TOK_STAR); |
| 682 | + this._match(TOK_RBRACKET); |
| 683 | + right = this._parseProjectionRHS(bindingPower.Star); |
| 684 | + return {type: "Projection", children: [left, right]}; |
689 | 685 | default: |
690 | 686 | this._errorToken(this._lookaheadToken(0)); |
691 | 687 | } |
|
862 | 858 | var matched, current, result, first, second, field, left, right, collected, i; |
863 | 859 | switch (node.type) { |
864 | 860 | case "Field": |
865 | | - if (value === null ) { |
866 | | - return null; |
867 | | - } else if (isObject(value)) { |
| 861 | + if (value !== null && isObject(value)) { |
868 | 862 | field = value[node.name]; |
869 | 863 | if (field === undefined) { |
870 | 864 | return null; |
871 | 865 | } else { |
872 | 866 | return field; |
873 | 867 | } |
874 | | - } else { |
875 | | - return null; |
876 | 868 | } |
| 869 | + return null; |
877 | 870 | case "Subexpression": |
878 | 871 | result = this.visit(node.children[0], value); |
879 | 872 | for (i = 1; i < node.children.length; i++) { |
|
0 commit comments