()
| 1118 | } |
| 1119 | |
| 1120 | private parsePrimary(): AST { |
| 1121 | const start = this.inputIndex; |
| 1122 | if (this.isArrowFunction()) { |
| 1123 | return this.parseArrowFunction(start); |
| 1124 | } else if (this.consumeOptionalCharacter(chars.$LPAREN)) { |
| 1125 | this.rparensExpected++; |
| 1126 | const result = this.parsePipe(); |
| 1127 | if (!this.consumeOptionalCharacter(chars.$RPAREN)) { |
| 1128 | this.error('Missing closing parentheses'); |
| 1129 | // Calling into `error` above will attempt to recover up until the next closing paren. |
| 1130 | // If that's the case, consume it so we can partially recover the expression. |
| 1131 | this.consumeOptionalCharacter(chars.$RPAREN); |
| 1132 | } |
| 1133 | this.rparensExpected--; |
| 1134 | return new ParenthesizedExpression(this.span(start), this.sourceSpan(start), result); |
| 1135 | } else if (this.next.isKeywordNull()) { |
| 1136 | this.advance(); |
| 1137 | return new LiteralPrimitive(this.span(start), this.sourceSpan(start), null); |
| 1138 | } else if (this.next.isKeywordUndefined()) { |
| 1139 | this.advance(); |
| 1140 | return new LiteralPrimitive(this.span(start), this.sourceSpan(start), undefined); |
| 1141 | } else if (this.next.isKeywordTrue()) { |
| 1142 | this.advance(); |
| 1143 | return new LiteralPrimitive(this.span(start), this.sourceSpan(start), true); |
| 1144 | } else if (this.next.isKeywordFalse()) { |
| 1145 | this.advance(); |
| 1146 | return new LiteralPrimitive(this.span(start), this.sourceSpan(start), false); |
| 1147 | } else if (this.next.isKeywordThis()) { |
| 1148 | this.advance(); |
| 1149 | return new ThisReceiver(this.span(start), this.sourceSpan(start)); |
| 1150 | } else if (this.consumeOptionalCharacter(chars.$LBRACKET)) { |
| 1151 | return this.parseLiteralArray(start); |
| 1152 | } else if (this.next.isCharacter(chars.$LBRACE)) { |
| 1153 | return this.parseLiteralMap(); |
| 1154 | } else if (this.next.isIdentifier()) { |
| 1155 | return this.parseAccessMember( |
| 1156 | new ImplicitReceiver(this.span(start), this.sourceSpan(start)), |
| 1157 | start, |
| 1158 | false, |
| 1159 | ); |
| 1160 | } else if (this.next.isNumber()) { |
| 1161 | const value = this.next.toNumber(); |
| 1162 | this.advance(); |
| 1163 | return new LiteralPrimitive(this.span(start), this.sourceSpan(start), value); |
| 1164 | } else if (this.next.isTemplateLiteralEnd()) { |
| 1165 | return this.parseNoInterpolationTemplateLiteral(); |
| 1166 | } else if (this.next.isTemplateLiteralPart()) { |
| 1167 | return this.parseTemplateLiteral(); |
| 1168 | } else if (this.next.isString() && this.next.kind === StringTokenKind.Plain) { |
| 1169 | const literalValue = this.next.toString(); |
| 1170 | this.advance(); |
| 1171 | return new LiteralPrimitive(this.span(start), this.sourceSpan(start), literalValue); |
| 1172 | } else if (this.next.isPrivateIdentifier()) { |
| 1173 | this._reportErrorForPrivateIdentifier(this.next, null); |
| 1174 | return new EmptyExpr(this.span(start), this.sourceSpan(start)); |
| 1175 | } else if (this.next.isRegExpBody()) { |
| 1176 | return this.parseRegularExpressionLiteral(); |
| 1177 | } else if (this.index >= this.tokens.length) { |
no test coverage detected