1 | "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _types = require('../parser/tokenizer/types');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | function getImportExportSpecifierInfo(
|
42 | tokens,
|
43 | index = tokens.currentIndex(),
|
44 | ) {
|
45 | let endIndex = index + 1;
|
46 | if (isSpecifierEnd(tokens, endIndex)) {
|
47 |
|
48 | const name = tokens.identifierNameAtIndex(index);
|
49 | return {
|
50 | isType: false,
|
51 | leftName: name,
|
52 | rightName: name,
|
53 | endIndex,
|
54 | };
|
55 | }
|
56 | endIndex++;
|
57 | if (isSpecifierEnd(tokens, endIndex)) {
|
58 |
|
59 | return {
|
60 | isType: true,
|
61 | leftName: null,
|
62 | rightName: null,
|
63 | endIndex,
|
64 | };
|
65 | }
|
66 | endIndex++;
|
67 | if (isSpecifierEnd(tokens, endIndex)) {
|
68 |
|
69 | return {
|
70 | isType: false,
|
71 | leftName: tokens.identifierNameAtIndex(index),
|
72 | rightName: tokens.identifierNameAtIndex(index + 2),
|
73 | endIndex,
|
74 | };
|
75 | }
|
76 | endIndex++;
|
77 | if (isSpecifierEnd(tokens, endIndex)) {
|
78 |
|
79 | return {
|
80 | isType: true,
|
81 | leftName: null,
|
82 | rightName: null,
|
83 | endIndex,
|
84 | };
|
85 | }
|
86 | throw new Error(`Unexpected import/export specifier at ${index}`);
|
87 | } exports.default = getImportExportSpecifierInfo;
|
88 |
|
89 | function isSpecifierEnd(tokens, index) {
|
90 | const token = tokens.tokens[index];
|
91 | return token.type === _types.TokenType.braceR || token.type === _types.TokenType.comma;
|
92 | }
|