()
| 7355 | } |
| 7356 | |
| 7357 | function parseImportDeclaration() { |
| 7358 | var specifiers, src, marker = markerCreate(), isType = false, token2; |
| 7359 | |
| 7360 | expectKeyword('import'); |
| 7361 | |
| 7362 | if (matchContextualKeyword('type')) { |
| 7363 | token2 = lookahead2(); |
| 7364 | if ((token2.type === Token.Identifier && token2.value !== 'from') || |
| 7365 | (token2.type === Token.Punctuator && |
| 7366 | (token2.value === '{' || token2.value === '*'))) { |
| 7367 | isType = true; |
| 7368 | lex(); |
| 7369 | } |
| 7370 | } |
| 7371 | |
| 7372 | specifiers = []; |
| 7373 | |
| 7374 | if (lookahead.type === Token.StringLiteral) { |
| 7375 | // covers: |
| 7376 | // import "foo"; |
| 7377 | src = parseModuleSpecifier(); |
| 7378 | consumeSemicolon(); |
| 7379 | return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType)); |
| 7380 | } |
| 7381 | |
| 7382 | if (!matchKeyword('default') && isIdentifierName(lookahead)) { |
| 7383 | // covers: |
| 7384 | // import foo |
| 7385 | // import foo, ... |
| 7386 | specifiers.push(parseImportDefaultSpecifier()); |
| 7387 | if (match(',')) { |
| 7388 | lex(); |
| 7389 | } |
| 7390 | } |
| 7391 | if (match('*')) { |
| 7392 | // covers: |
| 7393 | // import foo, * as foo |
| 7394 | // import * as foo |
| 7395 | specifiers.push(parseImportNamespaceSpecifier()); |
| 7396 | } else if (match('{')) { |
| 7397 | // covers: |
| 7398 | // import foo, {bar} |
| 7399 | // import {bar} |
| 7400 | specifiers = specifiers.concat(parseNamedImports()); |
| 7401 | } |
| 7402 | |
| 7403 | if (!matchContextualKeyword('from')) { |
| 7404 | throwError({}, lookahead.value ? |
| 7405 | Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); |
| 7406 | } |
| 7407 | lex(); |
| 7408 | src = parseModuleSpecifier(); |
| 7409 | consumeSemicolon(); |
| 7410 | |
| 7411 | return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType)); |
| 7412 | } |
| 7413 | |
| 7414 | // 12.3 Empty Statement |
no test coverage detected