()
| 1105 | } |
| 1106 | |
| 1107 | private parseCallChain(): AST { |
| 1108 | const start = this.inputIndex; |
| 1109 | let result = this.parsePrimary(); |
| 1110 | while (true) { |
| 1111 | if (this.consumeOptionalCharacter(chars.$PERIOD)) { |
| 1112 | result = this.parseAccessMember(result, start, false); |
| 1113 | } else if (this.consumeOptionalOperator('?.')) { |
| 1114 | if (this.consumeOptionalCharacter(chars.$LPAREN)) { |
| 1115 | result = this.parseCall(result, start, true); |
| 1116 | } else { |
| 1117 | result = this.consumeOptionalCharacter(chars.$LBRACKET) |
| 1118 | ? this.parseKeyedReadOrWrite(result, start, true) |
| 1119 | : this.parseAccessMember(result, start, true); |
| 1120 | } |
| 1121 | } else if (this.consumeOptionalCharacter(chars.$LBRACKET)) { |
| 1122 | result = this.parseKeyedReadOrWrite(result, start, false); |
| 1123 | } else if (this.consumeOptionalCharacter(chars.$LPAREN)) { |
| 1124 | result = this.parseCall(result, start, false); |
| 1125 | } else if (this.consumeOptionalOperator('!')) { |
| 1126 | result = new NonNullAssert(this.span(start), this.sourceSpan(start), result); |
| 1127 | } else if (this.next.isTemplateLiteralEnd()) { |
| 1128 | result = this.parseNoInterpolationTaggedTemplateLiteral(result, start); |
| 1129 | } else if (this.next.isTemplateLiteralPart()) { |
| 1130 | result = this.parseTaggedTemplateLiteral(result, start); |
| 1131 | } else { |
| 1132 | break; |
| 1133 | } |
| 1134 | } |
| 1135 | |
| 1136 | if (this.next.isOperator('++') || this.next.isOperator('--')) { |
| 1137 | // Note: we need to capture this here before we advance. |
| 1138 | const operator = this.next.strValue as '++' | '--'; |
| 1139 | this.advance(); |
| 1140 | return this.validateIncrementDecrementTarget(result) |
| 1141 | ? Unary.createPostfixUpdate(this.span(start), this.sourceSpan(start), operator, result) |
| 1142 | : new EmptyExpr(this.span(start), this.sourceSpan(start)); |
| 1143 | } |
| 1144 | |
| 1145 | return result; |
| 1146 | } |
| 1147 | |
| 1148 | private parsePrimary(): AST { |
| 1149 | const start = this.inputIndex; |
no test coverage detected