@umijs/mfsu 4.0.2 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/babelPlugins/awaitImport/MFImport.d.ts +24 -0
  2. package/dist/babelPlugins/awaitImport/MFImport.js +68 -0
  3. package/dist/babelPlugins/awaitImport/checkMatch.d.ts +1 -0
  4. package/dist/babelPlugins/awaitImport/checkMatch.js +1 -0
  5. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +5 -2
  6. package/dist/babelPlugins/awaitImport/getAliasedPath.js +16 -2
  7. package/dist/dep/dep.d.ts +1 -1
  8. package/dist/dep/dep.js +1 -1
  9. package/dist/depBuilder/depBuilder.d.ts +1 -1
  10. package/dist/depInfo.d.ts +18 -4
  11. package/dist/depInfo.js +7 -0
  12. package/dist/esbuildHandlers/awaitImport/index.d.ts +3 -0
  13. package/dist/esbuildHandlers/awaitImport/index.js +30 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/{mfsu.d.ts → mfsu/mfsu.d.ts} +21 -25
  17. package/dist/{mfsu.js → mfsu/mfsu.js} +69 -75
  18. package/dist/mfsu/strategyCompileTime.d.ts +20 -0
  19. package/dist/mfsu/strategyCompileTime.js +100 -0
  20. package/dist/mfsu/strategyStaticAnalyze.d.ts +23 -0
  21. package/dist/mfsu/strategyStaticAnalyze.js +122 -0
  22. package/dist/moduleGraph.d.ts +3 -8
  23. package/dist/staticDepInfo/importParser.d.ts +4 -0
  24. package/dist/staticDepInfo/importParser.js +8 -0
  25. package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +15 -0
  26. package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -0
  27. package/dist/staticDepInfo/staticDepInfo.d.ts +56 -0
  28. package/dist/staticDepInfo/staticDepInfo.js +198 -0
  29. package/dist/webpackPlugins/buildDepPlugin.d.ts +4 -3
  30. package/dist/webpackPlugins/buildDepPlugin.js +8 -0
  31. package/package.json +11 -9
  32. package/vendors/importParser/_importParser.js +683 -0
  33. package/vendors/importParser/importParser.jison +105 -0
@@ -0,0 +1,683 @@
1
+ /* parser generated by jison 0.4.18 */
2
+ /*
3
+ Returns a Parser object of the following structure:
4
+
5
+ Parser: {
6
+ yy: {}
7
+ }
8
+
9
+ Parser.prototype: {
10
+ yy: {},
11
+ trace: function(),
12
+ symbols_: {associative list: name ==> number},
13
+ terminals_: {associative list: number ==> name},
14
+ productions_: [...],
15
+ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
16
+ table: [...],
17
+ defaultActions: {...},
18
+ parseError: function(str, hash),
19
+ parse: function(input),
20
+
21
+ lexer: {
22
+ EOF: 1,
23
+ parseError: function(str, hash),
24
+ setInput: function(input),
25
+ input: function(),
26
+ unput: function(str),
27
+ more: function(),
28
+ less: function(n),
29
+ pastInput: function(),
30
+ upcomingInput: function(),
31
+ showPosition: function(),
32
+ test_match: function(regex_match_array, rule_index),
33
+ next: function(),
34
+ lex: function(),
35
+ begin: function(condition),
36
+ popState: function(),
37
+ _currentRules: function(),
38
+ topState: function(),
39
+ pushState: function(condition),
40
+
41
+ options: {
42
+ ranges: boolean (optional: true ==> token location info will include a .range[] member)
43
+ flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
44
+ backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
45
+ },
46
+
47
+ performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
48
+ rules: [...],
49
+ conditions: {associative list: name ==> set},
50
+ }
51
+ }
52
+
53
+
54
+ token location info (@$, _$, etc.): {
55
+ first_line: n,
56
+ last_line: n,
57
+ first_column: n,
58
+ last_column: n,
59
+ range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
60
+ }
61
+
62
+
63
+ the parseError function receives a 'hash' object with these members for lexer and parser errors: {
64
+ text: (matched text)
65
+ token: (the produced terminal token, if any)
66
+ line: (yylineno)
67
+ }
68
+ while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
69
+ loc: (yylloc)
70
+ expected: (string describing the set of expected tokens)
71
+ recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
72
+ }
73
+ */
74
+ var _importParser = (function(){
75
+ var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[1,6],$V2=[1,6,25],$V3=[1,16],$V4=[1,15],$V5=[1,10],$V6=[1,22],$V7=[1,29],$V8=[1,34],$V9=[14,18];
76
+ var parser = {trace: function trace () { },
77
+ yy: {},
78
+ symbols_: {"error":2,"Program":3,"ImportStatements":4,"ImportStatement":5,"IMPORT":6,"ModuleSpecifier":7,"ImportClause":8,"FromClause":9,"ExportFromStatement":10,"ImportedDefaultBinding":11,"NameSpaceImport":12,"NamedImports":13,"COMMA":14,"ID":15,"LBRACE":16,"ImportsList":17,"RBRACE":18,"STAR":19,"AS":20,"ImportSpecifier":21,"FROM":22,"STRING":23,"Semicolon":24,"EXPORT":25,"ExportFromClause":26,"NamedExports":27,"ExportsList":28,"ExportSpecifier":29,"SEMICOLON":30,"$accept":0,"$end":1},
79
+ terminals_: {2:"error",6:"IMPORT",14:"COMMA",15:"ID",16:"LBRACE",18:"RBRACE",19:"STAR",20:"AS",22:"FROM",23:"STRING",25:"EXPORT",30:"SEMICOLON"},
80
+ productions_: [0,[3,1],[4,1],[4,2],[5,2],[5,3],[5,1],[8,1],[8,1],[8,1],[8,3],[8,3],[11,1],[13,3],[13,4],[12,3],[17,1],[17,3],[21,1],[21,3],[9,2],[7,2],[10,3],[26,1],[26,3],[26,1],[27,3],[27,4],[28,1],[28,3],[29,1],[29,3],[24,0],[24,1]],
81
+ performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
82
+ /* this == yyval */
83
+
84
+ var $0 = $$.length - 1;
85
+ switch (yystate) {
86
+ case 1:
87
+ return $$[$0]
88
+ break;
89
+ case 2: case 7: case 8: case 28:
90
+ this.$ = [ $$[$0] ]
91
+ break;
92
+ case 3:
93
+ this.$ = [ ...$$[$0-1], $$[$0] ]
94
+ break;
95
+ case 4:
96
+ this.$ = { from: $$[$0], imports: []}
97
+ break;
98
+ case 5:
99
+ this.$ = { from: $$[$0], imports: $$[$0-1] }
100
+ break;
101
+ case 10:
102
+ this.$ = [ $$[$0-2], $$[$0]]
103
+ break;
104
+ case 11:
105
+ this.$ = [ $$[$0-2], ...$$[$0]]
106
+ break;
107
+ case 12:
108
+ this.$ = 'default'
109
+ break;
110
+ case 13:
111
+ this.$=$$[$0-1]
112
+ break;
113
+ case 14:
114
+ this.$=$$[$0-2]
115
+ break;
116
+ case 15:
117
+ this.$ = '*'
118
+ break;
119
+ case 16:
120
+ this.$ = [ $$[$0] ]
121
+ break;
122
+ case 17:
123
+ this.$= [ ...$$[$0-2], $$[$0] ]
124
+ break;
125
+ case 19: case 27: case 31:
126
+ this.$ = $$[$0-2]
127
+ break;
128
+ case 20:
129
+ this.$=$$[$0]
130
+ break;
131
+ case 21:
132
+ this.$=$$[$0-1]
133
+ break;
134
+ case 22:
135
+ this.$ = {from: $$[$0], imports: $$[$0-1] }
136
+ break;
137
+ case 23: case 24:
138
+ this.$ = [ '*' ]
139
+ break;
140
+ case 26:
141
+ this.$ = $$[$0-1]
142
+ break;
143
+ case 29:
144
+ this.$ = [ ...$$[$0-2], $$[$0] ]
145
+ break;
146
+ }
147
+ },
148
+ table: [{3:1,4:2,5:3,6:$V0,10:5,25:$V1},{1:[3]},{1:[2,1],5:7,6:$V0,10:5,25:$V1},o($V2,[2,2]),{7:8,8:9,11:11,12:12,13:13,15:[1,14],16:$V3,19:$V4,23:$V5},o($V2,[2,6]),{16:[1,20],19:[1,18],26:17,27:19},o($V2,[2,3]),o($V2,[2,4]),{9:21,22:$V6},o($V2,[2,32],{24:23,30:[1,24]}),{14:[1,25],22:[2,7]},{22:[2,8]},{22:[2,9]},o([14,22],[2,12]),{20:[1,26]},{15:$V7,17:27,21:28},{9:30,22:$V6},{20:[1,31],22:[2,23]},{22:[2,25]},{15:$V8,28:32,29:33},o($V2,[2,5]),{7:35,23:$V5},o($V2,[2,21]),o($V2,[2,33]),{12:36,13:37,16:$V3,19:$V4},{15:[1,38]},{14:[1,40],18:[1,39]},o($V9,[2,16]),o($V9,[2,18],{20:[1,41]}),o($V2,[2,22]),{15:[1,42]},{14:[1,44],18:[1,43]},o($V9,[2,28]),o($V9,[2,30],{20:[1,45]}),o($V2,[2,20]),{22:[2,10]},{22:[2,11]},{22:[2,15]},{22:[2,13]},{15:$V7,18:[1,46],21:47},{15:[1,48]},{22:[2,24]},{22:[2,26]},{15:$V8,18:[1,49],29:50},{15:[1,51]},{22:[2,14]},o($V9,[2,17]),o($V9,[2,19]),{22:[2,27]},o($V9,[2,29]),o($V9,[2,31])],
149
+ defaultActions: {12:[2,8],13:[2,9],19:[2,25],36:[2,10],37:[2,11],38:[2,15],39:[2,13],42:[2,24],43:[2,26],46:[2,14],49:[2,27]},
150
+ parseError: function parseError (str, hash) {
151
+ if (hash.recoverable) {
152
+ this.trace(str);
153
+ } else {
154
+ var error = new Error(str);
155
+ error.hash = hash;
156
+ throw error;
157
+ }
158
+ },
159
+ parse: function parse(input) {
160
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
161
+ var args = lstack.slice.call(arguments, 1);
162
+ var lexer = Object.create(this.lexer);
163
+ var sharedState = { yy: {} };
164
+ for (var k in this.yy) {
165
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
166
+ sharedState.yy[k] = this.yy[k];
167
+ }
168
+ }
169
+ lexer.setInput(input, sharedState.yy);
170
+ sharedState.yy.lexer = lexer;
171
+ sharedState.yy.parser = this;
172
+ if (typeof lexer.yylloc == 'undefined') {
173
+ lexer.yylloc = {};
174
+ }
175
+ var yyloc = lexer.yylloc;
176
+ lstack.push(yyloc);
177
+ var ranges = lexer.options && lexer.options.ranges;
178
+ if (typeof sharedState.yy.parseError === 'function') {
179
+ this.parseError = sharedState.yy.parseError;
180
+ } else {
181
+ this.parseError = Object.getPrototypeOf(this).parseError;
182
+ }
183
+ function popStack(n) {
184
+ stack.length = stack.length - 2 * n;
185
+ vstack.length = vstack.length - n;
186
+ lstack.length = lstack.length - n;
187
+ }
188
+ _token_stack:
189
+ var lex = function () {
190
+ var token;
191
+ token = lexer.lex() || EOF;
192
+ if (typeof token !== 'number') {
193
+ token = self.symbols_[token] || token;
194
+ }
195
+ return token;
196
+ };
197
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
198
+ while (true) {
199
+ state = stack[stack.length - 1];
200
+ if (this.defaultActions[state]) {
201
+ action = this.defaultActions[state];
202
+ } else {
203
+ if (symbol === null || typeof symbol == 'undefined') {
204
+ symbol = lex();
205
+ }
206
+ action = table[state] && table[state][symbol];
207
+ }
208
+ if (typeof action === 'undefined' || !action.length || !action[0]) {
209
+ var errStr = '';
210
+ expected = [];
211
+ for (p in table[state]) {
212
+ if (this.terminals_[p] && p > TERROR) {
213
+ expected.push('\'' + this.terminals_[p] + '\'');
214
+ }
215
+ }
216
+ if (lexer.showPosition) {
217
+ errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
218
+ } else {
219
+ errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
220
+ }
221
+ this.parseError(errStr, {
222
+ text: lexer.match,
223
+ token: this.terminals_[symbol] || symbol,
224
+ line: lexer.yylineno,
225
+ loc: yyloc,
226
+ expected: expected
227
+ });
228
+ }
229
+ if (action[0] instanceof Array && action.length > 1) {
230
+ throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
231
+ }
232
+ switch (action[0]) {
233
+ case 1:
234
+ stack.push(symbol);
235
+ vstack.push(lexer.yytext);
236
+ lstack.push(lexer.yylloc);
237
+ stack.push(action[1]);
238
+ symbol = null;
239
+ if (!preErrorSymbol) {
240
+ yyleng = lexer.yyleng;
241
+ yytext = lexer.yytext;
242
+ yylineno = lexer.yylineno;
243
+ yyloc = lexer.yylloc;
244
+ if (recovering > 0) {
245
+ recovering--;
246
+ }
247
+ } else {
248
+ symbol = preErrorSymbol;
249
+ preErrorSymbol = null;
250
+ }
251
+ break;
252
+ case 2:
253
+ len = this.productions_[action[1]][1];
254
+ yyval.$ = vstack[vstack.length - len];
255
+ yyval._$ = {
256
+ first_line: lstack[lstack.length - (len || 1)].first_line,
257
+ last_line: lstack[lstack.length - 1].last_line,
258
+ first_column: lstack[lstack.length - (len || 1)].first_column,
259
+ last_column: lstack[lstack.length - 1].last_column
260
+ };
261
+ if (ranges) {
262
+ yyval._$.range = [
263
+ lstack[lstack.length - (len || 1)].range[0],
264
+ lstack[lstack.length - 1].range[1]
265
+ ];
266
+ }
267
+ r = this.performAction.apply(yyval, [
268
+ yytext,
269
+ yyleng,
270
+ yylineno,
271
+ sharedState.yy,
272
+ action[1],
273
+ vstack,
274
+ lstack
275
+ ].concat(args));
276
+ if (typeof r !== 'undefined') {
277
+ return r;
278
+ }
279
+ if (len) {
280
+ stack = stack.slice(0, -1 * len * 2);
281
+ vstack = vstack.slice(0, -1 * len);
282
+ lstack = lstack.slice(0, -1 * len);
283
+ }
284
+ stack.push(this.productions_[action[1]][0]);
285
+ vstack.push(yyval.$);
286
+ lstack.push(yyval._$);
287
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
288
+ stack.push(newState);
289
+ break;
290
+ case 3:
291
+ return true;
292
+ }
293
+ }
294
+ return true;
295
+ }};
296
+ /* generated by jison-lex 0.3.4 */
297
+ var lexer = (function(){
298
+ var lexer = ({
299
+
300
+ EOF:1,
301
+
302
+ parseError:function parseError(str, hash) {
303
+ if (this.yy.parser) {
304
+ this.yy.parser.parseError(str, hash);
305
+ } else {
306
+ throw new Error(str);
307
+ }
308
+ },
309
+
310
+ // resets the lexer, sets new input
311
+ setInput:function (input, yy) {
312
+ this.yy = yy || this.yy || {};
313
+ this._input = input;
314
+ this._more = this._backtrack = this.done = false;
315
+ this.yylineno = this.yyleng = 0;
316
+ this.yytext = this.matched = this.match = '';
317
+ this.conditionStack = ['INITIAL'];
318
+ this.yylloc = {
319
+ first_line: 1,
320
+ first_column: 0,
321
+ last_line: 1,
322
+ last_column: 0
323
+ };
324
+ if (this.options.ranges) {
325
+ this.yylloc.range = [0,0];
326
+ }
327
+ this.offset = 0;
328
+ return this;
329
+ },
330
+
331
+ // consumes and returns one char from the input
332
+ input:function () {
333
+ var ch = this._input[0];
334
+ this.yytext += ch;
335
+ this.yyleng++;
336
+ this.offset++;
337
+ this.match += ch;
338
+ this.matched += ch;
339
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
340
+ if (lines) {
341
+ this.yylineno++;
342
+ this.yylloc.last_line++;
343
+ } else {
344
+ this.yylloc.last_column++;
345
+ }
346
+ if (this.options.ranges) {
347
+ this.yylloc.range[1]++;
348
+ }
349
+
350
+ this._input = this._input.slice(1);
351
+ return ch;
352
+ },
353
+
354
+ // unshifts one char (or a string) into the input
355
+ unput:function (ch) {
356
+ var len = ch.length;
357
+ var lines = ch.split(/(?:\r\n?|\n)/g);
358
+
359
+ this._input = ch + this._input;
360
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
361
+ //this.yyleng -= len;
362
+ this.offset -= len;
363
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
364
+ this.match = this.match.substr(0, this.match.length - 1);
365
+ this.matched = this.matched.substr(0, this.matched.length - 1);
366
+
367
+ if (lines.length - 1) {
368
+ this.yylineno -= lines.length - 1;
369
+ }
370
+ var r = this.yylloc.range;
371
+
372
+ this.yylloc = {
373
+ first_line: this.yylloc.first_line,
374
+ last_line: this.yylineno + 1,
375
+ first_column: this.yylloc.first_column,
376
+ last_column: lines ?
377
+ (lines.length === oldLines.length ? this.yylloc.first_column : 0)
378
+ + oldLines[oldLines.length - lines.length].length - lines[0].length :
379
+ this.yylloc.first_column - len
380
+ };
381
+
382
+ if (this.options.ranges) {
383
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
384
+ }
385
+ this.yyleng = this.yytext.length;
386
+ return this;
387
+ },
388
+
389
+ // When called from action, caches matched text and appends it on next action
390
+ more:function () {
391
+ this._more = true;
392
+ return this;
393
+ },
394
+
395
+ // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
396
+ reject:function () {
397
+ if (this.options.backtrack_lexer) {
398
+ this._backtrack = true;
399
+ } else {
400
+ return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
401
+ text: "",
402
+ token: null,
403
+ line: this.yylineno
404
+ });
405
+
406
+ }
407
+ return this;
408
+ },
409
+
410
+ // retain first n characters of the match
411
+ less:function (n) {
412
+ this.unput(this.match.slice(n));
413
+ },
414
+
415
+ // displays already matched input, i.e. for error messages
416
+ pastInput:function () {
417
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
418
+ return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
419
+ },
420
+
421
+ // displays upcoming input, i.e. for error messages
422
+ upcomingInput:function () {
423
+ var next = this.match;
424
+ if (next.length < 20) {
425
+ next += this._input.substr(0, 20-next.length);
426
+ }
427
+ return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
428
+ },
429
+
430
+ // displays the character position where the lexing error occurred, i.e. for error messages
431
+ showPosition:function () {
432
+ var pre = this.pastInput();
433
+ var c = new Array(pre.length + 1).join("-");
434
+ return pre + this.upcomingInput() + "\n" + c + "^";
435
+ },
436
+
437
+ // test the lexed token: return FALSE when not a match, otherwise return token
438
+ test_match:function(match, indexed_rule) {
439
+ var token,
440
+ lines,
441
+ backup;
442
+
443
+ if (this.options.backtrack_lexer) {
444
+ // save context
445
+ backup = {
446
+ yylineno: this.yylineno,
447
+ yylloc: {
448
+ first_line: this.yylloc.first_line,
449
+ last_line: this.last_line,
450
+ first_column: this.yylloc.first_column,
451
+ last_column: this.yylloc.last_column
452
+ },
453
+ yytext: this.yytext,
454
+ match: this.match,
455
+ matches: this.matches,
456
+ matched: this.matched,
457
+ yyleng: this.yyleng,
458
+ offset: this.offset,
459
+ _more: this._more,
460
+ _input: this._input,
461
+ yy: this.yy,
462
+ conditionStack: this.conditionStack.slice(0),
463
+ done: this.done
464
+ };
465
+ if (this.options.ranges) {
466
+ backup.yylloc.range = this.yylloc.range.slice(0);
467
+ }
468
+ }
469
+
470
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
471
+ if (lines) {
472
+ this.yylineno += lines.length;
473
+ }
474
+ this.yylloc = {
475
+ first_line: this.yylloc.last_line,
476
+ last_line: this.yylineno + 1,
477
+ first_column: this.yylloc.last_column,
478
+ last_column: lines ?
479
+ lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
480
+ this.yylloc.last_column + match[0].length
481
+ };
482
+ this.yytext += match[0];
483
+ this.match += match[0];
484
+ this.matches = match;
485
+ this.yyleng = this.yytext.length;
486
+ if (this.options.ranges) {
487
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
488
+ }
489
+ this._more = false;
490
+ this._backtrack = false;
491
+ this._input = this._input.slice(match[0].length);
492
+ this.matched += match[0];
493
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
494
+ if (this.done && this._input) {
495
+ this.done = false;
496
+ }
497
+ if (token) {
498
+ return token;
499
+ } else if (this._backtrack) {
500
+ // recover context
501
+ for (var k in backup) {
502
+ this[k] = backup[k];
503
+ }
504
+ return false; // rule action called reject() implying the next rule should be tested instead.
505
+ }
506
+ return false;
507
+ },
508
+
509
+ // return next match in input
510
+ next:function () {
511
+ if (this.done) {
512
+ return this.EOF;
513
+ }
514
+ if (!this._input) {
515
+ this.done = true;
516
+ }
517
+
518
+ var token,
519
+ match,
520
+ tempMatch,
521
+ index;
522
+ if (!this._more) {
523
+ this.yytext = '';
524
+ this.match = '';
525
+ }
526
+ var rules = this._currentRules();
527
+ for (var i = 0; i < rules.length; i++) {
528
+ tempMatch = this._input.match(this.rules[rules[i]]);
529
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
530
+ match = tempMatch;
531
+ index = i;
532
+ if (this.options.backtrack_lexer) {
533
+ token = this.test_match(tempMatch, rules[i]);
534
+ if (token !== false) {
535
+ return token;
536
+ } else if (this._backtrack) {
537
+ match = false;
538
+ continue; // rule action called reject() implying a rule MISmatch.
539
+ } else {
540
+ // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
541
+ return false;
542
+ }
543
+ } else if (!this.options.flex) {
544
+ break;
545
+ }
546
+ }
547
+ }
548
+ if (match) {
549
+ token = this.test_match(match, rules[index]);
550
+ if (token !== false) {
551
+ return token;
552
+ }
553
+ // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
554
+ return false;
555
+ }
556
+ if (this._input === "") {
557
+ return this.EOF;
558
+ } else {
559
+ return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
560
+ text: "",
561
+ token: null,
562
+ line: this.yylineno
563
+ });
564
+ }
565
+ },
566
+
567
+ // return next match that has a token
568
+ lex:function lex () {
569
+ var r = this.next();
570
+ if (r) {
571
+ return r;
572
+ } else {
573
+ return this.lex();
574
+ }
575
+ },
576
+
577
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
578
+ begin:function begin (condition) {
579
+ this.conditionStack.push(condition);
580
+ },
581
+
582
+ // pop the previously active lexer condition state off the condition stack
583
+ popState:function popState () {
584
+ var n = this.conditionStack.length - 1;
585
+ if (n > 0) {
586
+ return this.conditionStack.pop();
587
+ } else {
588
+ return this.conditionStack[0];
589
+ }
590
+ },
591
+
592
+ // produce the lexer rule set which is active for the currently active lexer condition state
593
+ _currentRules:function _currentRules () {
594
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
595
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
596
+ } else {
597
+ return this.conditions["INITIAL"].rules;
598
+ }
599
+ },
600
+
601
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
602
+ topState:function topState (n) {
603
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
604
+ if (n >= 0) {
605
+ return this.conditionStack[n];
606
+ } else {
607
+ return "INITIAL";
608
+ }
609
+ },
610
+
611
+ // alias for begin(condition)
612
+ pushState:function pushState (condition) {
613
+ this.begin(condition);
614
+ },
615
+
616
+ // return the number of states currently on the stack
617
+ stateStackSize:function stateStackSize() {
618
+ return this.conditionStack.length;
619
+ },
620
+ options: {},
621
+ performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
622
+ var YYSTATE=YY_START;
623
+ switch($avoiding_name_collisions) {
624
+ case 0:/* skip whitespace */
625
+ break;
626
+ case 1:/* IGNORE line comment */
627
+ break;
628
+ case 2:/* IGNORE block comment */
629
+ break;
630
+ case 3:return 19
631
+ break;
632
+ case 4:return 20
633
+ break;
634
+ case 5:return 22
635
+ break;
636
+ case 6:return 6
637
+ break;
638
+ case 7:return 25
639
+ break;
640
+ case 8:return 16
641
+ break;
642
+ case 9:return 18
643
+ break;
644
+ case 10:return 14
645
+ break;
646
+ case 11:return 30
647
+ break;
648
+ case 12:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 23;
649
+ break;
650
+ case 13:return 15;
651
+ break;
652
+ }
653
+ },
654
+ rules: [/^(?:\s+)/,/^(?:\/\/.*)/,/^(?:\/\*((\*+[^/*])|([^*]))*\**\*\/)/,/^(?:\*)/,/^(?:as\b)/,/^(?:from\b)/,/^(?:import\b)/,/^(?:export\b)/,/^(?:\{)/,/^(?:\})/,/^(?:,)/,/^(?:;)/,/^(?:"[^\"]*"|'[^\']*')/,/^(?:[a-zA-Z_]\w*)/],
655
+ conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}}
656
+ });
657
+ return lexer;
658
+ })();
659
+ parser.lexer = lexer;
660
+ function Parser () {
661
+ this.yy = {};
662
+ }
663
+ Parser.prototype = parser;parser.Parser = Parser;
664
+ return new Parser;
665
+ })();
666
+
667
+
668
+ if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
669
+ exports.parser = _importParser;
670
+ exports.Parser = _importParser.Parser;
671
+ exports.parse = function () { return _importParser.parse.apply(_importParser, arguments); };
672
+ exports.main = function commonjsMain (args) {
673
+ if (!args[1]) {
674
+ console.log('Usage: '+args[0]+' FILE');
675
+ process.exit(1);
676
+ }
677
+ var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
678
+ return exports.parser.parse(source);
679
+ };
680
+ if (typeof module !== 'undefined' && require.main === module) {
681
+ exports.main(process.argv.slice(1));
682
+ }
683
+ }