chrome-devtools-frontend 1.0.944903 → 1.0.945884
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/gni/devtools_grd_files.gni +1 -0
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/circled_exclamation_icon.svg +3 -0
- package/front_end/core/host/InspectorFrontendHostAPI.ts +5 -5
- package/front_end/core/host/UserMetrics.ts +3 -1
- package/front_end/core/i18n/i18nImpl.ts +7 -4
- package/front_end/core/i18n/locales/en-US.json +9 -45
- package/front_end/core/i18n/locales/en-XL.json +9 -45
- package/front_end/core/sdk/CSSMetadata.ts +0 -1
- package/front_end/core/sdk/sdk-meta.ts +20 -8
- package/front_end/entrypoints/main/MainImpl.ts +6 -0
- package/front_end/generated/protocol.d.ts +0 -4
- package/front_end/models/emulation/EmulatedDevices.ts +2 -4
- package/front_end/models/persistence/IsolatedFileSystemManager.ts +6 -10
- package/front_end/models/timeline_model/TimelineJSProfile.ts +16 -3
- package/front_end/models/timeline_model/TimelineModel.ts +1 -0
- package/front_end/models/workspace_diff/WorkspaceDiff.ts +20 -6
- package/front_end/panels/animation/AnimationTimeline.ts +1 -1
- package/front_end/panels/application/BackForwardCacheStrings.ts +15 -75
- package/front_end/panels/application/BackForwardCacheView.ts +8 -1
- package/front_end/panels/changes/ChangesView.ts +8 -7
- package/front_end/panels/elements/StyleEditorWidget.ts +7 -7
- package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -15
- package/front_end/panels/elements/StylesSidebarPane.ts +35 -9
- package/front_end/panels/emulation/DeviceModeView.ts +3 -0
- package/front_end/panels/help/ReleaseNoteText.ts +3 -1
- package/front_end/panels/network/NetworkItemView.ts +7 -1
- package/front_end/panels/profiler/heapProfiler.css +2 -5
- package/front_end/panels/timeline/TimelineController.ts +3 -0
- package/front_end/panels/webauthn/WebauthnPane.ts +31 -32
- package/front_end/third_party/acorn/README.chromium +2 -2
- package/front_end/third_party/acorn/acorn.ts +1 -1
- package/front_end/third_party/acorn/package/CHANGELOG.md +31 -1
- package/front_end/third_party/acorn/package/README.md +1 -1
- package/front_end/third_party/acorn/package/dist/acorn.d.ts +3 -0
- package/front_end/third_party/acorn/package/dist/acorn.js +772 -708
- package/front_end/third_party/acorn/package/dist/acorn.mjs +767 -703
- package/front_end/third_party/acorn/package/dist/bin.js +47 -21
- package/front_end/third_party/acorn/package/package.json +1 -1
- package/front_end/third_party/acorn-loose/README.chromium +2 -2
- package/front_end/third_party/acorn-loose/package/CHANGELOG.md +12 -0
- package/front_end/third_party/acorn-loose/package/dist/acorn-loose.js +27 -7
- package/front_end/third_party/acorn-loose/package/dist/acorn-loose.mjs +28 -8
- package/front_end/third_party/acorn-loose/package/package.json +2 -2
- package/front_end/third_party/i18n/i18n-impl.ts +1 -1
- package/front_end/ui/components/adorners/Adorner.ts +14 -14
- package/front_end/ui/components/buttons/Button.ts +133 -42
- package/front_end/ui/components/buttons/button.css +31 -0
- package/front_end/ui/components/data_grid/DataGrid.ts +131 -122
- package/front_end/ui/components/data_grid/DataGridController.ts +42 -42
- package/front_end/ui/components/diff_view/DiffView.ts +4 -4
- package/front_end/ui/components/docs/button/basic.html +3 -0
- package/front_end/ui/components/docs/button/basic.ts +58 -0
- package/front_end/ui/components/expandable_list/ExpandableList.ts +11 -11
- package/front_end/ui/components/icon_button/Icon.ts +24 -21
- package/front_end/ui/components/icon_button/IconButton.ts +31 -31
- package/front_end/ui/components/issue_counter/IssueCounter.ts +52 -52
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +42 -42
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspector.ts +67 -67
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +22 -22
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +36 -36
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryNavigator.ts +19 -19
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +24 -32
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +52 -52
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterDisplay.ts +21 -21
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterSettings.ts +6 -6
- package/front_end/ui/components/markdown_view/MarkdownImage.ts +14 -14
- package/front_end/ui/components/markdown_view/MarkdownLink.ts +8 -8
- package/front_end/ui/components/markdown_view/MarkdownView.ts +6 -6
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +33 -33
- package/front_end/ui/components/report_view/ReportView.ts +18 -18
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +53 -53
- package/front_end/ui/components/settings/SettingCheckbox.ts +15 -15
- package/front_end/ui/components/survey_link/SurveyLink.ts +28 -28
- package/front_end/ui/components/text_editor/TextEditor.ts +55 -52
- package/front_end/ui/components/text_editor/javascript.ts +6 -6
- package/front_end/ui/components/text_prompt/TextPrompt.ts +19 -19
- package/front_end/ui/components/tree_outline/TreeOutline.ts +56 -56
- package/front_end/ui/legacy/Infobar.ts +9 -0
- package/front_end/ui/legacy/InspectorView.ts +1 -1
- package/front_end/ui/legacy/ListWidget.ts +2 -2
- package/front_end/ui/legacy/tabbedPane.css +1 -1
- package/inspector_overlay/main.ts +3 -0
- package/package.json +1 -1
- package/scripts/eslint_rules/lib/l10n_filename_matches.js +17 -4
- package/scripts/eslint_rules/tests/l10n_filename_matches_test.js +21 -0
|
@@ -12,7 +12,7 @@ var reservedWords = {
|
|
|
12
12
|
|
|
13
13
|
var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
|
|
14
14
|
|
|
15
|
-
var keywords = {
|
|
15
|
+
var keywords$1 = {
|
|
16
16
|
5: ecma5AndLessKeywords,
|
|
17
17
|
"5module": ecma5AndLessKeywords + " export import",
|
|
18
18
|
6: ecma5AndLessKeywords + " const class extends export import super"
|
|
@@ -131,17 +131,17 @@ var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
|
|
|
131
131
|
|
|
132
132
|
// Map keyword names to token types.
|
|
133
133
|
|
|
134
|
-
var keywords
|
|
134
|
+
var keywords = {};
|
|
135
135
|
|
|
136
136
|
// Succinct definitions of keyword token types
|
|
137
137
|
function kw(name, options) {
|
|
138
138
|
if ( options === void 0 ) options = {};
|
|
139
139
|
|
|
140
140
|
options.keyword = name;
|
|
141
|
-
return keywords
|
|
141
|
+
return keywords[name] = new TokenType(name, options)
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
var types = {
|
|
144
|
+
var types$1 = {
|
|
145
145
|
num: new TokenType("num", startsExpr),
|
|
146
146
|
regexp: new TokenType("regexp", startsExpr),
|
|
147
147
|
string: new TokenType("string", startsExpr),
|
|
@@ -246,8 +246,8 @@ var types = {
|
|
|
246
246
|
var lineBreak = /\r\n?|\n|\u2028|\u2029/;
|
|
247
247
|
var lineBreakG = new RegExp(lineBreak.source, "g");
|
|
248
248
|
|
|
249
|
-
function isNewLine(code
|
|
250
|
-
return code === 10 || code === 13 ||
|
|
249
|
+
function isNewLine(code) {
|
|
250
|
+
return code === 10 || code === 13 || code === 0x2028 || code === 0x2029
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
|
|
@@ -458,13 +458,14 @@ function pushComment(options, array) {
|
|
|
458
458
|
var
|
|
459
459
|
SCOPE_TOP = 1,
|
|
460
460
|
SCOPE_FUNCTION = 2,
|
|
461
|
-
SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,
|
|
462
461
|
SCOPE_ASYNC = 4,
|
|
463
462
|
SCOPE_GENERATOR = 8,
|
|
464
463
|
SCOPE_ARROW = 16,
|
|
465
464
|
SCOPE_SIMPLE_CATCH = 32,
|
|
466
465
|
SCOPE_SUPER = 64,
|
|
467
|
-
SCOPE_DIRECT_SUPER = 128
|
|
466
|
+
SCOPE_DIRECT_SUPER = 128,
|
|
467
|
+
SCOPE_CLASS_STATIC_BLOCK = 256,
|
|
468
|
+
SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
|
|
468
469
|
|
|
469
470
|
function functionFlags(async, generator) {
|
|
470
471
|
return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
|
|
@@ -482,7 +483,7 @@ var
|
|
|
482
483
|
var Parser = function Parser(options, input, startPos) {
|
|
483
484
|
this.options = options = getOptions(options);
|
|
484
485
|
this.sourceFile = options.sourceFile;
|
|
485
|
-
this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
|
|
486
|
+
this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
|
|
486
487
|
var reserved = "";
|
|
487
488
|
if (options.allowReserved !== true) {
|
|
488
489
|
reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
|
|
@@ -513,7 +514,7 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
513
514
|
|
|
514
515
|
// Properties of the current token:
|
|
515
516
|
// Its type
|
|
516
|
-
this.type = types.eof;
|
|
517
|
+
this.type = types$1.eof;
|
|
517
518
|
// For tokens that include more information than their type, the value
|
|
518
519
|
this.value = null;
|
|
519
520
|
// Its start and end offset
|
|
@@ -564,7 +565,7 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
564
565
|
this.privateNameStack = [];
|
|
565
566
|
};
|
|
566
567
|
|
|
567
|
-
var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },
|
|
568
|
+
var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } };
|
|
568
569
|
|
|
569
570
|
Parser.prototype.parse = function parse () {
|
|
570
571
|
var node = this.options.program || this.startNode();
|
|
@@ -573,29 +574,40 @@ Parser.prototype.parse = function parse () {
|
|
|
573
574
|
};
|
|
574
575
|
|
|
575
576
|
prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
|
|
577
|
+
|
|
576
578
|
prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };
|
|
579
|
+
|
|
577
580
|
prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };
|
|
581
|
+
|
|
578
582
|
prototypeAccessors.canAwait.get = function () {
|
|
579
583
|
for (var i = this.scopeStack.length - 1; i >= 0; i--) {
|
|
580
584
|
var scope = this.scopeStack[i];
|
|
581
|
-
if (scope.inClassFieldInit) { return false }
|
|
585
|
+
if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }
|
|
582
586
|
if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }
|
|
583
587
|
}
|
|
584
588
|
return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
|
|
585
589
|
};
|
|
590
|
+
|
|
586
591
|
prototypeAccessors.allowSuper.get = function () {
|
|
587
592
|
var ref = this.currentThisScope();
|
|
588
593
|
var flags = ref.flags;
|
|
589
594
|
var inClassFieldInit = ref.inClassFieldInit;
|
|
590
595
|
return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod
|
|
591
596
|
};
|
|
597
|
+
|
|
592
598
|
prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
|
|
599
|
+
|
|
593
600
|
prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
|
|
594
|
-
|
|
601
|
+
|
|
602
|
+
prototypeAccessors.allowNewDotTarget.get = function () {
|
|
595
603
|
var ref = this.currentThisScope();
|
|
596
604
|
var flags = ref.flags;
|
|
597
605
|
var inClassFieldInit = ref.inClassFieldInit;
|
|
598
|
-
return (flags & SCOPE_FUNCTION) > 0 || inClassFieldInit
|
|
606
|
+
return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
prototypeAccessors.inClassStaticBlock.get = function () {
|
|
610
|
+
return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
|
|
599
611
|
};
|
|
600
612
|
|
|
601
613
|
Parser.extend = function extend () {
|
|
@@ -623,12 +635,12 @@ Parser.tokenizer = function tokenizer (input, options) {
|
|
|
623
635
|
|
|
624
636
|
Object.defineProperties( Parser.prototype, prototypeAccessors );
|
|
625
637
|
|
|
626
|
-
var pp = Parser.prototype;
|
|
638
|
+
var pp$9 = Parser.prototype;
|
|
627
639
|
|
|
628
640
|
// ## Parser utilities
|
|
629
641
|
|
|
630
642
|
var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
|
|
631
|
-
pp.strictDirective = function(start) {
|
|
643
|
+
pp$9.strictDirective = function(start) {
|
|
632
644
|
for (;;) {
|
|
633
645
|
// Try to find string literal.
|
|
634
646
|
skipWhiteSpace.lastIndex = start;
|
|
@@ -656,7 +668,7 @@ pp.strictDirective = function(start) {
|
|
|
656
668
|
// Predicate that tests whether the next token is of the given
|
|
657
669
|
// type, and if yes, consumes it as a side effect.
|
|
658
670
|
|
|
659
|
-
pp.eat = function(type) {
|
|
671
|
+
pp$9.eat = function(type) {
|
|
660
672
|
if (this.type === type) {
|
|
661
673
|
this.next();
|
|
662
674
|
return true
|
|
@@ -667,13 +679,13 @@ pp.eat = function(type) {
|
|
|
667
679
|
|
|
668
680
|
// Tests whether parsed token is a contextual keyword.
|
|
669
681
|
|
|
670
|
-
pp.isContextual = function(name) {
|
|
671
|
-
return this.type === types.name && this.value === name && !this.containsEsc
|
|
682
|
+
pp$9.isContextual = function(name) {
|
|
683
|
+
return this.type === types$1.name && this.value === name && !this.containsEsc
|
|
672
684
|
};
|
|
673
685
|
|
|
674
686
|
// Consumes contextual keyword if possible.
|
|
675
687
|
|
|
676
|
-
pp.eatContextual = function(name) {
|
|
688
|
+
pp$9.eatContextual = function(name) {
|
|
677
689
|
if (!this.isContextual(name)) { return false }
|
|
678
690
|
this.next();
|
|
679
691
|
return true
|
|
@@ -681,19 +693,19 @@ pp.eatContextual = function(name) {
|
|
|
681
693
|
|
|
682
694
|
// Asserts that following token is given contextual keyword.
|
|
683
695
|
|
|
684
|
-
pp.expectContextual = function(name) {
|
|
696
|
+
pp$9.expectContextual = function(name) {
|
|
685
697
|
if (!this.eatContextual(name)) { this.unexpected(); }
|
|
686
698
|
};
|
|
687
699
|
|
|
688
700
|
// Test whether a semicolon can be inserted at the current position.
|
|
689
701
|
|
|
690
|
-
pp.canInsertSemicolon = function() {
|
|
691
|
-
return this.type === types.eof ||
|
|
692
|
-
this.type === types.braceR ||
|
|
702
|
+
pp$9.canInsertSemicolon = function() {
|
|
703
|
+
return this.type === types$1.eof ||
|
|
704
|
+
this.type === types$1.braceR ||
|
|
693
705
|
lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
|
|
694
706
|
};
|
|
695
707
|
|
|
696
|
-
pp.insertSemicolon = function() {
|
|
708
|
+
pp$9.insertSemicolon = function() {
|
|
697
709
|
if (this.canInsertSemicolon()) {
|
|
698
710
|
if (this.options.onInsertedSemicolon)
|
|
699
711
|
{ this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
|
|
@@ -704,11 +716,11 @@ pp.insertSemicolon = function() {
|
|
|
704
716
|
// Consume a semicolon, or, failing that, see if we are allowed to
|
|
705
717
|
// pretend that there is a semicolon at this position.
|
|
706
718
|
|
|
707
|
-
pp.semicolon = function() {
|
|
708
|
-
if (!this.eat(types.semi) && !this.insertSemicolon()) { this.unexpected(); }
|
|
719
|
+
pp$9.semicolon = function() {
|
|
720
|
+
if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); }
|
|
709
721
|
};
|
|
710
722
|
|
|
711
|
-
pp.afterTrailingComma = function(tokType, notNext) {
|
|
723
|
+
pp$9.afterTrailingComma = function(tokType, notNext) {
|
|
712
724
|
if (this.type === tokType) {
|
|
713
725
|
if (this.options.onTrailingComma)
|
|
714
726
|
{ this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
|
|
@@ -721,13 +733,13 @@ pp.afterTrailingComma = function(tokType, notNext) {
|
|
|
721
733
|
// Expect a token of a given type. If found, consume it, otherwise,
|
|
722
734
|
// raise an unexpected token error.
|
|
723
735
|
|
|
724
|
-
pp.expect = function(type) {
|
|
736
|
+
pp$9.expect = function(type) {
|
|
725
737
|
this.eat(type) || this.unexpected();
|
|
726
738
|
};
|
|
727
739
|
|
|
728
740
|
// Raise an unexpected token error.
|
|
729
741
|
|
|
730
|
-
pp.unexpected = function(pos) {
|
|
742
|
+
pp$9.unexpected = function(pos) {
|
|
731
743
|
this.raise(pos != null ? pos : this.start, "Unexpected token");
|
|
732
744
|
};
|
|
733
745
|
|
|
@@ -740,7 +752,7 @@ function DestructuringErrors() {
|
|
|
740
752
|
-1;
|
|
741
753
|
}
|
|
742
754
|
|
|
743
|
-
pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
755
|
+
pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
744
756
|
if (!refDestructuringErrors) { return }
|
|
745
757
|
if (refDestructuringErrors.trailingComma > -1)
|
|
746
758
|
{ this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
|
|
@@ -748,7 +760,7 @@ pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
|
|
|
748
760
|
if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
|
|
749
761
|
};
|
|
750
762
|
|
|
751
|
-
pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
|
763
|
+
pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
|
752
764
|
if (!refDestructuringErrors) { return false }
|
|
753
765
|
var shorthandAssign = refDestructuringErrors.shorthandAssign;
|
|
754
766
|
var doubleProto = refDestructuringErrors.doubleProto;
|
|
@@ -759,20 +771,20 @@ pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
|
|
759
771
|
{ this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
|
|
760
772
|
};
|
|
761
773
|
|
|
762
|
-
pp.checkYieldAwaitInDefaultParams = function() {
|
|
774
|
+
pp$9.checkYieldAwaitInDefaultParams = function() {
|
|
763
775
|
if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
|
|
764
776
|
{ this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
|
|
765
777
|
if (this.awaitPos)
|
|
766
778
|
{ this.raise(this.awaitPos, "Await expression cannot be a default value"); }
|
|
767
779
|
};
|
|
768
780
|
|
|
769
|
-
pp.isSimpleAssignTarget = function(expr) {
|
|
781
|
+
pp$9.isSimpleAssignTarget = function(expr) {
|
|
770
782
|
if (expr.type === "ParenthesizedExpression")
|
|
771
783
|
{ return this.isSimpleAssignTarget(expr.expression) }
|
|
772
784
|
return expr.type === "Identifier" || expr.type === "MemberExpression"
|
|
773
785
|
};
|
|
774
786
|
|
|
775
|
-
var pp$
|
|
787
|
+
var pp$8 = Parser.prototype;
|
|
776
788
|
|
|
777
789
|
// ### Statement parsing
|
|
778
790
|
|
|
@@ -781,10 +793,10 @@ var pp$1 = Parser.prototype;
|
|
|
781
793
|
// `program` argument. If present, the statements will be appended
|
|
782
794
|
// to its body instead of creating a new node.
|
|
783
795
|
|
|
784
|
-
pp$
|
|
796
|
+
pp$8.parseTopLevel = function(node) {
|
|
785
797
|
var exports = Object.create(null);
|
|
786
798
|
if (!node.body) { node.body = []; }
|
|
787
|
-
while (this.type !== types.eof) {
|
|
799
|
+
while (this.type !== types$1.eof) {
|
|
788
800
|
var stmt = this.parseStatement(null, true, exports);
|
|
789
801
|
node.body.push(stmt);
|
|
790
802
|
}
|
|
@@ -803,7 +815,7 @@ pp$1.parseTopLevel = function(node) {
|
|
|
803
815
|
|
|
804
816
|
var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
|
|
805
817
|
|
|
806
|
-
pp$
|
|
818
|
+
pp$8.isLet = function(context) {
|
|
807
819
|
if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
|
|
808
820
|
skipWhiteSpace.lastIndex = this.pos;
|
|
809
821
|
var skip = skipWhiteSpace.exec(this.input);
|
|
@@ -829,7 +841,7 @@ pp$1.isLet = function(context) {
|
|
|
829
841
|
// check 'async [no LineTerminator here] function'
|
|
830
842
|
// - 'async /*foo*/ function' is OK.
|
|
831
843
|
// - 'async /*\n*/ function' is invalid.
|
|
832
|
-
pp$
|
|
844
|
+
pp$8.isAsyncFunction = function() {
|
|
833
845
|
if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
|
|
834
846
|
{ return false }
|
|
835
847
|
|
|
@@ -849,11 +861,11 @@ pp$1.isAsyncFunction = function() {
|
|
|
849
861
|
// `if (foo) /blah/.exec(foo)`, where looking at the previous token
|
|
850
862
|
// does not help.
|
|
851
863
|
|
|
852
|
-
pp$
|
|
864
|
+
pp$8.parseStatement = function(context, topLevel, exports) {
|
|
853
865
|
var starttype = this.type, node = this.startNode(), kind;
|
|
854
866
|
|
|
855
867
|
if (this.isLet(context)) {
|
|
856
|
-
starttype = types._var;
|
|
868
|
+
starttype = types$1._var;
|
|
857
869
|
kind = "let";
|
|
858
870
|
}
|
|
859
871
|
|
|
@@ -862,35 +874,35 @@ pp$1.parseStatement = function(context, topLevel, exports) {
|
|
|
862
874
|
// complexity.
|
|
863
875
|
|
|
864
876
|
switch (starttype) {
|
|
865
|
-
case types._break: case types._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
|
|
866
|
-
case types._debugger: return this.parseDebuggerStatement(node)
|
|
867
|
-
case types._do: return this.parseDoStatement(node)
|
|
868
|
-
case types._for: return this.parseForStatement(node)
|
|
869
|
-
case types._function:
|
|
877
|
+
case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
|
|
878
|
+
case types$1._debugger: return this.parseDebuggerStatement(node)
|
|
879
|
+
case types$1._do: return this.parseDoStatement(node)
|
|
880
|
+
case types$1._for: return this.parseForStatement(node)
|
|
881
|
+
case types$1._function:
|
|
870
882
|
// Function as sole body of either an if statement or a labeled statement
|
|
871
883
|
// works, but not when it is part of a labeled statement that is the sole
|
|
872
884
|
// body of an if statement.
|
|
873
885
|
if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
|
|
874
886
|
return this.parseFunctionStatement(node, false, !context)
|
|
875
|
-
case types._class:
|
|
887
|
+
case types$1._class:
|
|
876
888
|
if (context) { this.unexpected(); }
|
|
877
889
|
return this.parseClass(node, true)
|
|
878
|
-
case types._if: return this.parseIfStatement(node)
|
|
879
|
-
case types._return: return this.parseReturnStatement(node)
|
|
880
|
-
case types._switch: return this.parseSwitchStatement(node)
|
|
881
|
-
case types._throw: return this.parseThrowStatement(node)
|
|
882
|
-
case types._try: return this.parseTryStatement(node)
|
|
883
|
-
case types._const: case types._var:
|
|
890
|
+
case types$1._if: return this.parseIfStatement(node)
|
|
891
|
+
case types$1._return: return this.parseReturnStatement(node)
|
|
892
|
+
case types$1._switch: return this.parseSwitchStatement(node)
|
|
893
|
+
case types$1._throw: return this.parseThrowStatement(node)
|
|
894
|
+
case types$1._try: return this.parseTryStatement(node)
|
|
895
|
+
case types$1._const: case types$1._var:
|
|
884
896
|
kind = kind || this.value;
|
|
885
897
|
if (context && kind !== "var") { this.unexpected(); }
|
|
886
898
|
return this.parseVarStatement(node, kind)
|
|
887
|
-
case types._while: return this.parseWhileStatement(node)
|
|
888
|
-
case types._with: return this.parseWithStatement(node)
|
|
889
|
-
case types.braceL: return this.parseBlock(true, node)
|
|
890
|
-
case types.semi: return this.parseEmptyStatement(node)
|
|
891
|
-
case types._export:
|
|
892
|
-
case types._import:
|
|
893
|
-
if (this.options.ecmaVersion > 10 && starttype === types._import) {
|
|
899
|
+
case types$1._while: return this.parseWhileStatement(node)
|
|
900
|
+
case types$1._with: return this.parseWithStatement(node)
|
|
901
|
+
case types$1.braceL: return this.parseBlock(true, node)
|
|
902
|
+
case types$1.semi: return this.parseEmptyStatement(node)
|
|
903
|
+
case types$1._export:
|
|
904
|
+
case types$1._import:
|
|
905
|
+
if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
|
|
894
906
|
skipWhiteSpace.lastIndex = this.pos;
|
|
895
907
|
var skip = skipWhiteSpace.exec(this.input);
|
|
896
908
|
var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
|
|
@@ -904,7 +916,7 @@ pp$1.parseStatement = function(context, topLevel, exports) {
|
|
|
904
916
|
if (!this.inModule)
|
|
905
917
|
{ this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
|
|
906
918
|
}
|
|
907
|
-
return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports)
|
|
919
|
+
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
|
|
908
920
|
|
|
909
921
|
// If the statement does not start with a statement keyword or a
|
|
910
922
|
// brace, it's an ExpressionStatement or LabeledStatement. We
|
|
@@ -919,17 +931,17 @@ pp$1.parseStatement = function(context, topLevel, exports) {
|
|
|
919
931
|
}
|
|
920
932
|
|
|
921
933
|
var maybeName = this.value, expr = this.parseExpression();
|
|
922
|
-
if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon))
|
|
934
|
+
if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
|
|
923
935
|
{ return this.parseLabeledStatement(node, maybeName, expr, context) }
|
|
924
936
|
else { return this.parseExpressionStatement(node, expr) }
|
|
925
937
|
}
|
|
926
938
|
};
|
|
927
939
|
|
|
928
|
-
pp$
|
|
940
|
+
pp$8.parseBreakContinueStatement = function(node, keyword) {
|
|
929
941
|
var isBreak = keyword === "break";
|
|
930
942
|
this.next();
|
|
931
|
-
if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; }
|
|
932
|
-
else if (this.type !== types.name) { this.unexpected(); }
|
|
943
|
+
if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; }
|
|
944
|
+
else if (this.type !== types$1.name) { this.unexpected(); }
|
|
933
945
|
else {
|
|
934
946
|
node.label = this.parseIdent();
|
|
935
947
|
this.semicolon();
|
|
@@ -949,21 +961,21 @@ pp$1.parseBreakContinueStatement = function(node, keyword) {
|
|
|
949
961
|
return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
|
|
950
962
|
};
|
|
951
963
|
|
|
952
|
-
pp$
|
|
964
|
+
pp$8.parseDebuggerStatement = function(node) {
|
|
953
965
|
this.next();
|
|
954
966
|
this.semicolon();
|
|
955
967
|
return this.finishNode(node, "DebuggerStatement")
|
|
956
968
|
};
|
|
957
969
|
|
|
958
|
-
pp$
|
|
970
|
+
pp$8.parseDoStatement = function(node) {
|
|
959
971
|
this.next();
|
|
960
972
|
this.labels.push(loopLabel);
|
|
961
973
|
node.body = this.parseStatement("do");
|
|
962
974
|
this.labels.pop();
|
|
963
|
-
this.expect(types._while);
|
|
975
|
+
this.expect(types$1._while);
|
|
964
976
|
node.test = this.parseParenExpression();
|
|
965
977
|
if (this.options.ecmaVersion >= 6)
|
|
966
|
-
{ this.eat(types.semi); }
|
|
978
|
+
{ this.eat(types$1.semi); }
|
|
967
979
|
else
|
|
968
980
|
{ this.semicolon(); }
|
|
969
981
|
return this.finishNode(node, "DoWhileStatement")
|
|
@@ -977,25 +989,25 @@ pp$1.parseDoStatement = function(node) {
|
|
|
977
989
|
// part (semicolon immediately after the opening parenthesis), it
|
|
978
990
|
// is a regular `for` loop.
|
|
979
991
|
|
|
980
|
-
pp$
|
|
992
|
+
pp$8.parseForStatement = function(node) {
|
|
981
993
|
this.next();
|
|
982
994
|
var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1;
|
|
983
995
|
this.labels.push(loopLabel);
|
|
984
996
|
this.enterScope(0);
|
|
985
|
-
this.expect(types.parenL);
|
|
986
|
-
if (this.type === types.semi) {
|
|
997
|
+
this.expect(types$1.parenL);
|
|
998
|
+
if (this.type === types$1.semi) {
|
|
987
999
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
988
1000
|
return this.parseFor(node, null)
|
|
989
1001
|
}
|
|
990
1002
|
var isLet = this.isLet();
|
|
991
|
-
if (this.type === types._var || this.type === types._const || isLet) {
|
|
1003
|
+
if (this.type === types$1._var || this.type === types$1._const || isLet) {
|
|
992
1004
|
var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
|
|
993
1005
|
this.next();
|
|
994
1006
|
this.parseVar(init$1, true, kind);
|
|
995
1007
|
this.finishNode(init$1, "VariableDeclaration");
|
|
996
|
-
if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
|
|
1008
|
+
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
|
|
997
1009
|
if (this.options.ecmaVersion >= 9) {
|
|
998
|
-
if (this.type === types._in) {
|
|
1010
|
+
if (this.type === types$1._in) {
|
|
999
1011
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
1000
1012
|
} else { node.await = awaitAt > -1; }
|
|
1001
1013
|
}
|
|
@@ -1004,14 +1016,16 @@ pp$1.parseForStatement = function(node) {
|
|
|
1004
1016
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
1005
1017
|
return this.parseFor(node, init$1)
|
|
1006
1018
|
}
|
|
1019
|
+
var startsWithLet = this.isContextual("let"), isForOf = false;
|
|
1007
1020
|
var refDestructuringErrors = new DestructuringErrors;
|
|
1008
1021
|
var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
|
|
1009
|
-
if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
|
|
1022
|
+
if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
|
|
1010
1023
|
if (this.options.ecmaVersion >= 9) {
|
|
1011
|
-
if (this.type === types._in) {
|
|
1024
|
+
if (this.type === types$1._in) {
|
|
1012
1025
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
1013
1026
|
} else { node.await = awaitAt > -1; }
|
|
1014
1027
|
}
|
|
1028
|
+
if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
|
|
1015
1029
|
this.toAssignable(init, false, refDestructuringErrors);
|
|
1016
1030
|
this.checkLValPattern(init);
|
|
1017
1031
|
return this.parseForIn(node, init)
|
|
@@ -1022,21 +1036,21 @@ pp$1.parseForStatement = function(node) {
|
|
|
1022
1036
|
return this.parseFor(node, init)
|
|
1023
1037
|
};
|
|
1024
1038
|
|
|
1025
|
-
pp$
|
|
1039
|
+
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
1026
1040
|
this.next();
|
|
1027
1041
|
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
1028
1042
|
};
|
|
1029
1043
|
|
|
1030
|
-
pp$
|
|
1044
|
+
pp$8.parseIfStatement = function(node) {
|
|
1031
1045
|
this.next();
|
|
1032
1046
|
node.test = this.parseParenExpression();
|
|
1033
1047
|
// allow function declarations in branches, but only in non-strict mode
|
|
1034
1048
|
node.consequent = this.parseStatement("if");
|
|
1035
|
-
node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
|
|
1049
|
+
node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
|
|
1036
1050
|
return this.finishNode(node, "IfStatement")
|
|
1037
1051
|
};
|
|
1038
1052
|
|
|
1039
|
-
pp$
|
|
1053
|
+
pp$8.parseReturnStatement = function(node) {
|
|
1040
1054
|
if (!this.inFunction && !this.options.allowReturnOutsideFunction)
|
|
1041
1055
|
{ this.raise(this.start, "'return' outside of function"); }
|
|
1042
1056
|
this.next();
|
|
@@ -1045,16 +1059,16 @@ pp$1.parseReturnStatement = function(node) {
|
|
|
1045
1059
|
// optional arguments, we eagerly look for a semicolon or the
|
|
1046
1060
|
// possibility to insert one.
|
|
1047
1061
|
|
|
1048
|
-
if (this.eat(types.semi) || this.insertSemicolon()) { node.argument = null; }
|
|
1062
|
+
if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; }
|
|
1049
1063
|
else { node.argument = this.parseExpression(); this.semicolon(); }
|
|
1050
1064
|
return this.finishNode(node, "ReturnStatement")
|
|
1051
1065
|
};
|
|
1052
1066
|
|
|
1053
|
-
pp$
|
|
1067
|
+
pp$8.parseSwitchStatement = function(node) {
|
|
1054
1068
|
this.next();
|
|
1055
1069
|
node.discriminant = this.parseParenExpression();
|
|
1056
1070
|
node.cases = [];
|
|
1057
|
-
this.expect(types.braceL);
|
|
1071
|
+
this.expect(types$1.braceL);
|
|
1058
1072
|
this.labels.push(switchLabel);
|
|
1059
1073
|
this.enterScope(0);
|
|
1060
1074
|
|
|
@@ -1063,9 +1077,9 @@ pp$1.parseSwitchStatement = function(node) {
|
|
|
1063
1077
|
// adding statements to.
|
|
1064
1078
|
|
|
1065
1079
|
var cur;
|
|
1066
|
-
for (var sawDefault = false; this.type !== types.braceR;) {
|
|
1067
|
-
if (this.type === types._case || this.type === types._default) {
|
|
1068
|
-
var isCase = this.type === types._case;
|
|
1080
|
+
for (var sawDefault = false; this.type !== types$1.braceR;) {
|
|
1081
|
+
if (this.type === types$1._case || this.type === types$1._default) {
|
|
1082
|
+
var isCase = this.type === types$1._case;
|
|
1069
1083
|
if (cur) { this.finishNode(cur, "SwitchCase"); }
|
|
1070
1084
|
node.cases.push(cur = this.startNode());
|
|
1071
1085
|
cur.consequent = [];
|
|
@@ -1077,7 +1091,7 @@ pp$1.parseSwitchStatement = function(node) {
|
|
|
1077
1091
|
sawDefault = true;
|
|
1078
1092
|
cur.test = null;
|
|
1079
1093
|
}
|
|
1080
|
-
this.expect(types.colon);
|
|
1094
|
+
this.expect(types$1.colon);
|
|
1081
1095
|
} else {
|
|
1082
1096
|
if (!cur) { this.unexpected(); }
|
|
1083
1097
|
cur.consequent.push(this.parseStatement(null));
|
|
@@ -1090,7 +1104,7 @@ pp$1.parseSwitchStatement = function(node) {
|
|
|
1090
1104
|
return this.finishNode(node, "SwitchStatement")
|
|
1091
1105
|
};
|
|
1092
1106
|
|
|
1093
|
-
pp$
|
|
1107
|
+
pp$8.parseThrowStatement = function(node) {
|
|
1094
1108
|
this.next();
|
|
1095
1109
|
if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
|
|
1096
1110
|
{ this.raise(this.lastTokEnd, "Illegal newline after throw"); }
|
|
@@ -1101,21 +1115,21 @@ pp$1.parseThrowStatement = function(node) {
|
|
|
1101
1115
|
|
|
1102
1116
|
// Reused empty array added for node fields that are always empty.
|
|
1103
1117
|
|
|
1104
|
-
var empty = [];
|
|
1118
|
+
var empty$1 = [];
|
|
1105
1119
|
|
|
1106
|
-
pp$
|
|
1120
|
+
pp$8.parseTryStatement = function(node) {
|
|
1107
1121
|
this.next();
|
|
1108
1122
|
node.block = this.parseBlock();
|
|
1109
1123
|
node.handler = null;
|
|
1110
|
-
if (this.type === types._catch) {
|
|
1124
|
+
if (this.type === types$1._catch) {
|
|
1111
1125
|
var clause = this.startNode();
|
|
1112
1126
|
this.next();
|
|
1113
|
-
if (this.eat(types.parenL)) {
|
|
1127
|
+
if (this.eat(types$1.parenL)) {
|
|
1114
1128
|
clause.param = this.parseBindingAtom();
|
|
1115
1129
|
var simple = clause.param.type === "Identifier";
|
|
1116
1130
|
this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
|
|
1117
1131
|
this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
|
|
1118
|
-
this.expect(types.parenR);
|
|
1132
|
+
this.expect(types$1.parenR);
|
|
1119
1133
|
} else {
|
|
1120
1134
|
if (this.options.ecmaVersion < 10) { this.unexpected(); }
|
|
1121
1135
|
clause.param = null;
|
|
@@ -1125,20 +1139,20 @@ pp$1.parseTryStatement = function(node) {
|
|
|
1125
1139
|
this.exitScope();
|
|
1126
1140
|
node.handler = this.finishNode(clause, "CatchClause");
|
|
1127
1141
|
}
|
|
1128
|
-
node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
|
|
1142
|
+
node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
|
|
1129
1143
|
if (!node.handler && !node.finalizer)
|
|
1130
1144
|
{ this.raise(node.start, "Missing catch or finally clause"); }
|
|
1131
1145
|
return this.finishNode(node, "TryStatement")
|
|
1132
1146
|
};
|
|
1133
1147
|
|
|
1134
|
-
pp$
|
|
1148
|
+
pp$8.parseVarStatement = function(node, kind) {
|
|
1135
1149
|
this.next();
|
|
1136
1150
|
this.parseVar(node, false, kind);
|
|
1137
1151
|
this.semicolon();
|
|
1138
1152
|
return this.finishNode(node, "VariableDeclaration")
|
|
1139
1153
|
};
|
|
1140
1154
|
|
|
1141
|
-
pp$
|
|
1155
|
+
pp$8.parseWhileStatement = function(node) {
|
|
1142
1156
|
this.next();
|
|
1143
1157
|
node.test = this.parseParenExpression();
|
|
1144
1158
|
this.labels.push(loopLabel);
|
|
@@ -1147,7 +1161,7 @@ pp$1.parseWhileStatement = function(node) {
|
|
|
1147
1161
|
return this.finishNode(node, "WhileStatement")
|
|
1148
1162
|
};
|
|
1149
1163
|
|
|
1150
|
-
pp$
|
|
1164
|
+
pp$8.parseWithStatement = function(node) {
|
|
1151
1165
|
if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
|
|
1152
1166
|
this.next();
|
|
1153
1167
|
node.object = this.parseParenExpression();
|
|
@@ -1155,12 +1169,12 @@ pp$1.parseWithStatement = function(node) {
|
|
|
1155
1169
|
return this.finishNode(node, "WithStatement")
|
|
1156
1170
|
};
|
|
1157
1171
|
|
|
1158
|
-
pp$
|
|
1172
|
+
pp$8.parseEmptyStatement = function(node) {
|
|
1159
1173
|
this.next();
|
|
1160
1174
|
return this.finishNode(node, "EmptyStatement")
|
|
1161
1175
|
};
|
|
1162
1176
|
|
|
1163
|
-
pp$
|
|
1177
|
+
pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
|
|
1164
1178
|
for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
|
|
1165
1179
|
{
|
|
1166
1180
|
var label = list[i$1];
|
|
@@ -1168,7 +1182,7 @@ pp$1.parseLabeledStatement = function(node, maybeName, expr, context) {
|
|
|
1168
1182
|
if (label.name === maybeName)
|
|
1169
1183
|
{ this.raise(expr.start, "Label '" + maybeName + "' is already declared");
|
|
1170
1184
|
} }
|
|
1171
|
-
var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
|
|
1185
|
+
var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
|
|
1172
1186
|
for (var i = this.labels.length - 1; i >= 0; i--) {
|
|
1173
1187
|
var label$1 = this.labels[i];
|
|
1174
1188
|
if (label$1.statementStart === node.start) {
|
|
@@ -1184,7 +1198,7 @@ pp$1.parseLabeledStatement = function(node, maybeName, expr, context) {
|
|
|
1184
1198
|
return this.finishNode(node, "LabeledStatement")
|
|
1185
1199
|
};
|
|
1186
1200
|
|
|
1187
|
-
pp$
|
|
1201
|
+
pp$8.parseExpressionStatement = function(node, expr) {
|
|
1188
1202
|
node.expression = expr;
|
|
1189
1203
|
this.semicolon();
|
|
1190
1204
|
return this.finishNode(node, "ExpressionStatement")
|
|
@@ -1194,14 +1208,14 @@ pp$1.parseExpressionStatement = function(node, expr) {
|
|
|
1194
1208
|
// strict"` declarations when `allowStrict` is true (used for
|
|
1195
1209
|
// function bodies).
|
|
1196
1210
|
|
|
1197
|
-
pp$
|
|
1211
|
+
pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
|
|
1198
1212
|
if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
|
|
1199
1213
|
if ( node === void 0 ) node = this.startNode();
|
|
1200
1214
|
|
|
1201
1215
|
node.body = [];
|
|
1202
|
-
this.expect(types.braceL);
|
|
1216
|
+
this.expect(types$1.braceL);
|
|
1203
1217
|
if (createNewLexicalScope) { this.enterScope(0); }
|
|
1204
|
-
while (this.type !== types.braceR) {
|
|
1218
|
+
while (this.type !== types$1.braceR) {
|
|
1205
1219
|
var stmt = this.parseStatement(null);
|
|
1206
1220
|
node.body.push(stmt);
|
|
1207
1221
|
}
|
|
@@ -1215,13 +1229,13 @@ pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) {
|
|
|
1215
1229
|
// `parseStatement` will already have parsed the init statement or
|
|
1216
1230
|
// expression.
|
|
1217
1231
|
|
|
1218
|
-
pp$
|
|
1232
|
+
pp$8.parseFor = function(node, init) {
|
|
1219
1233
|
node.init = init;
|
|
1220
|
-
this.expect(types.semi);
|
|
1221
|
-
node.test = this.type === types.semi ? null : this.parseExpression();
|
|
1222
|
-
this.expect(types.semi);
|
|
1223
|
-
node.update = this.type === types.parenR ? null : this.parseExpression();
|
|
1224
|
-
this.expect(types.parenR);
|
|
1234
|
+
this.expect(types$1.semi);
|
|
1235
|
+
node.test = this.type === types$1.semi ? null : this.parseExpression();
|
|
1236
|
+
this.expect(types$1.semi);
|
|
1237
|
+
node.update = this.type === types$1.parenR ? null : this.parseExpression();
|
|
1238
|
+
this.expect(types$1.parenR);
|
|
1225
1239
|
node.body = this.parseStatement("for");
|
|
1226
1240
|
this.exitScope();
|
|
1227
1241
|
this.labels.pop();
|
|
@@ -1231,8 +1245,8 @@ pp$1.parseFor = function(node, init) {
|
|
|
1231
1245
|
// Parse a `for`/`in` and `for`/`of` loop, which are almost
|
|
1232
1246
|
// same from parser's perspective.
|
|
1233
1247
|
|
|
1234
|
-
pp$
|
|
1235
|
-
var isForIn = this.type === types._in;
|
|
1248
|
+
pp$8.parseForIn = function(node, init) {
|
|
1249
|
+
var isForIn = this.type === types$1._in;
|
|
1236
1250
|
this.next();
|
|
1237
1251
|
|
|
1238
1252
|
if (
|
|
@@ -1253,7 +1267,7 @@ pp$1.parseForIn = function(node, init) {
|
|
|
1253
1267
|
}
|
|
1254
1268
|
node.left = init;
|
|
1255
1269
|
node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
|
|
1256
|
-
this.expect(types.parenR);
|
|
1270
|
+
this.expect(types$1.parenR);
|
|
1257
1271
|
node.body = this.parseStatement("for");
|
|
1258
1272
|
this.exitScope();
|
|
1259
1273
|
this.labels.pop();
|
|
@@ -1262,28 +1276,28 @@ pp$1.parseForIn = function(node, init) {
|
|
|
1262
1276
|
|
|
1263
1277
|
// Parse a list of variable declarations.
|
|
1264
1278
|
|
|
1265
|
-
pp$
|
|
1279
|
+
pp$8.parseVar = function(node, isFor, kind) {
|
|
1266
1280
|
node.declarations = [];
|
|
1267
1281
|
node.kind = kind;
|
|
1268
1282
|
for (;;) {
|
|
1269
1283
|
var decl = this.startNode();
|
|
1270
1284
|
this.parseVarId(decl, kind);
|
|
1271
|
-
if (this.eat(types.eq)) {
|
|
1285
|
+
if (this.eat(types$1.eq)) {
|
|
1272
1286
|
decl.init = this.parseMaybeAssign(isFor);
|
|
1273
|
-
} else if (kind === "const" && !(this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
|
|
1287
|
+
} else if (kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
|
|
1274
1288
|
this.unexpected();
|
|
1275
|
-
} else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types._in || this.isContextual("of")))) {
|
|
1289
|
+
} else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
|
|
1276
1290
|
this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
|
|
1277
1291
|
} else {
|
|
1278
1292
|
decl.init = null;
|
|
1279
1293
|
}
|
|
1280
1294
|
node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
|
|
1281
|
-
if (!this.eat(types.comma)) { break }
|
|
1295
|
+
if (!this.eat(types$1.comma)) { break }
|
|
1282
1296
|
}
|
|
1283
1297
|
return node
|
|
1284
1298
|
};
|
|
1285
1299
|
|
|
1286
|
-
pp$
|
|
1300
|
+
pp$8.parseVarId = function(decl, kind) {
|
|
1287
1301
|
decl.id = this.parseBindingAtom();
|
|
1288
1302
|
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
|
|
1289
1303
|
};
|
|
@@ -1294,18 +1308,18 @@ var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
|
|
|
1294
1308
|
// `statement & FUNC_STATEMENT`).
|
|
1295
1309
|
|
|
1296
1310
|
// Remove `allowExpressionBody` for 7.0.0, as it is only called with false
|
|
1297
|
-
pp$
|
|
1311
|
+
pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
|
|
1298
1312
|
this.initFunction(node);
|
|
1299
1313
|
if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
|
|
1300
|
-
if (this.type === types.star && (statement & FUNC_HANGING_STATEMENT))
|
|
1314
|
+
if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT))
|
|
1301
1315
|
{ this.unexpected(); }
|
|
1302
|
-
node.generator = this.eat(types.star);
|
|
1316
|
+
node.generator = this.eat(types$1.star);
|
|
1303
1317
|
}
|
|
1304
1318
|
if (this.options.ecmaVersion >= 8)
|
|
1305
1319
|
{ node.async = !!isAsync; }
|
|
1306
1320
|
|
|
1307
1321
|
if (statement & FUNC_STATEMENT) {
|
|
1308
|
-
node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types.name ? null : this.parseIdent();
|
|
1322
|
+
node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
|
|
1309
1323
|
if (node.id && !(statement & FUNC_HANGING_STATEMENT))
|
|
1310
1324
|
// If it is a regular function declaration in sloppy mode, then it is
|
|
1311
1325
|
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
|
@@ -1321,10 +1335,10 @@ pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) {
|
|
|
1321
1335
|
this.enterScope(functionFlags(node.async, node.generator));
|
|
1322
1336
|
|
|
1323
1337
|
if (!(statement & FUNC_STATEMENT))
|
|
1324
|
-
{ node.id = this.type === types.name ? this.parseIdent() : null; }
|
|
1338
|
+
{ node.id = this.type === types$1.name ? this.parseIdent() : null; }
|
|
1325
1339
|
|
|
1326
1340
|
this.parseFunctionParams(node);
|
|
1327
|
-
this.parseFunctionBody(node, allowExpressionBody, false);
|
|
1341
|
+
this.parseFunctionBody(node, allowExpressionBody, false, forInit);
|
|
1328
1342
|
|
|
1329
1343
|
this.yieldPos = oldYieldPos;
|
|
1330
1344
|
this.awaitPos = oldAwaitPos;
|
|
@@ -1332,16 +1346,16 @@ pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) {
|
|
|
1332
1346
|
return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
|
|
1333
1347
|
};
|
|
1334
1348
|
|
|
1335
|
-
pp$
|
|
1336
|
-
this.expect(types.parenL);
|
|
1337
|
-
node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
|
|
1349
|
+
pp$8.parseFunctionParams = function(node) {
|
|
1350
|
+
this.expect(types$1.parenL);
|
|
1351
|
+
node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
|
|
1338
1352
|
this.checkYieldAwaitInDefaultParams();
|
|
1339
1353
|
};
|
|
1340
1354
|
|
|
1341
1355
|
// Parse a class declaration or literal (depending on the
|
|
1342
1356
|
// `isStatement` parameter).
|
|
1343
1357
|
|
|
1344
|
-
pp$
|
|
1358
|
+
pp$8.parseClass = function(node, isStatement) {
|
|
1345
1359
|
this.next();
|
|
1346
1360
|
|
|
1347
1361
|
// ecma-262 14.6 Class Definitions
|
|
@@ -1355,15 +1369,15 @@ pp$1.parseClass = function(node, isStatement) {
|
|
|
1355
1369
|
var classBody = this.startNode();
|
|
1356
1370
|
var hadConstructor = false;
|
|
1357
1371
|
classBody.body = [];
|
|
1358
|
-
this.expect(types.braceL);
|
|
1359
|
-
while (this.type !== types.braceR) {
|
|
1372
|
+
this.expect(types$1.braceL);
|
|
1373
|
+
while (this.type !== types$1.braceR) {
|
|
1360
1374
|
var element = this.parseClassElement(node.superClass !== null);
|
|
1361
1375
|
if (element) {
|
|
1362
1376
|
classBody.body.push(element);
|
|
1363
1377
|
if (element.type === "MethodDefinition" && element.kind === "constructor") {
|
|
1364
1378
|
if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
|
|
1365
1379
|
hadConstructor = true;
|
|
1366
|
-
} else if (element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
|
|
1380
|
+
} else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
|
|
1367
1381
|
this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
|
|
1368
1382
|
}
|
|
1369
1383
|
}
|
|
@@ -1375,8 +1389,8 @@ pp$1.parseClass = function(node, isStatement) {
|
|
|
1375
1389
|
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
|
|
1376
1390
|
};
|
|
1377
1391
|
|
|
1378
|
-
pp$
|
|
1379
|
-
if (this.eat(types.semi)) { return null }
|
|
1392
|
+
pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
1393
|
+
if (this.eat(types$1.semi)) { return null }
|
|
1380
1394
|
|
|
1381
1395
|
var ecmaVersion = this.options.ecmaVersion;
|
|
1382
1396
|
var node = this.startNode();
|
|
@@ -1384,24 +1398,29 @@ pp$1.parseClassElement = function(constructorAllowsSuper) {
|
|
|
1384
1398
|
var isGenerator = false;
|
|
1385
1399
|
var isAsync = false;
|
|
1386
1400
|
var kind = "method";
|
|
1401
|
+
var isStatic = false;
|
|
1387
1402
|
|
|
1388
|
-
// Parse modifiers
|
|
1389
|
-
node.static = false;
|
|
1390
1403
|
if (this.eatContextual("static")) {
|
|
1391
|
-
|
|
1392
|
-
|
|
1404
|
+
// Parse static init block
|
|
1405
|
+
if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
|
|
1406
|
+
this.parseClassStaticBlock(node);
|
|
1407
|
+
return node
|
|
1408
|
+
}
|
|
1409
|
+
if (this.isClassElementNameStart() || this.type === types$1.star) {
|
|
1410
|
+
isStatic = true;
|
|
1393
1411
|
} else {
|
|
1394
1412
|
keyName = "static";
|
|
1395
1413
|
}
|
|
1396
1414
|
}
|
|
1415
|
+
node.static = isStatic;
|
|
1397
1416
|
if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
|
|
1398
|
-
if ((this.isClassElementNameStart() || this.type === types.star) && !this.canInsertSemicolon()) {
|
|
1417
|
+
if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
|
|
1399
1418
|
isAsync = true;
|
|
1400
1419
|
} else {
|
|
1401
1420
|
keyName = "async";
|
|
1402
1421
|
}
|
|
1403
1422
|
}
|
|
1404
|
-
if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types.star)) {
|
|
1423
|
+
if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
|
|
1405
1424
|
isGenerator = true;
|
|
1406
1425
|
}
|
|
1407
1426
|
if (!keyName && !isAsync && !isGenerator) {
|
|
@@ -1428,7 +1447,7 @@ pp$1.parseClassElement = function(constructorAllowsSuper) {
|
|
|
1428
1447
|
}
|
|
1429
1448
|
|
|
1430
1449
|
// Parse element value
|
|
1431
|
-
if (ecmaVersion < 13 || this.type === types.parenL || kind !== "method" || isGenerator || isAsync) {
|
|
1450
|
+
if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
|
|
1432
1451
|
var isConstructor = !node.static && checkKeyName(node, "constructor");
|
|
1433
1452
|
var allowsDirectSuper = isConstructor && constructorAllowsSuper;
|
|
1434
1453
|
// Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
|
|
@@ -1442,19 +1461,19 @@ pp$1.parseClassElement = function(constructorAllowsSuper) {
|
|
|
1442
1461
|
return node
|
|
1443
1462
|
};
|
|
1444
1463
|
|
|
1445
|
-
pp$
|
|
1464
|
+
pp$8.isClassElementNameStart = function() {
|
|
1446
1465
|
return (
|
|
1447
|
-
this.type === types.name ||
|
|
1448
|
-
this.type === types.privateId ||
|
|
1449
|
-
this.type === types.num ||
|
|
1450
|
-
this.type === types.string ||
|
|
1451
|
-
this.type === types.bracketL ||
|
|
1466
|
+
this.type === types$1.name ||
|
|
1467
|
+
this.type === types$1.privateId ||
|
|
1468
|
+
this.type === types$1.num ||
|
|
1469
|
+
this.type === types$1.string ||
|
|
1470
|
+
this.type === types$1.bracketL ||
|
|
1452
1471
|
this.type.keyword
|
|
1453
1472
|
)
|
|
1454
1473
|
};
|
|
1455
1474
|
|
|
1456
|
-
pp$
|
|
1457
|
-
if (this.type === types.privateId) {
|
|
1475
|
+
pp$8.parseClassElementName = function(element) {
|
|
1476
|
+
if (this.type === types$1.privateId) {
|
|
1458
1477
|
if (this.value === "constructor") {
|
|
1459
1478
|
this.raise(this.start, "Classes can't have an element named '#constructor'");
|
|
1460
1479
|
}
|
|
@@ -1465,7 +1484,7 @@ pp$1.parseClassElementName = function(element) {
|
|
|
1465
1484
|
}
|
|
1466
1485
|
};
|
|
1467
1486
|
|
|
1468
|
-
pp$
|
|
1487
|
+
pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
|
|
1469
1488
|
// Check key and flags
|
|
1470
1489
|
var key = method.key;
|
|
1471
1490
|
if (method.kind === "constructor") {
|
|
@@ -1489,14 +1508,14 @@ pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper
|
|
|
1489
1508
|
return this.finishNode(method, "MethodDefinition")
|
|
1490
1509
|
};
|
|
1491
1510
|
|
|
1492
|
-
pp$
|
|
1511
|
+
pp$8.parseClassField = function(field) {
|
|
1493
1512
|
if (checkKeyName(field, "constructor")) {
|
|
1494
1513
|
this.raise(field.key.start, "Classes can't have a field named 'constructor'");
|
|
1495
1514
|
} else if (field.static && checkKeyName(field, "prototype")) {
|
|
1496
1515
|
this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
|
|
1497
1516
|
}
|
|
1498
1517
|
|
|
1499
|
-
if (this.eat(types.eq)) {
|
|
1518
|
+
if (this.eat(types$1.eq)) {
|
|
1500
1519
|
// To raise SyntaxError if 'arguments' exists in the initializer.
|
|
1501
1520
|
var scope = this.currentThisScope();
|
|
1502
1521
|
var inClassFieldInit = scope.inClassFieldInit;
|
|
@@ -1511,8 +1530,25 @@ pp$1.parseClassField = function(field) {
|
|
|
1511
1530
|
return this.finishNode(field, "PropertyDefinition")
|
|
1512
1531
|
};
|
|
1513
1532
|
|
|
1514
|
-
pp$
|
|
1515
|
-
|
|
1533
|
+
pp$8.parseClassStaticBlock = function(node) {
|
|
1534
|
+
node.body = [];
|
|
1535
|
+
|
|
1536
|
+
var oldLabels = this.labels;
|
|
1537
|
+
this.labels = [];
|
|
1538
|
+
this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
|
|
1539
|
+
while (this.type !== types$1.braceR) {
|
|
1540
|
+
var stmt = this.parseStatement(null);
|
|
1541
|
+
node.body.push(stmt);
|
|
1542
|
+
}
|
|
1543
|
+
this.next();
|
|
1544
|
+
this.exitScope();
|
|
1545
|
+
this.labels = oldLabels;
|
|
1546
|
+
|
|
1547
|
+
return this.finishNode(node, "StaticBlock")
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
pp$8.parseClassId = function(node, isStatement) {
|
|
1551
|
+
if (this.type === types$1.name) {
|
|
1516
1552
|
node.id = this.parseIdent();
|
|
1517
1553
|
if (isStatement)
|
|
1518
1554
|
{ this.checkLValSimple(node.id, BIND_LEXICAL, false); }
|
|
@@ -1523,17 +1559,17 @@ pp$1.parseClassId = function(node, isStatement) {
|
|
|
1523
1559
|
}
|
|
1524
1560
|
};
|
|
1525
1561
|
|
|
1526
|
-
pp$
|
|
1527
|
-
node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
|
|
1562
|
+
pp$8.parseClassSuper = function(node) {
|
|
1563
|
+
node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(false) : null;
|
|
1528
1564
|
};
|
|
1529
1565
|
|
|
1530
|
-
pp$
|
|
1566
|
+
pp$8.enterClassBody = function() {
|
|
1531
1567
|
var element = {declared: Object.create(null), used: []};
|
|
1532
1568
|
this.privateNameStack.push(element);
|
|
1533
1569
|
return element.declared
|
|
1534
1570
|
};
|
|
1535
1571
|
|
|
1536
|
-
pp$
|
|
1572
|
+
pp$8.exitClassBody = function() {
|
|
1537
1573
|
var ref = this.privateNameStack.pop();
|
|
1538
1574
|
var declared = ref.declared;
|
|
1539
1575
|
var used = ref.used;
|
|
@@ -1588,10 +1624,10 @@ function checkKeyName(node, name) {
|
|
|
1588
1624
|
|
|
1589
1625
|
// Parses module export declaration.
|
|
1590
1626
|
|
|
1591
|
-
pp$
|
|
1627
|
+
pp$8.parseExport = function(node, exports) {
|
|
1592
1628
|
this.next();
|
|
1593
1629
|
// export * from '...'
|
|
1594
|
-
if (this.eat(types.star)) {
|
|
1630
|
+
if (this.eat(types$1.star)) {
|
|
1595
1631
|
if (this.options.ecmaVersion >= 11) {
|
|
1596
1632
|
if (this.eatContextual("as")) {
|
|
1597
1633
|
node.exported = this.parseIdent(true);
|
|
@@ -1601,20 +1637,20 @@ pp$1.parseExport = function(node, exports) {
|
|
|
1601
1637
|
}
|
|
1602
1638
|
}
|
|
1603
1639
|
this.expectContextual("from");
|
|
1604
|
-
if (this.type !== types.string) { this.unexpected(); }
|
|
1640
|
+
if (this.type !== types$1.string) { this.unexpected(); }
|
|
1605
1641
|
node.source = this.parseExprAtom();
|
|
1606
1642
|
this.semicolon();
|
|
1607
1643
|
return this.finishNode(node, "ExportAllDeclaration")
|
|
1608
1644
|
}
|
|
1609
|
-
if (this.eat(types._default)) { // export default ...
|
|
1645
|
+
if (this.eat(types$1._default)) { // export default ...
|
|
1610
1646
|
this.checkExport(exports, "default", this.lastTokStart);
|
|
1611
1647
|
var isAsync;
|
|
1612
|
-
if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
|
|
1648
|
+
if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
|
|
1613
1649
|
var fNode = this.startNode();
|
|
1614
1650
|
this.next();
|
|
1615
1651
|
if (isAsync) { this.next(); }
|
|
1616
1652
|
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
1617
|
-
} else if (this.type === types._class) {
|
|
1653
|
+
} else if (this.type === types$1._class) {
|
|
1618
1654
|
var cNode = this.startNode();
|
|
1619
1655
|
node.declaration = this.parseClass(cNode, "nullableID");
|
|
1620
1656
|
} else {
|
|
@@ -1636,7 +1672,7 @@ pp$1.parseExport = function(node, exports) {
|
|
|
1636
1672
|
node.declaration = null;
|
|
1637
1673
|
node.specifiers = this.parseExportSpecifiers(exports);
|
|
1638
1674
|
if (this.eatContextual("from")) {
|
|
1639
|
-
if (this.type !== types.string) { this.unexpected(); }
|
|
1675
|
+
if (this.type !== types$1.string) { this.unexpected(); }
|
|
1640
1676
|
node.source = this.parseExprAtom();
|
|
1641
1677
|
} else {
|
|
1642
1678
|
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
@@ -1655,14 +1691,14 @@ pp$1.parseExport = function(node, exports) {
|
|
|
1655
1691
|
return this.finishNode(node, "ExportNamedDeclaration")
|
|
1656
1692
|
};
|
|
1657
1693
|
|
|
1658
|
-
pp$
|
|
1694
|
+
pp$8.checkExport = function(exports, name, pos) {
|
|
1659
1695
|
if (!exports) { return }
|
|
1660
1696
|
if (has(exports, name))
|
|
1661
1697
|
{ this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
|
|
1662
1698
|
exports[name] = true;
|
|
1663
1699
|
};
|
|
1664
1700
|
|
|
1665
|
-
pp$
|
|
1701
|
+
pp$8.checkPatternExport = function(exports, pat) {
|
|
1666
1702
|
var type = pat.type;
|
|
1667
1703
|
if (type === "Identifier")
|
|
1668
1704
|
{ this.checkExport(exports, pat.name, pat.start); }
|
|
@@ -1689,7 +1725,7 @@ pp$1.checkPatternExport = function(exports, pat) {
|
|
|
1689
1725
|
{ this.checkPatternExport(exports, pat.expression); }
|
|
1690
1726
|
};
|
|
1691
1727
|
|
|
1692
|
-
pp$
|
|
1728
|
+
pp$8.checkVariableExport = function(exports, decls) {
|
|
1693
1729
|
if (!exports) { return }
|
|
1694
1730
|
for (var i = 0, list = decls; i < list.length; i += 1)
|
|
1695
1731
|
{
|
|
@@ -1699,7 +1735,7 @@ pp$1.checkVariableExport = function(exports, decls) {
|
|
|
1699
1735
|
}
|
|
1700
1736
|
};
|
|
1701
1737
|
|
|
1702
|
-
pp$
|
|
1738
|
+
pp$8.shouldParseExportStatement = function() {
|
|
1703
1739
|
return this.type.keyword === "var" ||
|
|
1704
1740
|
this.type.keyword === "const" ||
|
|
1705
1741
|
this.type.keyword === "class" ||
|
|
@@ -1710,14 +1746,14 @@ pp$1.shouldParseExportStatement = function() {
|
|
|
1710
1746
|
|
|
1711
1747
|
// Parses a comma-separated list of module exports.
|
|
1712
1748
|
|
|
1713
|
-
pp$
|
|
1749
|
+
pp$8.parseExportSpecifiers = function(exports) {
|
|
1714
1750
|
var nodes = [], first = true;
|
|
1715
1751
|
// export { x, y as z } [from '...']
|
|
1716
|
-
this.expect(types.braceL);
|
|
1717
|
-
while (!this.eat(types.braceR)) {
|
|
1752
|
+
this.expect(types$1.braceL);
|
|
1753
|
+
while (!this.eat(types$1.braceR)) {
|
|
1718
1754
|
if (!first) {
|
|
1719
|
-
this.expect(types.comma);
|
|
1720
|
-
if (this.afterTrailingComma(types.braceR)) { break }
|
|
1755
|
+
this.expect(types$1.comma);
|
|
1756
|
+
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
1721
1757
|
} else { first = false; }
|
|
1722
1758
|
|
|
1723
1759
|
var node = this.startNode();
|
|
@@ -1731,16 +1767,16 @@ pp$1.parseExportSpecifiers = function(exports) {
|
|
|
1731
1767
|
|
|
1732
1768
|
// Parses import declaration.
|
|
1733
1769
|
|
|
1734
|
-
pp$
|
|
1770
|
+
pp$8.parseImport = function(node) {
|
|
1735
1771
|
this.next();
|
|
1736
1772
|
// import '...'
|
|
1737
|
-
if (this.type === types.string) {
|
|
1738
|
-
node.specifiers = empty;
|
|
1773
|
+
if (this.type === types$1.string) {
|
|
1774
|
+
node.specifiers = empty$1;
|
|
1739
1775
|
node.source = this.parseExprAtom();
|
|
1740
1776
|
} else {
|
|
1741
1777
|
node.specifiers = this.parseImportSpecifiers();
|
|
1742
1778
|
this.expectContextual("from");
|
|
1743
|
-
node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
|
|
1779
|
+
node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
|
|
1744
1780
|
}
|
|
1745
1781
|
this.semicolon();
|
|
1746
1782
|
return this.finishNode(node, "ImportDeclaration")
|
|
@@ -1748,17 +1784,17 @@ pp$1.parseImport = function(node) {
|
|
|
1748
1784
|
|
|
1749
1785
|
// Parses a comma-separated list of module imports.
|
|
1750
1786
|
|
|
1751
|
-
pp$
|
|
1787
|
+
pp$8.parseImportSpecifiers = function() {
|
|
1752
1788
|
var nodes = [], first = true;
|
|
1753
|
-
if (this.type === types.name) {
|
|
1789
|
+
if (this.type === types$1.name) {
|
|
1754
1790
|
// import defaultObj, { x, y as z } from '...'
|
|
1755
1791
|
var node = this.startNode();
|
|
1756
1792
|
node.local = this.parseIdent();
|
|
1757
1793
|
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
1758
1794
|
nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
|
|
1759
|
-
if (!this.eat(types.comma)) { return nodes }
|
|
1795
|
+
if (!this.eat(types$1.comma)) { return nodes }
|
|
1760
1796
|
}
|
|
1761
|
-
if (this.type === types.star) {
|
|
1797
|
+
if (this.type === types$1.star) {
|
|
1762
1798
|
var node$1 = this.startNode();
|
|
1763
1799
|
this.next();
|
|
1764
1800
|
this.expectContextual("as");
|
|
@@ -1767,11 +1803,11 @@ pp$1.parseImportSpecifiers = function() {
|
|
|
1767
1803
|
nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
|
|
1768
1804
|
return nodes
|
|
1769
1805
|
}
|
|
1770
|
-
this.expect(types.braceL);
|
|
1771
|
-
while (!this.eat(types.braceR)) {
|
|
1806
|
+
this.expect(types$1.braceL);
|
|
1807
|
+
while (!this.eat(types$1.braceR)) {
|
|
1772
1808
|
if (!first) {
|
|
1773
|
-
this.expect(types.comma);
|
|
1774
|
-
if (this.afterTrailingComma(types.braceR)) { break }
|
|
1809
|
+
this.expect(types$1.comma);
|
|
1810
|
+
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
1775
1811
|
} else { first = false; }
|
|
1776
1812
|
|
|
1777
1813
|
var node$2 = this.startNode();
|
|
@@ -1789,12 +1825,12 @@ pp$1.parseImportSpecifiers = function() {
|
|
|
1789
1825
|
};
|
|
1790
1826
|
|
|
1791
1827
|
// Set `ExpressionStatement#directive` property for directive prologues.
|
|
1792
|
-
pp$
|
|
1828
|
+
pp$8.adaptDirectivePrologue = function(statements) {
|
|
1793
1829
|
for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
|
|
1794
1830
|
statements[i].directive = statements[i].expression.raw.slice(1, -1);
|
|
1795
1831
|
}
|
|
1796
1832
|
};
|
|
1797
|
-
pp$
|
|
1833
|
+
pp$8.isDirectiveCandidate = function(statement) {
|
|
1798
1834
|
return (
|
|
1799
1835
|
statement.type === "ExpressionStatement" &&
|
|
1800
1836
|
statement.expression.type === "Literal" &&
|
|
@@ -1804,12 +1840,12 @@ pp$1.isDirectiveCandidate = function(statement) {
|
|
|
1804
1840
|
)
|
|
1805
1841
|
};
|
|
1806
1842
|
|
|
1807
|
-
var pp$
|
|
1843
|
+
var pp$7 = Parser.prototype;
|
|
1808
1844
|
|
|
1809
1845
|
// Convert existing expression atom to assignable pattern
|
|
1810
1846
|
// if possible.
|
|
1811
1847
|
|
|
1812
|
-
pp$
|
|
1848
|
+
pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
|
|
1813
1849
|
if (this.options.ecmaVersion >= 6 && node) {
|
|
1814
1850
|
switch (node.type) {
|
|
1815
1851
|
case "Identifier":
|
|
@@ -1890,7 +1926,7 @@ pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) {
|
|
|
1890
1926
|
|
|
1891
1927
|
// Convert list of expression atoms to binding list.
|
|
1892
1928
|
|
|
1893
|
-
pp$
|
|
1929
|
+
pp$7.toAssignableList = function(exprList, isBinding) {
|
|
1894
1930
|
var end = exprList.length;
|
|
1895
1931
|
for (var i = 0; i < end; i++) {
|
|
1896
1932
|
var elt = exprList[i];
|
|
@@ -1906,19 +1942,19 @@ pp$2.toAssignableList = function(exprList, isBinding) {
|
|
|
1906
1942
|
|
|
1907
1943
|
// Parses spread element.
|
|
1908
1944
|
|
|
1909
|
-
pp$
|
|
1945
|
+
pp$7.parseSpread = function(refDestructuringErrors) {
|
|
1910
1946
|
var node = this.startNode();
|
|
1911
1947
|
this.next();
|
|
1912
1948
|
node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
|
1913
1949
|
return this.finishNode(node, "SpreadElement")
|
|
1914
1950
|
};
|
|
1915
1951
|
|
|
1916
|
-
pp$
|
|
1952
|
+
pp$7.parseRestBinding = function() {
|
|
1917
1953
|
var node = this.startNode();
|
|
1918
1954
|
this.next();
|
|
1919
1955
|
|
|
1920
1956
|
// RestElement inside of a function parameter must be an identifier
|
|
1921
|
-
if (this.options.ecmaVersion === 6 && this.type !== types.name)
|
|
1957
|
+
if (this.options.ecmaVersion === 6 && this.type !== types$1.name)
|
|
1922
1958
|
{ this.unexpected(); }
|
|
1923
1959
|
|
|
1924
1960
|
node.argument = this.parseBindingAtom();
|
|
@@ -1928,36 +1964,36 @@ pp$2.parseRestBinding = function() {
|
|
|
1928
1964
|
|
|
1929
1965
|
// Parses lvalue (assignable) atom.
|
|
1930
1966
|
|
|
1931
|
-
pp$
|
|
1967
|
+
pp$7.parseBindingAtom = function() {
|
|
1932
1968
|
if (this.options.ecmaVersion >= 6) {
|
|
1933
1969
|
switch (this.type) {
|
|
1934
|
-
case types.bracketL:
|
|
1970
|
+
case types$1.bracketL:
|
|
1935
1971
|
var node = this.startNode();
|
|
1936
1972
|
this.next();
|
|
1937
|
-
node.elements = this.parseBindingList(types.bracketR, true, true);
|
|
1973
|
+
node.elements = this.parseBindingList(types$1.bracketR, true, true);
|
|
1938
1974
|
return this.finishNode(node, "ArrayPattern")
|
|
1939
1975
|
|
|
1940
|
-
case types.braceL:
|
|
1976
|
+
case types$1.braceL:
|
|
1941
1977
|
return this.parseObj(true)
|
|
1942
1978
|
}
|
|
1943
1979
|
}
|
|
1944
1980
|
return this.parseIdent()
|
|
1945
1981
|
};
|
|
1946
1982
|
|
|
1947
|
-
pp$
|
|
1983
|
+
pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
1948
1984
|
var elts = [], first = true;
|
|
1949
1985
|
while (!this.eat(close)) {
|
|
1950
1986
|
if (first) { first = false; }
|
|
1951
|
-
else { this.expect(types.comma); }
|
|
1952
|
-
if (allowEmpty && this.type === types.comma) {
|
|
1987
|
+
else { this.expect(types$1.comma); }
|
|
1988
|
+
if (allowEmpty && this.type === types$1.comma) {
|
|
1953
1989
|
elts.push(null);
|
|
1954
1990
|
} else if (allowTrailingComma && this.afterTrailingComma(close)) {
|
|
1955
1991
|
break
|
|
1956
|
-
} else if (this.type === types.ellipsis) {
|
|
1992
|
+
} else if (this.type === types$1.ellipsis) {
|
|
1957
1993
|
var rest = this.parseRestBinding();
|
|
1958
1994
|
this.parseBindingListItem(rest);
|
|
1959
1995
|
elts.push(rest);
|
|
1960
|
-
if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
|
|
1996
|
+
if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
|
|
1961
1997
|
this.expect(close);
|
|
1962
1998
|
break
|
|
1963
1999
|
} else {
|
|
@@ -1969,15 +2005,15 @@ pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
|
1969
2005
|
return elts
|
|
1970
2006
|
};
|
|
1971
2007
|
|
|
1972
|
-
pp$
|
|
2008
|
+
pp$7.parseBindingListItem = function(param) {
|
|
1973
2009
|
return param
|
|
1974
2010
|
};
|
|
1975
2011
|
|
|
1976
2012
|
// Parses assignment pattern around given atom if possible.
|
|
1977
2013
|
|
|
1978
|
-
pp$
|
|
2014
|
+
pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
|
|
1979
2015
|
left = left || this.parseBindingAtom();
|
|
1980
|
-
if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) { return left }
|
|
2016
|
+
if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left }
|
|
1981
2017
|
var node = this.startNodeAt(startPos, startLoc);
|
|
1982
2018
|
node.left = left;
|
|
1983
2019
|
node.right = this.parseMaybeAssign();
|
|
@@ -2048,7 +2084,7 @@ pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
|
|
|
2048
2084
|
// duplicate argument names. checkClashes is ignored if the provided construct
|
|
2049
2085
|
// is an assignment (i.e., bindingType is BIND_NONE).
|
|
2050
2086
|
|
|
2051
|
-
pp$
|
|
2087
|
+
pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
|
|
2052
2088
|
if ( bindingType === void 0 ) bindingType = BIND_NONE;
|
|
2053
2089
|
|
|
2054
2090
|
var isBind = bindingType !== BIND_NONE;
|
|
@@ -2086,7 +2122,7 @@ pp$2.checkLValSimple = function(expr, bindingType, checkClashes) {
|
|
|
2086
2122
|
}
|
|
2087
2123
|
};
|
|
2088
2124
|
|
|
2089
|
-
pp$
|
|
2125
|
+
pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
|
|
2090
2126
|
if ( bindingType === void 0 ) bindingType = BIND_NONE;
|
|
2091
2127
|
|
|
2092
2128
|
switch (expr.type) {
|
|
@@ -2111,7 +2147,7 @@ pp$2.checkLValPattern = function(expr, bindingType, checkClashes) {
|
|
|
2111
2147
|
}
|
|
2112
2148
|
};
|
|
2113
2149
|
|
|
2114
|
-
pp$
|
|
2150
|
+
pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
|
|
2115
2151
|
if ( bindingType === void 0 ) bindingType = BIND_NONE;
|
|
2116
2152
|
|
|
2117
2153
|
switch (expr.type) {
|
|
@@ -2133,16 +2169,170 @@ pp$2.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
|
|
|
2133
2169
|
}
|
|
2134
2170
|
};
|
|
2135
2171
|
|
|
2172
|
+
// The algorithm used to determine whether a regexp can appear at a
|
|
2173
|
+
|
|
2174
|
+
var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
|
|
2175
|
+
this.token = token;
|
|
2176
|
+
this.isExpr = !!isExpr;
|
|
2177
|
+
this.preserveSpace = !!preserveSpace;
|
|
2178
|
+
this.override = override;
|
|
2179
|
+
this.generator = !!generator;
|
|
2180
|
+
};
|
|
2181
|
+
|
|
2182
|
+
var types = {
|
|
2183
|
+
b_stat: new TokContext("{", false),
|
|
2184
|
+
b_expr: new TokContext("{", true),
|
|
2185
|
+
b_tmpl: new TokContext("${", false),
|
|
2186
|
+
p_stat: new TokContext("(", false),
|
|
2187
|
+
p_expr: new TokContext("(", true),
|
|
2188
|
+
q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
|
|
2189
|
+
f_stat: new TokContext("function", false),
|
|
2190
|
+
f_expr: new TokContext("function", true),
|
|
2191
|
+
f_expr_gen: new TokContext("function", true, false, null, true),
|
|
2192
|
+
f_gen: new TokContext("function", false, false, null, true)
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2195
|
+
var pp$6 = Parser.prototype;
|
|
2196
|
+
|
|
2197
|
+
pp$6.initialContext = function() {
|
|
2198
|
+
return [types.b_stat]
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2201
|
+
pp$6.curContext = function() {
|
|
2202
|
+
return this.context[this.context.length - 1]
|
|
2203
|
+
};
|
|
2204
|
+
|
|
2205
|
+
pp$6.braceIsBlock = function(prevType) {
|
|
2206
|
+
var parent = this.curContext();
|
|
2207
|
+
if (parent === types.f_expr || parent === types.f_stat)
|
|
2208
|
+
{ return true }
|
|
2209
|
+
if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr))
|
|
2210
|
+
{ return !parent.isExpr }
|
|
2211
|
+
|
|
2212
|
+
// The check for `tt.name && exprAllowed` detects whether we are
|
|
2213
|
+
// after a `yield` or `of` construct. See the `updateContext` for
|
|
2214
|
+
// `tt.name`.
|
|
2215
|
+
if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed)
|
|
2216
|
+
{ return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
|
|
2217
|
+
if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow)
|
|
2218
|
+
{ return true }
|
|
2219
|
+
if (prevType === types$1.braceL)
|
|
2220
|
+
{ return parent === types.b_stat }
|
|
2221
|
+
if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name)
|
|
2222
|
+
{ return false }
|
|
2223
|
+
return !this.exprAllowed
|
|
2224
|
+
};
|
|
2225
|
+
|
|
2226
|
+
pp$6.inGeneratorContext = function() {
|
|
2227
|
+
for (var i = this.context.length - 1; i >= 1; i--) {
|
|
2228
|
+
var context = this.context[i];
|
|
2229
|
+
if (context.token === "function")
|
|
2230
|
+
{ return context.generator }
|
|
2231
|
+
}
|
|
2232
|
+
return false
|
|
2233
|
+
};
|
|
2234
|
+
|
|
2235
|
+
pp$6.updateContext = function(prevType) {
|
|
2236
|
+
var update, type = this.type;
|
|
2237
|
+
if (type.keyword && prevType === types$1.dot)
|
|
2238
|
+
{ this.exprAllowed = false; }
|
|
2239
|
+
else if (update = type.updateContext)
|
|
2240
|
+
{ update.call(this, prevType); }
|
|
2241
|
+
else
|
|
2242
|
+
{ this.exprAllowed = type.beforeExpr; }
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
// Used to handle egde case when token context could not be inferred correctly in tokenize phase
|
|
2246
|
+
pp$6.overrideContext = function(tokenCtx) {
|
|
2247
|
+
if (this.curContext() !== tokenCtx) {
|
|
2248
|
+
this.context[this.context.length - 1] = tokenCtx;
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
// Token-specific context update code
|
|
2253
|
+
|
|
2254
|
+
types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
|
|
2255
|
+
if (this.context.length === 1) {
|
|
2256
|
+
this.exprAllowed = true;
|
|
2257
|
+
return
|
|
2258
|
+
}
|
|
2259
|
+
var out = this.context.pop();
|
|
2260
|
+
if (out === types.b_stat && this.curContext().token === "function") {
|
|
2261
|
+
out = this.context.pop();
|
|
2262
|
+
}
|
|
2263
|
+
this.exprAllowed = !out.isExpr;
|
|
2264
|
+
};
|
|
2265
|
+
|
|
2266
|
+
types$1.braceL.updateContext = function(prevType) {
|
|
2267
|
+
this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
|
|
2268
|
+
this.exprAllowed = true;
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
types$1.dollarBraceL.updateContext = function() {
|
|
2272
|
+
this.context.push(types.b_tmpl);
|
|
2273
|
+
this.exprAllowed = true;
|
|
2274
|
+
};
|
|
2275
|
+
|
|
2276
|
+
types$1.parenL.updateContext = function(prevType) {
|
|
2277
|
+
var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
|
|
2278
|
+
this.context.push(statementParens ? types.p_stat : types.p_expr);
|
|
2279
|
+
this.exprAllowed = true;
|
|
2280
|
+
};
|
|
2281
|
+
|
|
2282
|
+
types$1.incDec.updateContext = function() {
|
|
2283
|
+
// tokExprAllowed stays unchanged
|
|
2284
|
+
};
|
|
2285
|
+
|
|
2286
|
+
types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
|
|
2287
|
+
if (prevType.beforeExpr && prevType !== types$1._else &&
|
|
2288
|
+
!(prevType === types$1.semi && this.curContext() !== types.p_stat) &&
|
|
2289
|
+
!(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
|
|
2290
|
+
!((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat))
|
|
2291
|
+
{ this.context.push(types.f_expr); }
|
|
2292
|
+
else
|
|
2293
|
+
{ this.context.push(types.f_stat); }
|
|
2294
|
+
this.exprAllowed = false;
|
|
2295
|
+
};
|
|
2296
|
+
|
|
2297
|
+
types$1.backQuote.updateContext = function() {
|
|
2298
|
+
if (this.curContext() === types.q_tmpl)
|
|
2299
|
+
{ this.context.pop(); }
|
|
2300
|
+
else
|
|
2301
|
+
{ this.context.push(types.q_tmpl); }
|
|
2302
|
+
this.exprAllowed = false;
|
|
2303
|
+
};
|
|
2304
|
+
|
|
2305
|
+
types$1.star.updateContext = function(prevType) {
|
|
2306
|
+
if (prevType === types$1._function) {
|
|
2307
|
+
var index = this.context.length - 1;
|
|
2308
|
+
if (this.context[index] === types.f_expr)
|
|
2309
|
+
{ this.context[index] = types.f_expr_gen; }
|
|
2310
|
+
else
|
|
2311
|
+
{ this.context[index] = types.f_gen; }
|
|
2312
|
+
}
|
|
2313
|
+
this.exprAllowed = true;
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
types$1.name.updateContext = function(prevType) {
|
|
2317
|
+
var allowed = false;
|
|
2318
|
+
if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
|
|
2319
|
+
if (this.value === "of" && !this.exprAllowed ||
|
|
2320
|
+
this.value === "yield" && this.inGeneratorContext())
|
|
2321
|
+
{ allowed = true; }
|
|
2322
|
+
}
|
|
2323
|
+
this.exprAllowed = allowed;
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2136
2326
|
// A recursive descent parser operates by defining functions for all
|
|
2137
2327
|
|
|
2138
|
-
var pp$
|
|
2328
|
+
var pp$5 = Parser.prototype;
|
|
2139
2329
|
|
|
2140
2330
|
// Check if property name clashes with already added.
|
|
2141
2331
|
// Object/class getters and setters are not allowed to clash —
|
|
2142
2332
|
// either with each other or with an init property — and in
|
|
2143
2333
|
// strict mode, init properties are also not allowed to be repeated.
|
|
2144
2334
|
|
|
2145
|
-
pp$
|
|
2335
|
+
pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
2146
2336
|
if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
|
|
2147
2337
|
{ return }
|
|
2148
2338
|
if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
|
|
@@ -2159,10 +2349,12 @@ pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
|
2159
2349
|
if (name === "__proto__" && kind === "init") {
|
|
2160
2350
|
if (propHash.proto) {
|
|
2161
2351
|
if (refDestructuringErrors) {
|
|
2162
|
-
if (refDestructuringErrors.doubleProto < 0)
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
} else {
|
|
2352
|
+
if (refDestructuringErrors.doubleProto < 0) {
|
|
2353
|
+
refDestructuringErrors.doubleProto = key.start;
|
|
2354
|
+
}
|
|
2355
|
+
} else {
|
|
2356
|
+
this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
|
|
2357
|
+
}
|
|
2166
2358
|
}
|
|
2167
2359
|
propHash.proto = true;
|
|
2168
2360
|
}
|
|
@@ -2204,13 +2396,13 @@ pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
|
2204
2396
|
// and object pattern might appear (so it's possible to raise
|
|
2205
2397
|
// delayed syntax error at correct position).
|
|
2206
2398
|
|
|
2207
|
-
pp$
|
|
2399
|
+
pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
2208
2400
|
var startPos = this.start, startLoc = this.startLoc;
|
|
2209
2401
|
var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
2210
|
-
if (this.type === types.comma) {
|
|
2402
|
+
if (this.type === types$1.comma) {
|
|
2211
2403
|
var node = this.startNodeAt(startPos, startLoc);
|
|
2212
2404
|
node.expressions = [expr];
|
|
2213
|
-
while (this.eat(types.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
|
|
2405
|
+
while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
|
|
2214
2406
|
return this.finishNode(node, "SequenceExpression")
|
|
2215
2407
|
}
|
|
2216
2408
|
return expr
|
|
@@ -2219,7 +2411,7 @@ pp$3.parseExpression = function(forInit, refDestructuringErrors) {
|
|
|
2219
2411
|
// Parse an assignment expression. This includes applications of
|
|
2220
2412
|
// operators like `+=`.
|
|
2221
2413
|
|
|
2222
|
-
pp$
|
|
2414
|
+
pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
|
|
2223
2415
|
if (this.isContextual("yield")) {
|
|
2224
2416
|
if (this.inGenerator) { return this.parseYield(forInit) }
|
|
2225
2417
|
// The tokenizer will assume an expression is allowed after
|
|
@@ -2227,10 +2419,11 @@ pp$3.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse
|
|
|
2227
2419
|
else { this.exprAllowed = false; }
|
|
2228
2420
|
}
|
|
2229
2421
|
|
|
2230
|
-
var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
|
|
2422
|
+
var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
|
|
2231
2423
|
if (refDestructuringErrors) {
|
|
2232
2424
|
oldParenAssign = refDestructuringErrors.parenthesizedAssign;
|
|
2233
2425
|
oldTrailingComma = refDestructuringErrors.trailingComma;
|
|
2426
|
+
oldDoubleProto = refDestructuringErrors.doubleProto;
|
|
2234
2427
|
refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
|
|
2235
2428
|
} else {
|
|
2236
2429
|
refDestructuringErrors = new DestructuringErrors;
|
|
@@ -2238,7 +2431,7 @@ pp$3.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse
|
|
|
2238
2431
|
}
|
|
2239
2432
|
|
|
2240
2433
|
var startPos = this.start, startLoc = this.startLoc;
|
|
2241
|
-
if (this.type === types.parenL || this.type === types.name) {
|
|
2434
|
+
if (this.type === types$1.parenL || this.type === types$1.name) {
|
|
2242
2435
|
this.potentialArrowAt = this.start;
|
|
2243
2436
|
this.potentialArrowInForAwait = forInit === "await";
|
|
2244
2437
|
}
|
|
@@ -2247,20 +2440,21 @@ pp$3.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse
|
|
|
2247
2440
|
if (this.type.isAssign) {
|
|
2248
2441
|
var node = this.startNodeAt(startPos, startLoc);
|
|
2249
2442
|
node.operator = this.value;
|
|
2250
|
-
if (this.type === types.eq)
|
|
2443
|
+
if (this.type === types$1.eq)
|
|
2251
2444
|
{ left = this.toAssignable(left, false, refDestructuringErrors); }
|
|
2252
2445
|
if (!ownDestructuringErrors) {
|
|
2253
2446
|
refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
|
|
2254
2447
|
}
|
|
2255
2448
|
if (refDestructuringErrors.shorthandAssign >= left.start)
|
|
2256
2449
|
{ refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
|
|
2257
|
-
if (this.type === types.eq)
|
|
2450
|
+
if (this.type === types$1.eq)
|
|
2258
2451
|
{ this.checkLValPattern(left); }
|
|
2259
2452
|
else
|
|
2260
2453
|
{ this.checkLValSimple(left); }
|
|
2261
2454
|
node.left = left;
|
|
2262
2455
|
this.next();
|
|
2263
2456
|
node.right = this.parseMaybeAssign(forInit);
|
|
2457
|
+
if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; }
|
|
2264
2458
|
return this.finishNode(node, "AssignmentExpression")
|
|
2265
2459
|
} else {
|
|
2266
2460
|
if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
|
|
@@ -2272,15 +2466,15 @@ pp$3.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse
|
|
|
2272
2466
|
|
|
2273
2467
|
// Parse a ternary conditional (`?:`) operator.
|
|
2274
2468
|
|
|
2275
|
-
pp$
|
|
2469
|
+
pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
2276
2470
|
var startPos = this.start, startLoc = this.startLoc;
|
|
2277
2471
|
var expr = this.parseExprOps(forInit, refDestructuringErrors);
|
|
2278
2472
|
if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
|
|
2279
|
-
if (this.eat(types.question)) {
|
|
2473
|
+
if (this.eat(types$1.question)) {
|
|
2280
2474
|
var node = this.startNodeAt(startPos, startLoc);
|
|
2281
2475
|
node.test = expr;
|
|
2282
2476
|
node.consequent = this.parseMaybeAssign();
|
|
2283
|
-
this.expect(types.colon);
|
|
2477
|
+
this.expect(types$1.colon);
|
|
2284
2478
|
node.alternate = this.parseMaybeAssign(forInit);
|
|
2285
2479
|
return this.finishNode(node, "ConditionalExpression")
|
|
2286
2480
|
}
|
|
@@ -2289,9 +2483,9 @@ pp$3.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
|
2289
2483
|
|
|
2290
2484
|
// Start the precedence parser.
|
|
2291
2485
|
|
|
2292
|
-
pp$
|
|
2486
|
+
pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
|
|
2293
2487
|
var startPos = this.start, startLoc = this.startLoc;
|
|
2294
|
-
var expr = this.parseMaybeUnary(refDestructuringErrors, false);
|
|
2488
|
+
var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
|
|
2295
2489
|
if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
|
|
2296
2490
|
return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)
|
|
2297
2491
|
};
|
|
@@ -2302,23 +2496,23 @@ pp$3.parseExprOps = function(forInit, refDestructuringErrors) {
|
|
|
2302
2496
|
// defer further parser to one of its callers when it encounters an
|
|
2303
2497
|
// operator that has a lower precedence than the set it is parsing.
|
|
2304
2498
|
|
|
2305
|
-
pp$
|
|
2499
|
+
pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
|
|
2306
2500
|
var prec = this.type.binop;
|
|
2307
|
-
if (prec != null && (!forInit || this.type !== types._in)) {
|
|
2501
|
+
if (prec != null && (!forInit || this.type !== types$1._in)) {
|
|
2308
2502
|
if (prec > minPrec) {
|
|
2309
|
-
var logical = this.type === types.logicalOR || this.type === types.logicalAND;
|
|
2310
|
-
var coalesce = this.type === types.coalesce;
|
|
2503
|
+
var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
|
|
2504
|
+
var coalesce = this.type === types$1.coalesce;
|
|
2311
2505
|
if (coalesce) {
|
|
2312
2506
|
// Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
|
|
2313
2507
|
// In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
|
|
2314
|
-
prec = types.logicalAND.binop;
|
|
2508
|
+
prec = types$1.logicalAND.binop;
|
|
2315
2509
|
}
|
|
2316
2510
|
var op = this.value;
|
|
2317
2511
|
this.next();
|
|
2318
2512
|
var startPos = this.start, startLoc = this.startLoc;
|
|
2319
|
-
var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, forInit);
|
|
2513
|
+
var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
|
|
2320
2514
|
var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
|
|
2321
|
-
if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
|
|
2515
|
+
if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) {
|
|
2322
2516
|
this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
|
|
2323
2517
|
}
|
|
2324
2518
|
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)
|
|
@@ -2327,7 +2521,8 @@ pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit)
|
|
|
2327
2521
|
return left
|
|
2328
2522
|
};
|
|
2329
2523
|
|
|
2330
|
-
pp$
|
|
2524
|
+
pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
|
|
2525
|
+
if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); }
|
|
2331
2526
|
var node = this.startNodeAt(startPos, startLoc);
|
|
2332
2527
|
node.left = left;
|
|
2333
2528
|
node.operator = op;
|
|
@@ -2337,17 +2532,17 @@ pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
|
|
|
2337
2532
|
|
|
2338
2533
|
// Parse unary operators, both prefix and postfix.
|
|
2339
2534
|
|
|
2340
|
-
pp$
|
|
2535
|
+
pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
|
|
2341
2536
|
var startPos = this.start, startLoc = this.startLoc, expr;
|
|
2342
2537
|
if (this.isContextual("await") && this.canAwait) {
|
|
2343
|
-
expr = this.parseAwait();
|
|
2538
|
+
expr = this.parseAwait(forInit);
|
|
2344
2539
|
sawUnary = true;
|
|
2345
2540
|
} else if (this.type.prefix) {
|
|
2346
|
-
var node = this.startNode(), update = this.type === types.incDec;
|
|
2541
|
+
var node = this.startNode(), update = this.type === types$1.incDec;
|
|
2347
2542
|
node.operator = this.value;
|
|
2348
2543
|
node.prefix = true;
|
|
2349
2544
|
this.next();
|
|
2350
|
-
node.argument = this.parseMaybeUnary(null, true, update);
|
|
2545
|
+
node.argument = this.parseMaybeUnary(null, true, update, forInit);
|
|
2351
2546
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
2352
2547
|
if (update) { this.checkLValSimple(node.argument); }
|
|
2353
2548
|
else if (this.strict && node.operator === "delete" &&
|
|
@@ -2357,8 +2552,13 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec) {
|
|
|
2357
2552
|
{ this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
|
|
2358
2553
|
else { sawUnary = true; }
|
|
2359
2554
|
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
|
2555
|
+
} else if (!sawUnary && this.type === types$1.privateId) {
|
|
2556
|
+
if (forInit || this.privateNameStack.length === 0) { this.unexpected(); }
|
|
2557
|
+
expr = this.parsePrivateIdent();
|
|
2558
|
+
// only could be private fields in 'in', such as #x in obj
|
|
2559
|
+
if (this.type !== types$1._in) { this.unexpected(); }
|
|
2360
2560
|
} else {
|
|
2361
|
-
expr = this.parseExprSubscripts(refDestructuringErrors);
|
|
2561
|
+
expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
|
|
2362
2562
|
if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
|
|
2363
2563
|
while (this.type.postfix && !this.canInsertSemicolon()) {
|
|
2364
2564
|
var node$1 = this.startNodeAt(startPos, startLoc);
|
|
@@ -2371,11 +2571,11 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec) {
|
|
|
2371
2571
|
}
|
|
2372
2572
|
}
|
|
2373
2573
|
|
|
2374
|
-
if (!incDec && this.eat(types.starstar)) {
|
|
2574
|
+
if (!incDec && this.eat(types$1.starstar)) {
|
|
2375
2575
|
if (sawUnary)
|
|
2376
2576
|
{ this.unexpected(this.lastTokStart); }
|
|
2377
2577
|
else
|
|
2378
|
-
{ return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) }
|
|
2578
|
+
{ return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) }
|
|
2379
2579
|
} else {
|
|
2380
2580
|
return expr
|
|
2381
2581
|
}
|
|
@@ -2390,12 +2590,12 @@ function isPrivateFieldAccess(node) {
|
|
|
2390
2590
|
|
|
2391
2591
|
// Parse call, dot, and `[]`-subscript expressions.
|
|
2392
2592
|
|
|
2393
|
-
pp$
|
|
2593
|
+
pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
|
|
2394
2594
|
var startPos = this.start, startLoc = this.startLoc;
|
|
2395
|
-
var expr = this.parseExprAtom(refDestructuringErrors);
|
|
2595
|
+
var expr = this.parseExprAtom(refDestructuringErrors, forInit);
|
|
2396
2596
|
if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
|
|
2397
2597
|
{ return expr }
|
|
2398
|
-
var result = this.parseSubscripts(expr, startPos, startLoc);
|
|
2598
|
+
var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
|
|
2399
2599
|
if (refDestructuringErrors && result.type === "MemberExpression") {
|
|
2400
2600
|
if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
|
|
2401
2601
|
if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
|
|
@@ -2404,14 +2604,14 @@ pp$3.parseExprSubscripts = function(refDestructuringErrors) {
|
|
|
2404
2604
|
return result
|
|
2405
2605
|
};
|
|
2406
2606
|
|
|
2407
|
-
pp$
|
|
2607
|
+
pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
|
|
2408
2608
|
var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
|
|
2409
2609
|
this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
|
|
2410
2610
|
this.potentialArrowAt === base.start;
|
|
2411
2611
|
var optionalChained = false;
|
|
2412
2612
|
|
|
2413
2613
|
while (true) {
|
|
2414
|
-
var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained);
|
|
2614
|
+
var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
|
|
2415
2615
|
|
|
2416
2616
|
if (element.optional) { optionalChained = true; }
|
|
2417
2617
|
if (element === base || element.type === "ArrowFunctionExpression") {
|
|
@@ -2427,19 +2627,19 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
|
|
|
2427
2627
|
}
|
|
2428
2628
|
};
|
|
2429
2629
|
|
|
2430
|
-
pp$
|
|
2630
|
+
pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
|
|
2431
2631
|
var optionalSupported = this.options.ecmaVersion >= 11;
|
|
2432
|
-
var optional = optionalSupported && this.eat(types.questionDot);
|
|
2632
|
+
var optional = optionalSupported && this.eat(types$1.questionDot);
|
|
2433
2633
|
if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
|
|
2434
2634
|
|
|
2435
|
-
var computed = this.eat(types.bracketL);
|
|
2436
|
-
if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
|
|
2635
|
+
var computed = this.eat(types$1.bracketL);
|
|
2636
|
+
if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) {
|
|
2437
2637
|
var node = this.startNodeAt(startPos, startLoc);
|
|
2438
2638
|
node.object = base;
|
|
2439
2639
|
if (computed) {
|
|
2440
2640
|
node.property = this.parseExpression();
|
|
2441
|
-
this.expect(types.bracketR);
|
|
2442
|
-
} else if (this.type === types.privateId && base.type !== "Super") {
|
|
2641
|
+
this.expect(types$1.bracketR);
|
|
2642
|
+
} else if (this.type === types$1.privateId && base.type !== "Super") {
|
|
2443
2643
|
node.property = this.parsePrivateIdent();
|
|
2444
2644
|
} else {
|
|
2445
2645
|
node.property = this.parseIdent(this.options.allowReserved !== "never");
|
|
@@ -2449,13 +2649,13 @@ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2449
2649
|
node.optional = optional;
|
|
2450
2650
|
}
|
|
2451
2651
|
base = this.finishNode(node, "MemberExpression");
|
|
2452
|
-
} else if (!noCalls && this.eat(types.parenL)) {
|
|
2652
|
+
} else if (!noCalls && this.eat(types$1.parenL)) {
|
|
2453
2653
|
var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
2454
2654
|
this.yieldPos = 0;
|
|
2455
2655
|
this.awaitPos = 0;
|
|
2456
2656
|
this.awaitIdentPos = 0;
|
|
2457
|
-
var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
|
|
2458
|
-
if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types.arrow)) {
|
|
2657
|
+
var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
|
|
2658
|
+
if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
|
|
2459
2659
|
this.checkPatternErrors(refDestructuringErrors, false);
|
|
2460
2660
|
this.checkYieldAwaitInDefaultParams();
|
|
2461
2661
|
if (this.awaitIdentPos > 0)
|
|
@@ -2463,7 +2663,7 @@ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2463
2663
|
this.yieldPos = oldYieldPos;
|
|
2464
2664
|
this.awaitPos = oldAwaitPos;
|
|
2465
2665
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
2466
|
-
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true)
|
|
2666
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
|
|
2467
2667
|
}
|
|
2468
2668
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
2469
2669
|
this.yieldPos = oldYieldPos || this.yieldPos;
|
|
@@ -2476,7 +2676,7 @@ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2476
2676
|
node$1.optional = optional;
|
|
2477
2677
|
}
|
|
2478
2678
|
base = this.finishNode(node$1, "CallExpression");
|
|
2479
|
-
} else if (this.type === types.backQuote) {
|
|
2679
|
+
} else if (this.type === types$1.backQuote) {
|
|
2480
2680
|
if (optional || optionalChained) {
|
|
2481
2681
|
this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
|
|
2482
2682
|
}
|
|
@@ -2493,19 +2693,19 @@ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2493
2693
|
// `new`, or an expression wrapped in punctuation like `()`, `[]`,
|
|
2494
2694
|
// or `{}`.
|
|
2495
2695
|
|
|
2496
|
-
pp$
|
|
2696
|
+
pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
|
|
2497
2697
|
// If a division operator appears in an expression position, the
|
|
2498
2698
|
// tokenizer got confused, and we force it to read a regexp instead.
|
|
2499
|
-
if (this.type === types.slash) { this.readRegexp(); }
|
|
2699
|
+
if (this.type === types$1.slash) { this.readRegexp(); }
|
|
2500
2700
|
|
|
2501
2701
|
var node, canBeArrow = this.potentialArrowAt === this.start;
|
|
2502
2702
|
switch (this.type) {
|
|
2503
|
-
case types._super:
|
|
2703
|
+
case types$1._super:
|
|
2504
2704
|
if (!this.allowSuper)
|
|
2505
2705
|
{ this.raise(this.start, "'super' keyword outside a method"); }
|
|
2506
2706
|
node = this.startNode();
|
|
2507
2707
|
this.next();
|
|
2508
|
-
if (this.type === types.parenL && !this.allowDirectSuper)
|
|
2708
|
+
if (this.type === types$1.parenL && !this.allowDirectSuper)
|
|
2509
2709
|
{ this.raise(node.start, "super() call outside constructor of a subclass"); }
|
|
2510
2710
|
// The `super` keyword can appear at below:
|
|
2511
2711
|
// SuperProperty:
|
|
@@ -2513,51 +2713,53 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
|
|
|
2513
2713
|
// super . IdentifierName
|
|
2514
2714
|
// SuperCall:
|
|
2515
2715
|
// super ( Arguments )
|
|
2516
|
-
if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
|
|
2716
|
+
if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL)
|
|
2517
2717
|
{ this.unexpected(); }
|
|
2518
2718
|
return this.finishNode(node, "Super")
|
|
2519
2719
|
|
|
2520
|
-
case types._this:
|
|
2720
|
+
case types$1._this:
|
|
2521
2721
|
node = this.startNode();
|
|
2522
2722
|
this.next();
|
|
2523
2723
|
return this.finishNode(node, "ThisExpression")
|
|
2524
2724
|
|
|
2525
|
-
case types.name:
|
|
2725
|
+
case types$1.name:
|
|
2526
2726
|
var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
|
|
2527
2727
|
var id = this.parseIdent(false);
|
|
2528
|
-
if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function))
|
|
2529
|
-
|
|
2728
|
+
if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
|
|
2729
|
+
this.overrideContext(types.f_expr);
|
|
2730
|
+
return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)
|
|
2731
|
+
}
|
|
2530
2732
|
if (canBeArrow && !this.canInsertSemicolon()) {
|
|
2531
|
-
if (this.eat(types.arrow))
|
|
2532
|
-
{ return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) }
|
|
2533
|
-
if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc &&
|
|
2733
|
+
if (this.eat(types$1.arrow))
|
|
2734
|
+
{ return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }
|
|
2735
|
+
if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc &&
|
|
2534
2736
|
(!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
|
|
2535
2737
|
id = this.parseIdent(false);
|
|
2536
|
-
if (this.canInsertSemicolon() || !this.eat(types.arrow))
|
|
2738
|
+
if (this.canInsertSemicolon() || !this.eat(types$1.arrow))
|
|
2537
2739
|
{ this.unexpected(); }
|
|
2538
|
-
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)
|
|
2740
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)
|
|
2539
2741
|
}
|
|
2540
2742
|
}
|
|
2541
2743
|
return id
|
|
2542
2744
|
|
|
2543
|
-
case types.regexp:
|
|
2745
|
+
case types$1.regexp:
|
|
2544
2746
|
var value = this.value;
|
|
2545
2747
|
node = this.parseLiteral(value.value);
|
|
2546
2748
|
node.regex = {pattern: value.pattern, flags: value.flags};
|
|
2547
2749
|
return node
|
|
2548
2750
|
|
|
2549
|
-
case types.num: case types.string:
|
|
2751
|
+
case types$1.num: case types$1.string:
|
|
2550
2752
|
return this.parseLiteral(this.value)
|
|
2551
2753
|
|
|
2552
|
-
case types._null: case types._true: case types._false:
|
|
2754
|
+
case types$1._null: case types$1._true: case types$1._false:
|
|
2553
2755
|
node = this.startNode();
|
|
2554
|
-
node.value = this.type === types._null ? null : this.type === types._true;
|
|
2756
|
+
node.value = this.type === types$1._null ? null : this.type === types$1._true;
|
|
2555
2757
|
node.raw = this.type.keyword;
|
|
2556
2758
|
this.next();
|
|
2557
2759
|
return this.finishNode(node, "Literal")
|
|
2558
2760
|
|
|
2559
|
-
case types.parenL:
|
|
2560
|
-
var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow);
|
|
2761
|
+
case types$1.parenL:
|
|
2762
|
+
var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
|
|
2561
2763
|
if (refDestructuringErrors) {
|
|
2562
2764
|
if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
|
|
2563
2765
|
{ refDestructuringErrors.parenthesizedAssign = start; }
|
|
@@ -2566,30 +2768,31 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
|
|
|
2566
2768
|
}
|
|
2567
2769
|
return expr
|
|
2568
2770
|
|
|
2569
|
-
case types.bracketL:
|
|
2771
|
+
case types$1.bracketL:
|
|
2570
2772
|
node = this.startNode();
|
|
2571
2773
|
this.next();
|
|
2572
|
-
node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
|
|
2774
|
+
node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
|
|
2573
2775
|
return this.finishNode(node, "ArrayExpression")
|
|
2574
2776
|
|
|
2575
|
-
case types.braceL:
|
|
2777
|
+
case types$1.braceL:
|
|
2778
|
+
this.overrideContext(types.b_expr);
|
|
2576
2779
|
return this.parseObj(false, refDestructuringErrors)
|
|
2577
2780
|
|
|
2578
|
-
case types._function:
|
|
2781
|
+
case types$1._function:
|
|
2579
2782
|
node = this.startNode();
|
|
2580
2783
|
this.next();
|
|
2581
2784
|
return this.parseFunction(node, 0)
|
|
2582
2785
|
|
|
2583
|
-
case types._class:
|
|
2786
|
+
case types$1._class:
|
|
2584
2787
|
return this.parseClass(this.startNode(), false)
|
|
2585
2788
|
|
|
2586
|
-
case types._new:
|
|
2789
|
+
case types$1._new:
|
|
2587
2790
|
return this.parseNew()
|
|
2588
2791
|
|
|
2589
|
-
case types.backQuote:
|
|
2792
|
+
case types$1.backQuote:
|
|
2590
2793
|
return this.parseTemplate()
|
|
2591
2794
|
|
|
2592
|
-
case types._import:
|
|
2795
|
+
case types$1._import:
|
|
2593
2796
|
if (this.options.ecmaVersion >= 11) {
|
|
2594
2797
|
return this.parseExprImport()
|
|
2595
2798
|
} else {
|
|
@@ -2601,7 +2804,7 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
|
|
|
2601
2804
|
}
|
|
2602
2805
|
};
|
|
2603
2806
|
|
|
2604
|
-
pp$
|
|
2807
|
+
pp$5.parseExprImport = function() {
|
|
2605
2808
|
var node = this.startNode();
|
|
2606
2809
|
|
|
2607
2810
|
// Consume `import` as an identifier for `import.meta`.
|
|
@@ -2610,9 +2813,9 @@ pp$3.parseExprImport = function() {
|
|
|
2610
2813
|
var meta = this.parseIdent(true);
|
|
2611
2814
|
|
|
2612
2815
|
switch (this.type) {
|
|
2613
|
-
case types.parenL:
|
|
2816
|
+
case types$1.parenL:
|
|
2614
2817
|
return this.parseDynamicImport(node)
|
|
2615
|
-
case types.dot:
|
|
2818
|
+
case types$1.dot:
|
|
2616
2819
|
node.meta = meta;
|
|
2617
2820
|
return this.parseImportMeta(node)
|
|
2618
2821
|
default:
|
|
@@ -2620,16 +2823,16 @@ pp$3.parseExprImport = function() {
|
|
|
2620
2823
|
}
|
|
2621
2824
|
};
|
|
2622
2825
|
|
|
2623
|
-
pp$
|
|
2826
|
+
pp$5.parseDynamicImport = function(node) {
|
|
2624
2827
|
this.next(); // skip `(`
|
|
2625
2828
|
|
|
2626
2829
|
// Parse node.source.
|
|
2627
2830
|
node.source = this.parseMaybeAssign();
|
|
2628
2831
|
|
|
2629
2832
|
// Verify ending.
|
|
2630
|
-
if (!this.eat(types.parenR)) {
|
|
2833
|
+
if (!this.eat(types$1.parenR)) {
|
|
2631
2834
|
var errorPos = this.start;
|
|
2632
|
-
if (this.eat(types.comma) && this.eat(types.parenR)) {
|
|
2835
|
+
if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
|
|
2633
2836
|
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
|
|
2634
2837
|
} else {
|
|
2635
2838
|
this.unexpected(errorPos);
|
|
@@ -2639,7 +2842,7 @@ pp$3.parseDynamicImport = function(node) {
|
|
|
2639
2842
|
return this.finishNode(node, "ImportExpression")
|
|
2640
2843
|
};
|
|
2641
2844
|
|
|
2642
|
-
pp$
|
|
2845
|
+
pp$5.parseImportMeta = function(node) {
|
|
2643
2846
|
this.next(); // skip `.`
|
|
2644
2847
|
|
|
2645
2848
|
var containsEsc = this.containsEsc;
|
|
@@ -2655,7 +2858,7 @@ pp$3.parseImportMeta = function(node) {
|
|
|
2655
2858
|
return this.finishNode(node, "MetaProperty")
|
|
2656
2859
|
};
|
|
2657
2860
|
|
|
2658
|
-
pp$
|
|
2861
|
+
pp$5.parseLiteral = function(value) {
|
|
2659
2862
|
var node = this.startNode();
|
|
2660
2863
|
node.value = value;
|
|
2661
2864
|
node.raw = this.input.slice(this.start, this.end);
|
|
@@ -2664,14 +2867,14 @@ pp$3.parseLiteral = function(value) {
|
|
|
2664
2867
|
return this.finishNode(node, "Literal")
|
|
2665
2868
|
};
|
|
2666
2869
|
|
|
2667
|
-
pp$
|
|
2668
|
-
this.expect(types.parenL);
|
|
2870
|
+
pp$5.parseParenExpression = function() {
|
|
2871
|
+
this.expect(types$1.parenL);
|
|
2669
2872
|
var val = this.parseExpression();
|
|
2670
|
-
this.expect(types.parenR);
|
|
2873
|
+
this.expect(types$1.parenR);
|
|
2671
2874
|
return val
|
|
2672
2875
|
};
|
|
2673
2876
|
|
|
2674
|
-
pp$
|
|
2877
|
+
pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
2675
2878
|
var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
|
|
2676
2879
|
if (this.options.ecmaVersion >= 6) {
|
|
2677
2880
|
this.next();
|
|
@@ -2682,29 +2885,29 @@ pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
|
|
|
2682
2885
|
this.yieldPos = 0;
|
|
2683
2886
|
this.awaitPos = 0;
|
|
2684
2887
|
// Do not save awaitIdentPos to allow checking awaits nested in parameters
|
|
2685
|
-
while (this.type !== types.parenR) {
|
|
2686
|
-
first ? first = false : this.expect(types.comma);
|
|
2687
|
-
if (allowTrailingComma && this.afterTrailingComma(types.parenR, true)) {
|
|
2888
|
+
while (this.type !== types$1.parenR) {
|
|
2889
|
+
first ? first = false : this.expect(types$1.comma);
|
|
2890
|
+
if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
|
|
2688
2891
|
lastIsComma = true;
|
|
2689
2892
|
break
|
|
2690
|
-
} else if (this.type === types.ellipsis) {
|
|
2893
|
+
} else if (this.type === types$1.ellipsis) {
|
|
2691
2894
|
spreadStart = this.start;
|
|
2692
2895
|
exprList.push(this.parseParenItem(this.parseRestBinding()));
|
|
2693
|
-
if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
|
|
2896
|
+
if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
|
|
2694
2897
|
break
|
|
2695
2898
|
} else {
|
|
2696
2899
|
exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
|
|
2697
2900
|
}
|
|
2698
2901
|
}
|
|
2699
|
-
var innerEndPos = this.
|
|
2700
|
-
this.expect(types.parenR);
|
|
2902
|
+
var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
|
|
2903
|
+
this.expect(types$1.parenR);
|
|
2701
2904
|
|
|
2702
|
-
if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
|
|
2905
|
+
if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
|
|
2703
2906
|
this.checkPatternErrors(refDestructuringErrors, false);
|
|
2704
2907
|
this.checkYieldAwaitInDefaultParams();
|
|
2705
2908
|
this.yieldPos = oldYieldPos;
|
|
2706
2909
|
this.awaitPos = oldAwaitPos;
|
|
2707
|
-
return this.parseParenArrowList(startPos, startLoc, exprList)
|
|
2910
|
+
return this.parseParenArrowList(startPos, startLoc, exprList, forInit)
|
|
2708
2911
|
}
|
|
2709
2912
|
|
|
2710
2913
|
if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
|
|
@@ -2733,12 +2936,12 @@ pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
|
|
|
2733
2936
|
}
|
|
2734
2937
|
};
|
|
2735
2938
|
|
|
2736
|
-
pp$
|
|
2939
|
+
pp$5.parseParenItem = function(item) {
|
|
2737
2940
|
return item
|
|
2738
2941
|
};
|
|
2739
2942
|
|
|
2740
|
-
pp$
|
|
2741
|
-
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)
|
|
2943
|
+
pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
|
|
2944
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit)
|
|
2742
2945
|
};
|
|
2743
2946
|
|
|
2744
2947
|
// New's precedence is slightly tricky. It must allow its argument to
|
|
@@ -2747,13 +2950,13 @@ pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
|
|
|
2747
2950
|
// argument to parseSubscripts to prevent it from consuming the
|
|
2748
2951
|
// argument list.
|
|
2749
2952
|
|
|
2750
|
-
var empty
|
|
2953
|
+
var empty = [];
|
|
2751
2954
|
|
|
2752
|
-
pp$
|
|
2955
|
+
pp$5.parseNew = function() {
|
|
2753
2956
|
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
|
|
2754
2957
|
var node = this.startNode();
|
|
2755
2958
|
var meta = this.parseIdent(true);
|
|
2756
|
-
if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
|
|
2959
|
+
if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {
|
|
2757
2960
|
node.meta = meta;
|
|
2758
2961
|
var containsEsc = this.containsEsc;
|
|
2759
2962
|
node.property = this.parseIdent(true);
|
|
@@ -2761,27 +2964,27 @@ pp$3.parseNew = function() {
|
|
|
2761
2964
|
{ this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
|
|
2762
2965
|
if (containsEsc)
|
|
2763
2966
|
{ this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
|
|
2764
|
-
if (!this.
|
|
2765
|
-
{ this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); }
|
|
2967
|
+
if (!this.allowNewDotTarget)
|
|
2968
|
+
{ this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
|
|
2766
2969
|
return this.finishNode(node, "MetaProperty")
|
|
2767
2970
|
}
|
|
2768
|
-
var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import;
|
|
2769
|
-
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
|
|
2971
|
+
var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types$1._import;
|
|
2972
|
+
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
|
|
2770
2973
|
if (isImport && node.callee.type === "ImportExpression") {
|
|
2771
2974
|
this.raise(startPos, "Cannot use new with import()");
|
|
2772
2975
|
}
|
|
2773
|
-
if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
|
|
2774
|
-
else { node.arguments = empty
|
|
2976
|
+
if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
|
|
2977
|
+
else { node.arguments = empty; }
|
|
2775
2978
|
return this.finishNode(node, "NewExpression")
|
|
2776
2979
|
};
|
|
2777
2980
|
|
|
2778
2981
|
// Parse template expression.
|
|
2779
2982
|
|
|
2780
|
-
pp$
|
|
2983
|
+
pp$5.parseTemplateElement = function(ref) {
|
|
2781
2984
|
var isTagged = ref.isTagged;
|
|
2782
2985
|
|
|
2783
2986
|
var elem = this.startNode();
|
|
2784
|
-
if (this.type === types.invalidTemplate) {
|
|
2987
|
+
if (this.type === types$1.invalidTemplate) {
|
|
2785
2988
|
if (!isTagged) {
|
|
2786
2989
|
this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
|
|
2787
2990
|
}
|
|
@@ -2796,11 +2999,11 @@ pp$3.parseTemplateElement = function(ref) {
|
|
|
2796
2999
|
};
|
|
2797
3000
|
}
|
|
2798
3001
|
this.next();
|
|
2799
|
-
elem.tail = this.type === types.backQuote;
|
|
3002
|
+
elem.tail = this.type === types$1.backQuote;
|
|
2800
3003
|
return this.finishNode(elem, "TemplateElement")
|
|
2801
3004
|
};
|
|
2802
3005
|
|
|
2803
|
-
pp$
|
|
3006
|
+
pp$5.parseTemplate = function(ref) {
|
|
2804
3007
|
if ( ref === void 0 ) ref = {};
|
|
2805
3008
|
var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
|
|
2806
3009
|
|
|
@@ -2810,32 +3013,32 @@ pp$3.parseTemplate = function(ref) {
|
|
|
2810
3013
|
var curElt = this.parseTemplateElement({isTagged: isTagged});
|
|
2811
3014
|
node.quasis = [curElt];
|
|
2812
3015
|
while (!curElt.tail) {
|
|
2813
|
-
if (this.type === types.eof) { this.raise(this.pos, "Unterminated template literal"); }
|
|
2814
|
-
this.expect(types.dollarBraceL);
|
|
3016
|
+
if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); }
|
|
3017
|
+
this.expect(types$1.dollarBraceL);
|
|
2815
3018
|
node.expressions.push(this.parseExpression());
|
|
2816
|
-
this.expect(types.braceR);
|
|
3019
|
+
this.expect(types$1.braceR);
|
|
2817
3020
|
node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
|
|
2818
3021
|
}
|
|
2819
3022
|
this.next();
|
|
2820
3023
|
return this.finishNode(node, "TemplateLiteral")
|
|
2821
3024
|
};
|
|
2822
3025
|
|
|
2823
|
-
pp$
|
|
3026
|
+
pp$5.isAsyncProp = function(prop) {
|
|
2824
3027
|
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
|
|
2825
|
-
(this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types.star)) &&
|
|
3028
|
+
(this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) &&
|
|
2826
3029
|
!lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
|
|
2827
3030
|
};
|
|
2828
3031
|
|
|
2829
3032
|
// Parse an object literal or binding pattern.
|
|
2830
3033
|
|
|
2831
|
-
pp$
|
|
3034
|
+
pp$5.parseObj = function(isPattern, refDestructuringErrors) {
|
|
2832
3035
|
var node = this.startNode(), first = true, propHash = {};
|
|
2833
3036
|
node.properties = [];
|
|
2834
3037
|
this.next();
|
|
2835
|
-
while (!this.eat(types.braceR)) {
|
|
3038
|
+
while (!this.eat(types$1.braceR)) {
|
|
2836
3039
|
if (!first) {
|
|
2837
|
-
this.expect(types.comma);
|
|
2838
|
-
if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break }
|
|
3040
|
+
this.expect(types$1.comma);
|
|
3041
|
+
if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break }
|
|
2839
3042
|
} else { first = false; }
|
|
2840
3043
|
|
|
2841
3044
|
var prop = this.parseProperty(isPattern, refDestructuringErrors);
|
|
@@ -2845,18 +3048,18 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
|
|
|
2845
3048
|
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
|
|
2846
3049
|
};
|
|
2847
3050
|
|
|
2848
|
-
pp$
|
|
3051
|
+
pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
2849
3052
|
var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
|
|
2850
|
-
if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
|
|
3053
|
+
if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
|
|
2851
3054
|
if (isPattern) {
|
|
2852
3055
|
prop.argument = this.parseIdent(false);
|
|
2853
|
-
if (this.type === types.comma) {
|
|
3056
|
+
if (this.type === types$1.comma) {
|
|
2854
3057
|
this.raise(this.start, "Comma is not permitted after the rest element");
|
|
2855
3058
|
}
|
|
2856
3059
|
return this.finishNode(prop, "RestElement")
|
|
2857
3060
|
}
|
|
2858
3061
|
// To disallow parenthesized identifier via `this.toAssignable()`.
|
|
2859
|
-
if (this.type === types.parenL && refDestructuringErrors) {
|
|
3062
|
+
if (this.type === types$1.parenL && refDestructuringErrors) {
|
|
2860
3063
|
if (refDestructuringErrors.parenthesizedAssign < 0) {
|
|
2861
3064
|
refDestructuringErrors.parenthesizedAssign = this.start;
|
|
2862
3065
|
}
|
|
@@ -2867,7 +3070,7 @@ pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
2867
3070
|
// Parse argument.
|
|
2868
3071
|
prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
|
2869
3072
|
// To disallow trailing comma via `this.toAssignable()`.
|
|
2870
|
-
if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
|
|
3073
|
+
if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
|
|
2871
3074
|
refDestructuringErrors.trailingComma = this.start;
|
|
2872
3075
|
}
|
|
2873
3076
|
// Finish
|
|
@@ -2881,13 +3084,13 @@ pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
2881
3084
|
startLoc = this.startLoc;
|
|
2882
3085
|
}
|
|
2883
3086
|
if (!isPattern)
|
|
2884
|
-
{ isGenerator = this.eat(types.star); }
|
|
3087
|
+
{ isGenerator = this.eat(types$1.star); }
|
|
2885
3088
|
}
|
|
2886
3089
|
var containsEsc = this.containsEsc;
|
|
2887
3090
|
this.parsePropertyName(prop);
|
|
2888
3091
|
if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
|
|
2889
3092
|
isAsync = true;
|
|
2890
|
-
isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
|
|
3093
|
+
isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
|
|
2891
3094
|
this.parsePropertyName(prop, refDestructuringErrors);
|
|
2892
3095
|
} else {
|
|
2893
3096
|
isAsync = false;
|
|
@@ -2896,14 +3099,14 @@ pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
2896
3099
|
return this.finishNode(prop, "Property")
|
|
2897
3100
|
};
|
|
2898
3101
|
|
|
2899
|
-
pp$
|
|
2900
|
-
if ((isGenerator || isAsync) && this.type === types.colon)
|
|
3102
|
+
pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
|
|
3103
|
+
if ((isGenerator || isAsync) && this.type === types$1.colon)
|
|
2901
3104
|
{ this.unexpected(); }
|
|
2902
3105
|
|
|
2903
|
-
if (this.eat(types.colon)) {
|
|
3106
|
+
if (this.eat(types$1.colon)) {
|
|
2904
3107
|
prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
|
|
2905
3108
|
prop.kind = "init";
|
|
2906
|
-
} else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
|
|
3109
|
+
} else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
|
|
2907
3110
|
if (isPattern) { this.unexpected(); }
|
|
2908
3111
|
prop.kind = "init";
|
|
2909
3112
|
prop.method = true;
|
|
@@ -2911,7 +3114,7 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
2911
3114
|
} else if (!isPattern && !containsEsc &&
|
|
2912
3115
|
this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
|
|
2913
3116
|
(prop.key.name === "get" || prop.key.name === "set") &&
|
|
2914
|
-
(this.type !== types.comma && this.type !== types.braceR && this.type !== types.eq)) {
|
|
3117
|
+
(this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
|
|
2915
3118
|
if (isGenerator || isAsync) { this.unexpected(); }
|
|
2916
3119
|
prop.kind = prop.key.name;
|
|
2917
3120
|
this.parsePropertyName(prop);
|
|
@@ -2935,7 +3138,7 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
2935
3138
|
prop.kind = "init";
|
|
2936
3139
|
if (isPattern) {
|
|
2937
3140
|
prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
|
|
2938
|
-
} else if (this.type === types.eq && refDestructuringErrors) {
|
|
3141
|
+
} else if (this.type === types$1.eq && refDestructuringErrors) {
|
|
2939
3142
|
if (refDestructuringErrors.shorthandAssign < 0)
|
|
2940
3143
|
{ refDestructuringErrors.shorthandAssign = this.start; }
|
|
2941
3144
|
prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
|
|
@@ -2946,23 +3149,23 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
2946
3149
|
} else { this.unexpected(); }
|
|
2947
3150
|
};
|
|
2948
3151
|
|
|
2949
|
-
pp$
|
|
3152
|
+
pp$5.parsePropertyName = function(prop) {
|
|
2950
3153
|
if (this.options.ecmaVersion >= 6) {
|
|
2951
|
-
if (this.eat(types.bracketL)) {
|
|
3154
|
+
if (this.eat(types$1.bracketL)) {
|
|
2952
3155
|
prop.computed = true;
|
|
2953
3156
|
prop.key = this.parseMaybeAssign();
|
|
2954
|
-
this.expect(types.bracketR);
|
|
3157
|
+
this.expect(types$1.bracketR);
|
|
2955
3158
|
return prop.key
|
|
2956
3159
|
} else {
|
|
2957
3160
|
prop.computed = false;
|
|
2958
3161
|
}
|
|
2959
3162
|
}
|
|
2960
|
-
return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
|
|
3163
|
+
return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
|
|
2961
3164
|
};
|
|
2962
3165
|
|
|
2963
3166
|
// Initialize empty function node.
|
|
2964
3167
|
|
|
2965
|
-
pp$
|
|
3168
|
+
pp$5.initFunction = function(node) {
|
|
2966
3169
|
node.id = null;
|
|
2967
3170
|
if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
|
|
2968
3171
|
if (this.options.ecmaVersion >= 8) { node.async = false; }
|
|
@@ -2970,7 +3173,7 @@ pp$3.initFunction = function(node) {
|
|
|
2970
3173
|
|
|
2971
3174
|
// Parse object or class method.
|
|
2972
3175
|
|
|
2973
|
-
pp$
|
|
3176
|
+
pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
|
|
2974
3177
|
var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
2975
3178
|
|
|
2976
3179
|
this.initFunction(node);
|
|
@@ -2984,10 +3187,10 @@ pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
|
|
|
2984
3187
|
this.awaitIdentPos = 0;
|
|
2985
3188
|
this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
|
|
2986
3189
|
|
|
2987
|
-
this.expect(types.parenL);
|
|
2988
|
-
node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
|
|
3190
|
+
this.expect(types$1.parenL);
|
|
3191
|
+
node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
|
|
2989
3192
|
this.checkYieldAwaitInDefaultParams();
|
|
2990
|
-
this.parseFunctionBody(node, false, true);
|
|
3193
|
+
this.parseFunctionBody(node, false, true, false);
|
|
2991
3194
|
|
|
2992
3195
|
this.yieldPos = oldYieldPos;
|
|
2993
3196
|
this.awaitPos = oldAwaitPos;
|
|
@@ -2997,7 +3200,7 @@ pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
|
|
|
2997
3200
|
|
|
2998
3201
|
// Parse arrow function expression with given parameters.
|
|
2999
3202
|
|
|
3000
|
-
pp$
|
|
3203
|
+
pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
|
|
3001
3204
|
var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
3002
3205
|
|
|
3003
3206
|
this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
|
|
@@ -3009,7 +3212,7 @@ pp$3.parseArrowExpression = function(node, params, isAsync) {
|
|
|
3009
3212
|
this.awaitIdentPos = 0;
|
|
3010
3213
|
|
|
3011
3214
|
node.params = this.toAssignableList(params, true);
|
|
3012
|
-
this.parseFunctionBody(node, true, false);
|
|
3215
|
+
this.parseFunctionBody(node, true, false, forInit);
|
|
3013
3216
|
|
|
3014
3217
|
this.yieldPos = oldYieldPos;
|
|
3015
3218
|
this.awaitPos = oldAwaitPos;
|
|
@@ -3019,12 +3222,12 @@ pp$3.parseArrowExpression = function(node, params, isAsync) {
|
|
|
3019
3222
|
|
|
3020
3223
|
// Parse function body and check parameters.
|
|
3021
3224
|
|
|
3022
|
-
pp$
|
|
3023
|
-
var isExpression = isArrowFunction && this.type !== types.braceL;
|
|
3225
|
+
pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
|
|
3226
|
+
var isExpression = isArrowFunction && this.type !== types$1.braceL;
|
|
3024
3227
|
var oldStrict = this.strict, useStrict = false;
|
|
3025
3228
|
|
|
3026
3229
|
if (isExpression) {
|
|
3027
|
-
node.body = this.parseMaybeAssign();
|
|
3230
|
+
node.body = this.parseMaybeAssign(forInit);
|
|
3028
3231
|
node.expression = true;
|
|
3029
3232
|
this.checkParams(node, false);
|
|
3030
3233
|
} else {
|
|
@@ -3056,7 +3259,7 @@ pp$3.parseFunctionBody = function(node, isArrowFunction, isMethod) {
|
|
|
3056
3259
|
this.exitScope();
|
|
3057
3260
|
};
|
|
3058
3261
|
|
|
3059
|
-
pp$
|
|
3262
|
+
pp$5.isSimpleParamList = function(params) {
|
|
3060
3263
|
for (var i = 0, list = params; i < list.length; i += 1)
|
|
3061
3264
|
{
|
|
3062
3265
|
var param = list[i];
|
|
@@ -3069,7 +3272,7 @@ pp$3.isSimpleParamList = function(params) {
|
|
|
3069
3272
|
// Checks function params for various disallowed patterns such as using "eval"
|
|
3070
3273
|
// or "arguments" and duplicate parameters.
|
|
3071
3274
|
|
|
3072
|
-
pp$
|
|
3275
|
+
pp$5.checkParams = function(node, allowDuplicates) {
|
|
3073
3276
|
var nameHash = Object.create(null);
|
|
3074
3277
|
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
3075
3278
|
{
|
|
@@ -3085,20 +3288,20 @@ pp$3.checkParams = function(node, allowDuplicates) {
|
|
|
3085
3288
|
// nothing in between them to be parsed as `null` (which is needed
|
|
3086
3289
|
// for array literals).
|
|
3087
3290
|
|
|
3088
|
-
pp$
|
|
3291
|
+
pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
|
|
3089
3292
|
var elts = [], first = true;
|
|
3090
3293
|
while (!this.eat(close)) {
|
|
3091
3294
|
if (!first) {
|
|
3092
|
-
this.expect(types.comma);
|
|
3295
|
+
this.expect(types$1.comma);
|
|
3093
3296
|
if (allowTrailingComma && this.afterTrailingComma(close)) { break }
|
|
3094
3297
|
} else { first = false; }
|
|
3095
3298
|
|
|
3096
3299
|
var elt = (void 0);
|
|
3097
|
-
if (allowEmpty && this.type === types.comma)
|
|
3300
|
+
if (allowEmpty && this.type === types$1.comma)
|
|
3098
3301
|
{ elt = null; }
|
|
3099
|
-
else if (this.type === types.ellipsis) {
|
|
3302
|
+
else if (this.type === types$1.ellipsis) {
|
|
3100
3303
|
elt = this.parseSpread(refDestructuringErrors);
|
|
3101
|
-
if (refDestructuringErrors && this.type === types.comma && refDestructuringErrors.trailingComma < 0)
|
|
3304
|
+
if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0)
|
|
3102
3305
|
{ refDestructuringErrors.trailingComma = this.start; }
|
|
3103
3306
|
} else {
|
|
3104
3307
|
elt = this.parseMaybeAssign(false, refDestructuringErrors);
|
|
@@ -3108,7 +3311,7 @@ pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestruct
|
|
|
3108
3311
|
return elts
|
|
3109
3312
|
};
|
|
3110
3313
|
|
|
3111
|
-
pp$
|
|
3314
|
+
pp$5.checkUnreserved = function(ref) {
|
|
3112
3315
|
var start = ref.start;
|
|
3113
3316
|
var end = ref.end;
|
|
3114
3317
|
var name = ref.name;
|
|
@@ -3119,6 +3322,8 @@ pp$3.checkUnreserved = function(ref) {
|
|
|
3119
3322
|
{ this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
|
|
3120
3323
|
if (this.currentThisScope().inClassFieldInit && name === "arguments")
|
|
3121
3324
|
{ this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); }
|
|
3325
|
+
if (this.inClassStaticBlock && (name === "arguments" || name === "await"))
|
|
3326
|
+
{ this.raise(start, ("Cannot use " + name + " in class static initialization block")); }
|
|
3122
3327
|
if (this.keywords.test(name))
|
|
3123
3328
|
{ this.raise(start, ("Unexpected keyword '" + name + "'")); }
|
|
3124
3329
|
if (this.options.ecmaVersion < 6 &&
|
|
@@ -3135,9 +3340,9 @@ pp$3.checkUnreserved = function(ref) {
|
|
|
3135
3340
|
// when parsing properties), it will also convert keywords into
|
|
3136
3341
|
// identifiers.
|
|
3137
3342
|
|
|
3138
|
-
pp$
|
|
3343
|
+
pp$5.parseIdent = function(liberal, isBinding) {
|
|
3139
3344
|
var node = this.startNode();
|
|
3140
|
-
if (this.type === types.name) {
|
|
3345
|
+
if (this.type === types$1.name) {
|
|
3141
3346
|
node.name = this.value;
|
|
3142
3347
|
} else if (this.type.keyword) {
|
|
3143
3348
|
node.name = this.type.keyword;
|
|
@@ -3163,9 +3368,9 @@ pp$3.parseIdent = function(liberal, isBinding) {
|
|
|
3163
3368
|
return node
|
|
3164
3369
|
};
|
|
3165
3370
|
|
|
3166
|
-
pp$
|
|
3371
|
+
pp$5.parsePrivateIdent = function() {
|
|
3167
3372
|
var node = this.startNode();
|
|
3168
|
-
if (this.type === types.privateId) {
|
|
3373
|
+
if (this.type === types$1.privateId) {
|
|
3169
3374
|
node.name = this.value;
|
|
3170
3375
|
} else {
|
|
3171
3376
|
this.unexpected();
|
|
@@ -3185,27 +3390,27 @@ pp$3.parsePrivateIdent = function() {
|
|
|
3185
3390
|
|
|
3186
3391
|
// Parses yield expression inside generator.
|
|
3187
3392
|
|
|
3188
|
-
pp$
|
|
3393
|
+
pp$5.parseYield = function(forInit) {
|
|
3189
3394
|
if (!this.yieldPos) { this.yieldPos = this.start; }
|
|
3190
3395
|
|
|
3191
3396
|
var node = this.startNode();
|
|
3192
3397
|
this.next();
|
|
3193
|
-
if (this.type === types.semi || this.canInsertSemicolon() || (this.type !== types.star && !this.type.startsExpr)) {
|
|
3398
|
+
if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) {
|
|
3194
3399
|
node.delegate = false;
|
|
3195
3400
|
node.argument = null;
|
|
3196
3401
|
} else {
|
|
3197
|
-
node.delegate = this.eat(types.star);
|
|
3402
|
+
node.delegate = this.eat(types$1.star);
|
|
3198
3403
|
node.argument = this.parseMaybeAssign(forInit);
|
|
3199
3404
|
}
|
|
3200
3405
|
return this.finishNode(node, "YieldExpression")
|
|
3201
3406
|
};
|
|
3202
3407
|
|
|
3203
|
-
pp$
|
|
3408
|
+
pp$5.parseAwait = function(forInit) {
|
|
3204
3409
|
if (!this.awaitPos) { this.awaitPos = this.start; }
|
|
3205
3410
|
|
|
3206
3411
|
var node = this.startNode();
|
|
3207
3412
|
this.next();
|
|
3208
|
-
node.argument = this.parseMaybeUnary(null, true);
|
|
3413
|
+
node.argument = this.parseMaybeUnary(null, true, false, forInit);
|
|
3209
3414
|
return this.finishNode(node, "AwaitExpression")
|
|
3210
3415
|
};
|
|
3211
3416
|
|
|
@@ -3233,7 +3438,7 @@ pp$4.curPosition = function() {
|
|
|
3233
3438
|
}
|
|
3234
3439
|
};
|
|
3235
3440
|
|
|
3236
|
-
var pp$
|
|
3441
|
+
var pp$3 = Parser.prototype;
|
|
3237
3442
|
|
|
3238
3443
|
var Scope = function Scope(flags) {
|
|
3239
3444
|
this.flags = flags;
|
|
@@ -3249,22 +3454,22 @@ var Scope = function Scope(flags) {
|
|
|
3249
3454
|
|
|
3250
3455
|
// The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
|
|
3251
3456
|
|
|
3252
|
-
pp$
|
|
3457
|
+
pp$3.enterScope = function(flags) {
|
|
3253
3458
|
this.scopeStack.push(new Scope(flags));
|
|
3254
3459
|
};
|
|
3255
3460
|
|
|
3256
|
-
pp$
|
|
3461
|
+
pp$3.exitScope = function() {
|
|
3257
3462
|
this.scopeStack.pop();
|
|
3258
3463
|
};
|
|
3259
3464
|
|
|
3260
3465
|
// The spec says:
|
|
3261
3466
|
// > At the top level of a function, or script, function declarations are
|
|
3262
3467
|
// > treated like var declarations rather than like lexical declarations.
|
|
3263
|
-
pp$
|
|
3468
|
+
pp$3.treatFunctionsAsVarInScope = function(scope) {
|
|
3264
3469
|
return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
|
|
3265
3470
|
};
|
|
3266
3471
|
|
|
3267
|
-
pp$
|
|
3472
|
+
pp$3.declareName = function(name, bindingType, pos) {
|
|
3268
3473
|
var redeclared = false;
|
|
3269
3474
|
if (bindingType === BIND_LEXICAL) {
|
|
3270
3475
|
var scope = this.currentScope();
|
|
@@ -3299,7 +3504,7 @@ pp$5.declareName = function(name, bindingType, pos) {
|
|
|
3299
3504
|
if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
|
|
3300
3505
|
};
|
|
3301
3506
|
|
|
3302
|
-
pp$
|
|
3507
|
+
pp$3.checkLocalExport = function(id) {
|
|
3303
3508
|
// scope.functions must be empty as Module code is always strict.
|
|
3304
3509
|
if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
|
|
3305
3510
|
this.scopeStack[0].var.indexOf(id.name) === -1) {
|
|
@@ -3307,11 +3512,11 @@ pp$5.checkLocalExport = function(id) {
|
|
|
3307
3512
|
}
|
|
3308
3513
|
};
|
|
3309
3514
|
|
|
3310
|
-
pp$
|
|
3515
|
+
pp$3.currentScope = function() {
|
|
3311
3516
|
return this.scopeStack[this.scopeStack.length - 1]
|
|
3312
3517
|
};
|
|
3313
3518
|
|
|
3314
|
-
pp$
|
|
3519
|
+
pp$3.currentVarScope = function() {
|
|
3315
3520
|
for (var i = this.scopeStack.length - 1;; i--) {
|
|
3316
3521
|
var scope = this.scopeStack[i];
|
|
3317
3522
|
if (scope.flags & SCOPE_VAR) { return scope }
|
|
@@ -3319,7 +3524,7 @@ pp$5.currentVarScope = function() {
|
|
|
3319
3524
|
};
|
|
3320
3525
|
|
|
3321
3526
|
// Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
|
|
3322
|
-
pp$
|
|
3527
|
+
pp$3.currentThisScope = function() {
|
|
3323
3528
|
for (var i = this.scopeStack.length - 1;; i--) {
|
|
3324
3529
|
var scope = this.scopeStack[i];
|
|
3325
3530
|
if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
|
|
@@ -3340,13 +3545,13 @@ var Node = function Node(parser, pos, loc) {
|
|
|
3340
3545
|
|
|
3341
3546
|
// Start an AST node, attaching a start offset.
|
|
3342
3547
|
|
|
3343
|
-
var pp$
|
|
3548
|
+
var pp$2 = Parser.prototype;
|
|
3344
3549
|
|
|
3345
|
-
pp$
|
|
3550
|
+
pp$2.startNode = function() {
|
|
3346
3551
|
return new Node(this, this.start, this.startLoc)
|
|
3347
3552
|
};
|
|
3348
3553
|
|
|
3349
|
-
pp$
|
|
3554
|
+
pp$2.startNodeAt = function(pos, loc) {
|
|
3350
3555
|
return new Node(this, pos, loc)
|
|
3351
3556
|
};
|
|
3352
3557
|
|
|
@@ -3362,165 +3567,22 @@ function finishNodeAt(node, type, pos, loc) {
|
|
|
3362
3567
|
return node
|
|
3363
3568
|
}
|
|
3364
3569
|
|
|
3365
|
-
pp$
|
|
3570
|
+
pp$2.finishNode = function(node, type) {
|
|
3366
3571
|
return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
|
|
3367
3572
|
};
|
|
3368
3573
|
|
|
3369
3574
|
// Finish node at given position
|
|
3370
3575
|
|
|
3371
|
-
pp$
|
|
3576
|
+
pp$2.finishNodeAt = function(node, type, pos, loc) {
|
|
3372
3577
|
return finishNodeAt.call(this, node, type, pos, loc)
|
|
3373
3578
|
};
|
|
3374
3579
|
|
|
3375
|
-
pp$
|
|
3580
|
+
pp$2.copyNode = function(node) {
|
|
3376
3581
|
var newNode = new Node(this, node.start, this.startLoc);
|
|
3377
3582
|
for (var prop in node) { newNode[prop] = node[prop]; }
|
|
3378
3583
|
return newNode
|
|
3379
3584
|
};
|
|
3380
3585
|
|
|
3381
|
-
// The algorithm used to determine whether a regexp can appear at a
|
|
3382
|
-
|
|
3383
|
-
var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
|
|
3384
|
-
this.token = token;
|
|
3385
|
-
this.isExpr = !!isExpr;
|
|
3386
|
-
this.preserveSpace = !!preserveSpace;
|
|
3387
|
-
this.override = override;
|
|
3388
|
-
this.generator = !!generator;
|
|
3389
|
-
};
|
|
3390
|
-
|
|
3391
|
-
var types$1 = {
|
|
3392
|
-
b_stat: new TokContext("{", false),
|
|
3393
|
-
b_expr: new TokContext("{", true),
|
|
3394
|
-
b_tmpl: new TokContext("${", false),
|
|
3395
|
-
p_stat: new TokContext("(", false),
|
|
3396
|
-
p_expr: new TokContext("(", true),
|
|
3397
|
-
q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
|
|
3398
|
-
f_stat: new TokContext("function", false),
|
|
3399
|
-
f_expr: new TokContext("function", true),
|
|
3400
|
-
f_expr_gen: new TokContext("function", true, false, null, true),
|
|
3401
|
-
f_gen: new TokContext("function", false, false, null, true)
|
|
3402
|
-
};
|
|
3403
|
-
|
|
3404
|
-
var pp$7 = Parser.prototype;
|
|
3405
|
-
|
|
3406
|
-
pp$7.initialContext = function() {
|
|
3407
|
-
return [types$1.b_stat]
|
|
3408
|
-
};
|
|
3409
|
-
|
|
3410
|
-
pp$7.braceIsBlock = function(prevType) {
|
|
3411
|
-
var parent = this.curContext();
|
|
3412
|
-
if (parent === types$1.f_expr || parent === types$1.f_stat)
|
|
3413
|
-
{ return true }
|
|
3414
|
-
if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
|
|
3415
|
-
{ return !parent.isExpr }
|
|
3416
|
-
|
|
3417
|
-
// The check for `tt.name && exprAllowed` detects whether we are
|
|
3418
|
-
// after a `yield` or `of` construct. See the `updateContext` for
|
|
3419
|
-
// `tt.name`.
|
|
3420
|
-
if (prevType === types._return || prevType === types.name && this.exprAllowed)
|
|
3421
|
-
{ return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
|
|
3422
|
-
if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow)
|
|
3423
|
-
{ return true }
|
|
3424
|
-
if (prevType === types.braceL)
|
|
3425
|
-
{ return parent === types$1.b_stat }
|
|
3426
|
-
if (prevType === types._var || prevType === types._const || prevType === types.name)
|
|
3427
|
-
{ return false }
|
|
3428
|
-
return !this.exprAllowed
|
|
3429
|
-
};
|
|
3430
|
-
|
|
3431
|
-
pp$7.inGeneratorContext = function() {
|
|
3432
|
-
for (var i = this.context.length - 1; i >= 1; i--) {
|
|
3433
|
-
var context = this.context[i];
|
|
3434
|
-
if (context.token === "function")
|
|
3435
|
-
{ return context.generator }
|
|
3436
|
-
}
|
|
3437
|
-
return false
|
|
3438
|
-
};
|
|
3439
|
-
|
|
3440
|
-
pp$7.updateContext = function(prevType) {
|
|
3441
|
-
var update, type = this.type;
|
|
3442
|
-
if (type.keyword && prevType === types.dot)
|
|
3443
|
-
{ this.exprAllowed = false; }
|
|
3444
|
-
else if (update = type.updateContext)
|
|
3445
|
-
{ update.call(this, prevType); }
|
|
3446
|
-
else
|
|
3447
|
-
{ this.exprAllowed = type.beforeExpr; }
|
|
3448
|
-
};
|
|
3449
|
-
|
|
3450
|
-
// Token-specific context update code
|
|
3451
|
-
|
|
3452
|
-
types.parenR.updateContext = types.braceR.updateContext = function() {
|
|
3453
|
-
if (this.context.length === 1) {
|
|
3454
|
-
this.exprAllowed = true;
|
|
3455
|
-
return
|
|
3456
|
-
}
|
|
3457
|
-
var out = this.context.pop();
|
|
3458
|
-
if (out === types$1.b_stat && this.curContext().token === "function") {
|
|
3459
|
-
out = this.context.pop();
|
|
3460
|
-
}
|
|
3461
|
-
this.exprAllowed = !out.isExpr;
|
|
3462
|
-
};
|
|
3463
|
-
|
|
3464
|
-
types.braceL.updateContext = function(prevType) {
|
|
3465
|
-
this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
|
|
3466
|
-
this.exprAllowed = true;
|
|
3467
|
-
};
|
|
3468
|
-
|
|
3469
|
-
types.dollarBraceL.updateContext = function() {
|
|
3470
|
-
this.context.push(types$1.b_tmpl);
|
|
3471
|
-
this.exprAllowed = true;
|
|
3472
|
-
};
|
|
3473
|
-
|
|
3474
|
-
types.parenL.updateContext = function(prevType) {
|
|
3475
|
-
var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
|
|
3476
|
-
this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
|
|
3477
|
-
this.exprAllowed = true;
|
|
3478
|
-
};
|
|
3479
|
-
|
|
3480
|
-
types.incDec.updateContext = function() {
|
|
3481
|
-
// tokExprAllowed stays unchanged
|
|
3482
|
-
};
|
|
3483
|
-
|
|
3484
|
-
types._function.updateContext = types._class.updateContext = function(prevType) {
|
|
3485
|
-
if (prevType.beforeExpr && prevType !== types._else &&
|
|
3486
|
-
!(prevType === types.semi && this.curContext() !== types$1.p_stat) &&
|
|
3487
|
-
!(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
|
|
3488
|
-
!((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
|
|
3489
|
-
{ this.context.push(types$1.f_expr); }
|
|
3490
|
-
else
|
|
3491
|
-
{ this.context.push(types$1.f_stat); }
|
|
3492
|
-
this.exprAllowed = false;
|
|
3493
|
-
};
|
|
3494
|
-
|
|
3495
|
-
types.backQuote.updateContext = function() {
|
|
3496
|
-
if (this.curContext() === types$1.q_tmpl)
|
|
3497
|
-
{ this.context.pop(); }
|
|
3498
|
-
else
|
|
3499
|
-
{ this.context.push(types$1.q_tmpl); }
|
|
3500
|
-
this.exprAllowed = false;
|
|
3501
|
-
};
|
|
3502
|
-
|
|
3503
|
-
types.star.updateContext = function(prevType) {
|
|
3504
|
-
if (prevType === types._function) {
|
|
3505
|
-
var index = this.context.length - 1;
|
|
3506
|
-
if (this.context[index] === types$1.f_expr)
|
|
3507
|
-
{ this.context[index] = types$1.f_expr_gen; }
|
|
3508
|
-
else
|
|
3509
|
-
{ this.context[index] = types$1.f_gen; }
|
|
3510
|
-
}
|
|
3511
|
-
this.exprAllowed = true;
|
|
3512
|
-
};
|
|
3513
|
-
|
|
3514
|
-
types.name.updateContext = function(prevType) {
|
|
3515
|
-
var allowed = false;
|
|
3516
|
-
if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
|
|
3517
|
-
if (this.value === "of" && !this.exprAllowed ||
|
|
3518
|
-
this.value === "yield" && this.inGeneratorContext())
|
|
3519
|
-
{ allowed = true; }
|
|
3520
|
-
}
|
|
3521
|
-
this.exprAllowed = allowed;
|
|
3522
|
-
};
|
|
3523
|
-
|
|
3524
3586
|
// This file contains Unicode properties extracted from the ECMAScript
|
|
3525
3587
|
// specification. The lists are extracted like so:
|
|
3526
3588
|
// $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
|
|
@@ -3572,7 +3634,7 @@ buildUnicodeData(10);
|
|
|
3572
3634
|
buildUnicodeData(11);
|
|
3573
3635
|
buildUnicodeData(12);
|
|
3574
3636
|
|
|
3575
|
-
var pp$
|
|
3637
|
+
var pp$1 = Parser.prototype;
|
|
3576
3638
|
|
|
3577
3639
|
var RegExpValidationState = function RegExpValidationState(parser) {
|
|
3578
3640
|
this.parser = parser;
|
|
@@ -3668,7 +3730,7 @@ RegExpValidationState.prototype.eat = function eat (ch, forceU) {
|
|
|
3668
3730
|
return false
|
|
3669
3731
|
};
|
|
3670
3732
|
|
|
3671
|
-
function codePointToString(ch) {
|
|
3733
|
+
function codePointToString$1(ch) {
|
|
3672
3734
|
if (ch <= 0xFFFF) { return String.fromCharCode(ch) }
|
|
3673
3735
|
ch -= 0x10000;
|
|
3674
3736
|
return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)
|
|
@@ -3680,7 +3742,7 @@ function codePointToString(ch) {
|
|
|
3680
3742
|
* @param {RegExpValidationState} state The state to validate RegExp.
|
|
3681
3743
|
* @returns {void}
|
|
3682
3744
|
*/
|
|
3683
|
-
pp$
|
|
3745
|
+
pp$1.validateRegExpFlags = function(state) {
|
|
3684
3746
|
var validFlags = state.validFlags;
|
|
3685
3747
|
var flags = state.flags;
|
|
3686
3748
|
|
|
@@ -3701,7 +3763,7 @@ pp$8.validateRegExpFlags = function(state) {
|
|
|
3701
3763
|
* @param {RegExpValidationState} state The state to validate RegExp.
|
|
3702
3764
|
* @returns {void}
|
|
3703
3765
|
*/
|
|
3704
|
-
pp$
|
|
3766
|
+
pp$1.validateRegExpPattern = function(state) {
|
|
3705
3767
|
this.regexp_pattern(state);
|
|
3706
3768
|
|
|
3707
3769
|
// The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
|
|
@@ -3716,7 +3778,7 @@ pp$8.validateRegExpPattern = function(state) {
|
|
|
3716
3778
|
};
|
|
3717
3779
|
|
|
3718
3780
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
|
|
3719
|
-
pp$
|
|
3781
|
+
pp$1.regexp_pattern = function(state) {
|
|
3720
3782
|
state.pos = 0;
|
|
3721
3783
|
state.lastIntValue = 0;
|
|
3722
3784
|
state.lastStringValue = "";
|
|
@@ -3750,7 +3812,7 @@ pp$8.regexp_pattern = function(state) {
|
|
|
3750
3812
|
};
|
|
3751
3813
|
|
|
3752
3814
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
|
|
3753
|
-
pp$
|
|
3815
|
+
pp$1.regexp_disjunction = function(state) {
|
|
3754
3816
|
this.regexp_alternative(state);
|
|
3755
3817
|
while (state.eat(0x7C /* | */)) {
|
|
3756
3818
|
this.regexp_alternative(state);
|
|
@@ -3766,13 +3828,13 @@ pp$8.regexp_disjunction = function(state) {
|
|
|
3766
3828
|
};
|
|
3767
3829
|
|
|
3768
3830
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
|
|
3769
|
-
pp$
|
|
3831
|
+
pp$1.regexp_alternative = function(state) {
|
|
3770
3832
|
while (state.pos < state.source.length && this.regexp_eatTerm(state))
|
|
3771
3833
|
{ }
|
|
3772
3834
|
};
|
|
3773
3835
|
|
|
3774
3836
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
|
|
3775
|
-
pp$
|
|
3837
|
+
pp$1.regexp_eatTerm = function(state) {
|
|
3776
3838
|
if (this.regexp_eatAssertion(state)) {
|
|
3777
3839
|
// Handle `QuantifiableAssertion Quantifier` alternative.
|
|
3778
3840
|
// `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
|
|
@@ -3795,7 +3857,7 @@ pp$8.regexp_eatTerm = function(state) {
|
|
|
3795
3857
|
};
|
|
3796
3858
|
|
|
3797
3859
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
|
|
3798
|
-
pp$
|
|
3860
|
+
pp$1.regexp_eatAssertion = function(state) {
|
|
3799
3861
|
var start = state.pos;
|
|
3800
3862
|
state.lastAssertionIsQuantifiable = false;
|
|
3801
3863
|
|
|
@@ -3833,7 +3895,7 @@ pp$8.regexp_eatAssertion = function(state) {
|
|
|
3833
3895
|
};
|
|
3834
3896
|
|
|
3835
3897
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
|
|
3836
|
-
pp$
|
|
3898
|
+
pp$1.regexp_eatQuantifier = function(state, noError) {
|
|
3837
3899
|
if ( noError === void 0 ) noError = false;
|
|
3838
3900
|
|
|
3839
3901
|
if (this.regexp_eatQuantifierPrefix(state, noError)) {
|
|
@@ -3844,7 +3906,7 @@ pp$8.regexp_eatQuantifier = function(state, noError) {
|
|
|
3844
3906
|
};
|
|
3845
3907
|
|
|
3846
3908
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
|
|
3847
|
-
pp$
|
|
3909
|
+
pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
|
|
3848
3910
|
return (
|
|
3849
3911
|
state.eat(0x2A /* * */) ||
|
|
3850
3912
|
state.eat(0x2B /* + */) ||
|
|
@@ -3852,7 +3914,7 @@ pp$8.regexp_eatQuantifierPrefix = function(state, noError) {
|
|
|
3852
3914
|
this.regexp_eatBracedQuantifier(state, noError)
|
|
3853
3915
|
)
|
|
3854
3916
|
};
|
|
3855
|
-
pp$
|
|
3917
|
+
pp$1.regexp_eatBracedQuantifier = function(state, noError) {
|
|
3856
3918
|
var start = state.pos;
|
|
3857
3919
|
if (state.eat(0x7B /* { */)) {
|
|
3858
3920
|
var min = 0, max = -1;
|
|
@@ -3878,7 +3940,7 @@ pp$8.regexp_eatBracedQuantifier = function(state, noError) {
|
|
|
3878
3940
|
};
|
|
3879
3941
|
|
|
3880
3942
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
|
|
3881
|
-
pp$
|
|
3943
|
+
pp$1.regexp_eatAtom = function(state) {
|
|
3882
3944
|
return (
|
|
3883
3945
|
this.regexp_eatPatternCharacters(state) ||
|
|
3884
3946
|
state.eat(0x2E /* . */) ||
|
|
@@ -3888,7 +3950,7 @@ pp$8.regexp_eatAtom = function(state) {
|
|
|
3888
3950
|
this.regexp_eatCapturingGroup(state)
|
|
3889
3951
|
)
|
|
3890
3952
|
};
|
|
3891
|
-
pp$
|
|
3953
|
+
pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
|
|
3892
3954
|
var start = state.pos;
|
|
3893
3955
|
if (state.eat(0x5C /* \ */)) {
|
|
3894
3956
|
if (this.regexp_eatAtomEscape(state)) {
|
|
@@ -3898,7 +3960,7 @@ pp$8.regexp_eatReverseSolidusAtomEscape = function(state) {
|
|
|
3898
3960
|
}
|
|
3899
3961
|
return false
|
|
3900
3962
|
};
|
|
3901
|
-
pp$
|
|
3963
|
+
pp$1.regexp_eatUncapturingGroup = function(state) {
|
|
3902
3964
|
var start = state.pos;
|
|
3903
3965
|
if (state.eat(0x28 /* ( */)) {
|
|
3904
3966
|
if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
|
|
@@ -3912,7 +3974,7 @@ pp$8.regexp_eatUncapturingGroup = function(state) {
|
|
|
3912
3974
|
}
|
|
3913
3975
|
return false
|
|
3914
3976
|
};
|
|
3915
|
-
pp$
|
|
3977
|
+
pp$1.regexp_eatCapturingGroup = function(state) {
|
|
3916
3978
|
if (state.eat(0x28 /* ( */)) {
|
|
3917
3979
|
if (this.options.ecmaVersion >= 9) {
|
|
3918
3980
|
this.regexp_groupSpecifier(state);
|
|
@@ -3930,7 +3992,7 @@ pp$8.regexp_eatCapturingGroup = function(state) {
|
|
|
3930
3992
|
};
|
|
3931
3993
|
|
|
3932
3994
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
|
|
3933
|
-
pp$
|
|
3995
|
+
pp$1.regexp_eatExtendedAtom = function(state) {
|
|
3934
3996
|
return (
|
|
3935
3997
|
state.eat(0x2E /* . */) ||
|
|
3936
3998
|
this.regexp_eatReverseSolidusAtomEscape(state) ||
|
|
@@ -3943,7 +4005,7 @@ pp$8.regexp_eatExtendedAtom = function(state) {
|
|
|
3943
4005
|
};
|
|
3944
4006
|
|
|
3945
4007
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
|
|
3946
|
-
pp$
|
|
4008
|
+
pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
|
|
3947
4009
|
if (this.regexp_eatBracedQuantifier(state, true)) {
|
|
3948
4010
|
state.raise("Nothing to repeat");
|
|
3949
4011
|
}
|
|
@@ -3951,7 +4013,7 @@ pp$8.regexp_eatInvalidBracedQuantifier = function(state) {
|
|
|
3951
4013
|
};
|
|
3952
4014
|
|
|
3953
4015
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
|
|
3954
|
-
pp$
|
|
4016
|
+
pp$1.regexp_eatSyntaxCharacter = function(state) {
|
|
3955
4017
|
var ch = state.current();
|
|
3956
4018
|
if (isSyntaxCharacter(ch)) {
|
|
3957
4019
|
state.lastIntValue = ch;
|
|
@@ -3973,7 +4035,7 @@ function isSyntaxCharacter(ch) {
|
|
|
3973
4035
|
|
|
3974
4036
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
|
|
3975
4037
|
// But eat eager.
|
|
3976
|
-
pp$
|
|
4038
|
+
pp$1.regexp_eatPatternCharacters = function(state) {
|
|
3977
4039
|
var start = state.pos;
|
|
3978
4040
|
var ch = 0;
|
|
3979
4041
|
while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
|
|
@@ -3983,7 +4045,7 @@ pp$8.regexp_eatPatternCharacters = function(state) {
|
|
|
3983
4045
|
};
|
|
3984
4046
|
|
|
3985
4047
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
|
|
3986
|
-
pp$
|
|
4048
|
+
pp$1.regexp_eatExtendedPatternCharacter = function(state) {
|
|
3987
4049
|
var ch = state.current();
|
|
3988
4050
|
if (
|
|
3989
4051
|
ch !== -1 &&
|
|
@@ -4004,7 +4066,7 @@ pp$8.regexp_eatExtendedPatternCharacter = function(state) {
|
|
|
4004
4066
|
// GroupSpecifier ::
|
|
4005
4067
|
// [empty]
|
|
4006
4068
|
// `?` GroupName
|
|
4007
|
-
pp$
|
|
4069
|
+
pp$1.regexp_groupSpecifier = function(state) {
|
|
4008
4070
|
if (state.eat(0x3F /* ? */)) {
|
|
4009
4071
|
if (this.regexp_eatGroupName(state)) {
|
|
4010
4072
|
if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
|
|
@@ -4020,7 +4082,7 @@ pp$8.regexp_groupSpecifier = function(state) {
|
|
|
4020
4082
|
// GroupName ::
|
|
4021
4083
|
// `<` RegExpIdentifierName `>`
|
|
4022
4084
|
// Note: this updates `state.lastStringValue` property with the eaten name.
|
|
4023
|
-
pp$
|
|
4085
|
+
pp$1.regexp_eatGroupName = function(state) {
|
|
4024
4086
|
state.lastStringValue = "";
|
|
4025
4087
|
if (state.eat(0x3C /* < */)) {
|
|
4026
4088
|
if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
|
|
@@ -4035,12 +4097,12 @@ pp$8.regexp_eatGroupName = function(state) {
|
|
|
4035
4097
|
// RegExpIdentifierStart
|
|
4036
4098
|
// RegExpIdentifierName RegExpIdentifierPart
|
|
4037
4099
|
// Note: this updates `state.lastStringValue` property with the eaten name.
|
|
4038
|
-
pp$
|
|
4100
|
+
pp$1.regexp_eatRegExpIdentifierName = function(state) {
|
|
4039
4101
|
state.lastStringValue = "";
|
|
4040
4102
|
if (this.regexp_eatRegExpIdentifierStart(state)) {
|
|
4041
|
-
state.lastStringValue += codePointToString(state.lastIntValue);
|
|
4103
|
+
state.lastStringValue += codePointToString$1(state.lastIntValue);
|
|
4042
4104
|
while (this.regexp_eatRegExpIdentifierPart(state)) {
|
|
4043
|
-
state.lastStringValue += codePointToString(state.lastIntValue);
|
|
4105
|
+
state.lastStringValue += codePointToString$1(state.lastIntValue);
|
|
4044
4106
|
}
|
|
4045
4107
|
return true
|
|
4046
4108
|
}
|
|
@@ -4052,7 +4114,7 @@ pp$8.regexp_eatRegExpIdentifierName = function(state) {
|
|
|
4052
4114
|
// `$`
|
|
4053
4115
|
// `_`
|
|
4054
4116
|
// `\` RegExpUnicodeEscapeSequence[+U]
|
|
4055
|
-
pp$
|
|
4117
|
+
pp$1.regexp_eatRegExpIdentifierStart = function(state) {
|
|
4056
4118
|
var start = state.pos;
|
|
4057
4119
|
var forceU = this.options.ecmaVersion >= 11;
|
|
4058
4120
|
var ch = state.current(forceU);
|
|
@@ -4080,7 +4142,7 @@ function isRegExpIdentifierStart(ch) {
|
|
|
4080
4142
|
// `\` RegExpUnicodeEscapeSequence[+U]
|
|
4081
4143
|
// <ZWNJ>
|
|
4082
4144
|
// <ZWJ>
|
|
4083
|
-
pp$
|
|
4145
|
+
pp$1.regexp_eatRegExpIdentifierPart = function(state) {
|
|
4084
4146
|
var start = state.pos;
|
|
4085
4147
|
var forceU = this.options.ecmaVersion >= 11;
|
|
4086
4148
|
var ch = state.current(forceU);
|
|
@@ -4102,7 +4164,7 @@ function isRegExpIdentifierPart(ch) {
|
|
|
4102
4164
|
}
|
|
4103
4165
|
|
|
4104
4166
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
|
|
4105
|
-
pp$
|
|
4167
|
+
pp$1.regexp_eatAtomEscape = function(state) {
|
|
4106
4168
|
if (
|
|
4107
4169
|
this.regexp_eatBackReference(state) ||
|
|
4108
4170
|
this.regexp_eatCharacterClassEscape(state) ||
|
|
@@ -4120,7 +4182,7 @@ pp$8.regexp_eatAtomEscape = function(state) {
|
|
|
4120
4182
|
}
|
|
4121
4183
|
return false
|
|
4122
4184
|
};
|
|
4123
|
-
pp$
|
|
4185
|
+
pp$1.regexp_eatBackReference = function(state) {
|
|
4124
4186
|
var start = state.pos;
|
|
4125
4187
|
if (this.regexp_eatDecimalEscape(state)) {
|
|
4126
4188
|
var n = state.lastIntValue;
|
|
@@ -4138,7 +4200,7 @@ pp$8.regexp_eatBackReference = function(state) {
|
|
|
4138
4200
|
}
|
|
4139
4201
|
return false
|
|
4140
4202
|
};
|
|
4141
|
-
pp$
|
|
4203
|
+
pp$1.regexp_eatKGroupName = function(state) {
|
|
4142
4204
|
if (state.eat(0x6B /* k */)) {
|
|
4143
4205
|
if (this.regexp_eatGroupName(state)) {
|
|
4144
4206
|
state.backReferenceNames.push(state.lastStringValue);
|
|
@@ -4150,7 +4212,7 @@ pp$8.regexp_eatKGroupName = function(state) {
|
|
|
4150
4212
|
};
|
|
4151
4213
|
|
|
4152
4214
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
|
|
4153
|
-
pp$
|
|
4215
|
+
pp$1.regexp_eatCharacterEscape = function(state) {
|
|
4154
4216
|
return (
|
|
4155
4217
|
this.regexp_eatControlEscape(state) ||
|
|
4156
4218
|
this.regexp_eatCControlLetter(state) ||
|
|
@@ -4161,7 +4223,7 @@ pp$8.regexp_eatCharacterEscape = function(state) {
|
|
|
4161
4223
|
this.regexp_eatIdentityEscape(state)
|
|
4162
4224
|
)
|
|
4163
4225
|
};
|
|
4164
|
-
pp$
|
|
4226
|
+
pp$1.regexp_eatCControlLetter = function(state) {
|
|
4165
4227
|
var start = state.pos;
|
|
4166
4228
|
if (state.eat(0x63 /* c */)) {
|
|
4167
4229
|
if (this.regexp_eatControlLetter(state)) {
|
|
@@ -4171,7 +4233,7 @@ pp$8.regexp_eatCControlLetter = function(state) {
|
|
|
4171
4233
|
}
|
|
4172
4234
|
return false
|
|
4173
4235
|
};
|
|
4174
|
-
pp$
|
|
4236
|
+
pp$1.regexp_eatZero = function(state) {
|
|
4175
4237
|
if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
|
|
4176
4238
|
state.lastIntValue = 0;
|
|
4177
4239
|
state.advance();
|
|
@@ -4181,7 +4243,7 @@ pp$8.regexp_eatZero = function(state) {
|
|
|
4181
4243
|
};
|
|
4182
4244
|
|
|
4183
4245
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
|
|
4184
|
-
pp$
|
|
4246
|
+
pp$1.regexp_eatControlEscape = function(state) {
|
|
4185
4247
|
var ch = state.current();
|
|
4186
4248
|
if (ch === 0x74 /* t */) {
|
|
4187
4249
|
state.lastIntValue = 0x09; /* \t */
|
|
@@ -4212,7 +4274,7 @@ pp$8.regexp_eatControlEscape = function(state) {
|
|
|
4212
4274
|
};
|
|
4213
4275
|
|
|
4214
4276
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
|
|
4215
|
-
pp$
|
|
4277
|
+
pp$1.regexp_eatControlLetter = function(state) {
|
|
4216
4278
|
var ch = state.current();
|
|
4217
4279
|
if (isControlLetter(ch)) {
|
|
4218
4280
|
state.lastIntValue = ch % 0x20;
|
|
@@ -4229,7 +4291,7 @@ function isControlLetter(ch) {
|
|
|
4229
4291
|
}
|
|
4230
4292
|
|
|
4231
4293
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
|
|
4232
|
-
pp$
|
|
4294
|
+
pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
|
|
4233
4295
|
if ( forceU === void 0 ) forceU = false;
|
|
4234
4296
|
|
|
4235
4297
|
var start = state.pos;
|
|
@@ -4274,7 +4336,7 @@ function isValidUnicode(ch) {
|
|
|
4274
4336
|
}
|
|
4275
4337
|
|
|
4276
4338
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
|
|
4277
|
-
pp$
|
|
4339
|
+
pp$1.regexp_eatIdentityEscape = function(state) {
|
|
4278
4340
|
if (state.switchU) {
|
|
4279
4341
|
if (this.regexp_eatSyntaxCharacter(state)) {
|
|
4280
4342
|
return true
|
|
@@ -4297,7 +4359,7 @@ pp$8.regexp_eatIdentityEscape = function(state) {
|
|
|
4297
4359
|
};
|
|
4298
4360
|
|
|
4299
4361
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
|
|
4300
|
-
pp$
|
|
4362
|
+
pp$1.regexp_eatDecimalEscape = function(state) {
|
|
4301
4363
|
state.lastIntValue = 0;
|
|
4302
4364
|
var ch = state.current();
|
|
4303
4365
|
if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
|
|
@@ -4311,7 +4373,7 @@ pp$8.regexp_eatDecimalEscape = function(state) {
|
|
|
4311
4373
|
};
|
|
4312
4374
|
|
|
4313
4375
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
|
|
4314
|
-
pp$
|
|
4376
|
+
pp$1.regexp_eatCharacterClassEscape = function(state) {
|
|
4315
4377
|
var ch = state.current();
|
|
4316
4378
|
|
|
4317
4379
|
if (isCharacterClassEscape(ch)) {
|
|
@@ -4353,7 +4415,7 @@ function isCharacterClassEscape(ch) {
|
|
|
4353
4415
|
// UnicodePropertyValueExpression ::
|
|
4354
4416
|
// UnicodePropertyName `=` UnicodePropertyValue
|
|
4355
4417
|
// LoneUnicodePropertyNameOrValue
|
|
4356
|
-
pp$
|
|
4418
|
+
pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
|
|
4357
4419
|
var start = state.pos;
|
|
4358
4420
|
|
|
4359
4421
|
// UnicodePropertyName `=` UnicodePropertyValue
|
|
@@ -4375,24 +4437,24 @@ pp$8.regexp_eatUnicodePropertyValueExpression = function(state) {
|
|
|
4375
4437
|
}
|
|
4376
4438
|
return false
|
|
4377
4439
|
};
|
|
4378
|
-
pp$
|
|
4440
|
+
pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
|
|
4379
4441
|
if (!has(state.unicodeProperties.nonBinary, name))
|
|
4380
4442
|
{ state.raise("Invalid property name"); }
|
|
4381
4443
|
if (!state.unicodeProperties.nonBinary[name].test(value))
|
|
4382
4444
|
{ state.raise("Invalid property value"); }
|
|
4383
4445
|
};
|
|
4384
|
-
pp$
|
|
4446
|
+
pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
|
|
4385
4447
|
if (!state.unicodeProperties.binary.test(nameOrValue))
|
|
4386
4448
|
{ state.raise("Invalid property name"); }
|
|
4387
4449
|
};
|
|
4388
4450
|
|
|
4389
4451
|
// UnicodePropertyName ::
|
|
4390
4452
|
// UnicodePropertyNameCharacters
|
|
4391
|
-
pp$
|
|
4453
|
+
pp$1.regexp_eatUnicodePropertyName = function(state) {
|
|
4392
4454
|
var ch = 0;
|
|
4393
4455
|
state.lastStringValue = "";
|
|
4394
4456
|
while (isUnicodePropertyNameCharacter(ch = state.current())) {
|
|
4395
|
-
state.lastStringValue += codePointToString(ch);
|
|
4457
|
+
state.lastStringValue += codePointToString$1(ch);
|
|
4396
4458
|
state.advance();
|
|
4397
4459
|
}
|
|
4398
4460
|
return state.lastStringValue !== ""
|
|
@@ -4403,11 +4465,11 @@ function isUnicodePropertyNameCharacter(ch) {
|
|
|
4403
4465
|
|
|
4404
4466
|
// UnicodePropertyValue ::
|
|
4405
4467
|
// UnicodePropertyValueCharacters
|
|
4406
|
-
pp$
|
|
4468
|
+
pp$1.regexp_eatUnicodePropertyValue = function(state) {
|
|
4407
4469
|
var ch = 0;
|
|
4408
4470
|
state.lastStringValue = "";
|
|
4409
4471
|
while (isUnicodePropertyValueCharacter(ch = state.current())) {
|
|
4410
|
-
state.lastStringValue += codePointToString(ch);
|
|
4472
|
+
state.lastStringValue += codePointToString$1(ch);
|
|
4411
4473
|
state.advance();
|
|
4412
4474
|
}
|
|
4413
4475
|
return state.lastStringValue !== ""
|
|
@@ -4418,12 +4480,12 @@ function isUnicodePropertyValueCharacter(ch) {
|
|
|
4418
4480
|
|
|
4419
4481
|
// LoneUnicodePropertyNameOrValue ::
|
|
4420
4482
|
// UnicodePropertyValueCharacters
|
|
4421
|
-
pp$
|
|
4483
|
+
pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
|
|
4422
4484
|
return this.regexp_eatUnicodePropertyValue(state)
|
|
4423
4485
|
};
|
|
4424
4486
|
|
|
4425
4487
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
|
|
4426
|
-
pp$
|
|
4488
|
+
pp$1.regexp_eatCharacterClass = function(state) {
|
|
4427
4489
|
if (state.eat(0x5B /* [ */)) {
|
|
4428
4490
|
state.eat(0x5E /* ^ */);
|
|
4429
4491
|
this.regexp_classRanges(state);
|
|
@@ -4439,7 +4501,7 @@ pp$8.regexp_eatCharacterClass = function(state) {
|
|
|
4439
4501
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
|
|
4440
4502
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
|
|
4441
4503
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
|
|
4442
|
-
pp$
|
|
4504
|
+
pp$1.regexp_classRanges = function(state) {
|
|
4443
4505
|
while (this.regexp_eatClassAtom(state)) {
|
|
4444
4506
|
var left = state.lastIntValue;
|
|
4445
4507
|
if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
|
|
@@ -4456,7 +4518,7 @@ pp$8.regexp_classRanges = function(state) {
|
|
|
4456
4518
|
|
|
4457
4519
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
|
|
4458
4520
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
|
|
4459
|
-
pp$
|
|
4521
|
+
pp$1.regexp_eatClassAtom = function(state) {
|
|
4460
4522
|
var start = state.pos;
|
|
4461
4523
|
|
|
4462
4524
|
if (state.eat(0x5C /* \ */)) {
|
|
@@ -4485,7 +4547,7 @@ pp$8.regexp_eatClassAtom = function(state) {
|
|
|
4485
4547
|
};
|
|
4486
4548
|
|
|
4487
4549
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
|
|
4488
|
-
pp$
|
|
4550
|
+
pp$1.regexp_eatClassEscape = function(state) {
|
|
4489
4551
|
var start = state.pos;
|
|
4490
4552
|
|
|
4491
4553
|
if (state.eat(0x62 /* b */)) {
|
|
@@ -4512,7 +4574,7 @@ pp$8.regexp_eatClassEscape = function(state) {
|
|
|
4512
4574
|
};
|
|
4513
4575
|
|
|
4514
4576
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
|
|
4515
|
-
pp$
|
|
4577
|
+
pp$1.regexp_eatClassControlLetter = function(state) {
|
|
4516
4578
|
var ch = state.current();
|
|
4517
4579
|
if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
|
|
4518
4580
|
state.lastIntValue = ch % 0x20;
|
|
@@ -4523,7 +4585,7 @@ pp$8.regexp_eatClassControlLetter = function(state) {
|
|
|
4523
4585
|
};
|
|
4524
4586
|
|
|
4525
4587
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
|
|
4526
|
-
pp$
|
|
4588
|
+
pp$1.regexp_eatHexEscapeSequence = function(state) {
|
|
4527
4589
|
var start = state.pos;
|
|
4528
4590
|
if (state.eat(0x78 /* x */)) {
|
|
4529
4591
|
if (this.regexp_eatFixedHexDigits(state, 2)) {
|
|
@@ -4538,7 +4600,7 @@ pp$8.regexp_eatHexEscapeSequence = function(state) {
|
|
|
4538
4600
|
};
|
|
4539
4601
|
|
|
4540
4602
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
|
|
4541
|
-
pp$
|
|
4603
|
+
pp$1.regexp_eatDecimalDigits = function(state) {
|
|
4542
4604
|
var start = state.pos;
|
|
4543
4605
|
var ch = 0;
|
|
4544
4606
|
state.lastIntValue = 0;
|
|
@@ -4553,7 +4615,7 @@ function isDecimalDigit(ch) {
|
|
|
4553
4615
|
}
|
|
4554
4616
|
|
|
4555
4617
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
|
|
4556
|
-
pp$
|
|
4618
|
+
pp$1.regexp_eatHexDigits = function(state) {
|
|
4557
4619
|
var start = state.pos;
|
|
4558
4620
|
var ch = 0;
|
|
4559
4621
|
state.lastIntValue = 0;
|
|
@@ -4582,7 +4644,7 @@ function hexToInt(ch) {
|
|
|
4582
4644
|
|
|
4583
4645
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
|
|
4584
4646
|
// Allows only 0-377(octal) i.e. 0-255(decimal).
|
|
4585
|
-
pp$
|
|
4647
|
+
pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
|
|
4586
4648
|
if (this.regexp_eatOctalDigit(state)) {
|
|
4587
4649
|
var n1 = state.lastIntValue;
|
|
4588
4650
|
if (this.regexp_eatOctalDigit(state)) {
|
|
@@ -4601,7 +4663,7 @@ pp$8.regexp_eatLegacyOctalEscapeSequence = function(state) {
|
|
|
4601
4663
|
};
|
|
4602
4664
|
|
|
4603
4665
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
|
|
4604
|
-
pp$
|
|
4666
|
+
pp$1.regexp_eatOctalDigit = function(state) {
|
|
4605
4667
|
var ch = state.current();
|
|
4606
4668
|
if (isOctalDigit(ch)) {
|
|
4607
4669
|
state.lastIntValue = ch - 0x30; /* 0 */
|
|
@@ -4618,7 +4680,7 @@ function isOctalDigit(ch) {
|
|
|
4618
4680
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
|
|
4619
4681
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
|
|
4620
4682
|
// And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
|
|
4621
|
-
pp$
|
|
4683
|
+
pp$1.regexp_eatFixedHexDigits = function(state, length) {
|
|
4622
4684
|
var start = state.pos;
|
|
4623
4685
|
state.lastIntValue = 0;
|
|
4624
4686
|
for (var i = 0; i < length; ++i) {
|
|
@@ -4650,11 +4712,11 @@ var Token = function Token(p) {
|
|
|
4650
4712
|
|
|
4651
4713
|
// ## Tokenizer
|
|
4652
4714
|
|
|
4653
|
-
var pp
|
|
4715
|
+
var pp = Parser.prototype;
|
|
4654
4716
|
|
|
4655
4717
|
// Move to the next token
|
|
4656
4718
|
|
|
4657
|
-
pp
|
|
4719
|
+
pp.next = function(ignoreEscapeSequenceInKeyword) {
|
|
4658
4720
|
if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
|
|
4659
4721
|
{ this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
|
|
4660
4722
|
if (this.options.onToken)
|
|
@@ -4667,21 +4729,21 @@ pp$9.next = function(ignoreEscapeSequenceInKeyword) {
|
|
|
4667
4729
|
this.nextToken();
|
|
4668
4730
|
};
|
|
4669
4731
|
|
|
4670
|
-
pp
|
|
4732
|
+
pp.getToken = function() {
|
|
4671
4733
|
this.next();
|
|
4672
4734
|
return new Token(this)
|
|
4673
4735
|
};
|
|
4674
4736
|
|
|
4675
4737
|
// If we're in an ES6 environment, make parsers iterable
|
|
4676
4738
|
if (typeof Symbol !== "undefined")
|
|
4677
|
-
{ pp
|
|
4678
|
-
var this$1 = this;
|
|
4739
|
+
{ pp[Symbol.iterator] = function() {
|
|
4740
|
+
var this$1$1 = this;
|
|
4679
4741
|
|
|
4680
4742
|
return {
|
|
4681
4743
|
next: function () {
|
|
4682
|
-
var token = this$1.getToken();
|
|
4744
|
+
var token = this$1$1.getToken();
|
|
4683
4745
|
return {
|
|
4684
|
-
done: token.type === types.eof,
|
|
4746
|
+
done: token.type === types$1.eof,
|
|
4685
4747
|
value: token
|
|
4686
4748
|
}
|
|
4687
4749
|
}
|
|
@@ -4691,26 +4753,22 @@ if (typeof Symbol !== "undefined")
|
|
|
4691
4753
|
// Toggle strict mode. Re-reads the next number or string to please
|
|
4692
4754
|
// pedantic tests (`"use strict"; 010;` should fail).
|
|
4693
4755
|
|
|
4694
|
-
pp$9.curContext = function() {
|
|
4695
|
-
return this.context[this.context.length - 1]
|
|
4696
|
-
};
|
|
4697
|
-
|
|
4698
4756
|
// Read a single token, updating the parser object's token-related
|
|
4699
4757
|
// properties.
|
|
4700
4758
|
|
|
4701
|
-
pp
|
|
4759
|
+
pp.nextToken = function() {
|
|
4702
4760
|
var curContext = this.curContext();
|
|
4703
4761
|
if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
|
|
4704
4762
|
|
|
4705
4763
|
this.start = this.pos;
|
|
4706
4764
|
if (this.options.locations) { this.startLoc = this.curPosition(); }
|
|
4707
|
-
if (this.pos >= this.input.length) { return this.finishToken(types.eof) }
|
|
4765
|
+
if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) }
|
|
4708
4766
|
|
|
4709
4767
|
if (curContext.override) { return curContext.override(this) }
|
|
4710
4768
|
else { this.readToken(this.fullCharCodeAtPos()); }
|
|
4711
4769
|
};
|
|
4712
4770
|
|
|
4713
|
-
pp
|
|
4771
|
+
pp.readToken = function(code) {
|
|
4714
4772
|
// Identifier or keyword. '\uXXXX' sequences are allowed in
|
|
4715
4773
|
// identifiers, so '\' also dispatches to that.
|
|
4716
4774
|
if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
|
|
@@ -4719,14 +4777,14 @@ pp$9.readToken = function(code) {
|
|
|
4719
4777
|
return this.getTokenFromCode(code)
|
|
4720
4778
|
};
|
|
4721
4779
|
|
|
4722
|
-
pp
|
|
4780
|
+
pp.fullCharCodeAtPos = function() {
|
|
4723
4781
|
var code = this.input.charCodeAt(this.pos);
|
|
4724
4782
|
if (code <= 0xd7ff || code >= 0xdc00) { return code }
|
|
4725
4783
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4726
4784
|
return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
|
|
4727
4785
|
};
|
|
4728
4786
|
|
|
4729
|
-
pp
|
|
4787
|
+
pp.skipBlockComment = function() {
|
|
4730
4788
|
var startLoc = this.options.onComment && this.curPosition();
|
|
4731
4789
|
var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
|
|
4732
4790
|
if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
|
|
@@ -4744,7 +4802,7 @@ pp$9.skipBlockComment = function() {
|
|
|
4744
4802
|
startLoc, this.curPosition()); }
|
|
4745
4803
|
};
|
|
4746
4804
|
|
|
4747
|
-
pp
|
|
4805
|
+
pp.skipLineComment = function(startSkip) {
|
|
4748
4806
|
var start = this.pos;
|
|
4749
4807
|
var startLoc = this.options.onComment && this.curPosition();
|
|
4750
4808
|
var ch = this.input.charCodeAt(this.pos += startSkip);
|
|
@@ -4759,7 +4817,7 @@ pp$9.skipLineComment = function(startSkip) {
|
|
|
4759
4817
|
// Called at the start of the parse and after every token. Skips
|
|
4760
4818
|
// whitespace and comments, and.
|
|
4761
4819
|
|
|
4762
|
-
pp
|
|
4820
|
+
pp.skipSpace = function() {
|
|
4763
4821
|
loop: while (this.pos < this.input.length) {
|
|
4764
4822
|
var ch = this.input.charCodeAt(this.pos);
|
|
4765
4823
|
switch (ch) {
|
|
@@ -4804,7 +4862,7 @@ pp$9.skipSpace = function() {
|
|
|
4804
4862
|
// the token, so that the next one's `start` will point at the
|
|
4805
4863
|
// right position.
|
|
4806
4864
|
|
|
4807
|
-
pp
|
|
4865
|
+
pp.finishToken = function(type, val) {
|
|
4808
4866
|
this.end = this.pos;
|
|
4809
4867
|
if (this.options.locations) { this.endLoc = this.curPosition(); }
|
|
4810
4868
|
var prevType = this.type;
|
|
@@ -4823,62 +4881,62 @@ pp$9.finishToken = function(type, val) {
|
|
|
4823
4881
|
//
|
|
4824
4882
|
// All in the name of speed.
|
|
4825
4883
|
//
|
|
4826
|
-
pp
|
|
4884
|
+
pp.readToken_dot = function() {
|
|
4827
4885
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4828
4886
|
if (next >= 48 && next <= 57) { return this.readNumber(true) }
|
|
4829
4887
|
var next2 = this.input.charCodeAt(this.pos + 2);
|
|
4830
4888
|
if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
|
|
4831
4889
|
this.pos += 3;
|
|
4832
|
-
return this.finishToken(types.ellipsis)
|
|
4890
|
+
return this.finishToken(types$1.ellipsis)
|
|
4833
4891
|
} else {
|
|
4834
4892
|
++this.pos;
|
|
4835
|
-
return this.finishToken(types.dot)
|
|
4893
|
+
return this.finishToken(types$1.dot)
|
|
4836
4894
|
}
|
|
4837
4895
|
};
|
|
4838
4896
|
|
|
4839
|
-
pp
|
|
4897
|
+
pp.readToken_slash = function() { // '/'
|
|
4840
4898
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4841
4899
|
if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
|
|
4842
|
-
if (next === 61) { return this.finishOp(types.assign, 2) }
|
|
4843
|
-
return this.finishOp(types.slash, 1)
|
|
4900
|
+
if (next === 61) { return this.finishOp(types$1.assign, 2) }
|
|
4901
|
+
return this.finishOp(types$1.slash, 1)
|
|
4844
4902
|
};
|
|
4845
4903
|
|
|
4846
|
-
pp
|
|
4904
|
+
pp.readToken_mult_modulo_exp = function(code) { // '%*'
|
|
4847
4905
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4848
4906
|
var size = 1;
|
|
4849
|
-
var tokentype = code === 42 ? types.star : types.modulo;
|
|
4907
|
+
var tokentype = code === 42 ? types$1.star : types$1.modulo;
|
|
4850
4908
|
|
|
4851
4909
|
// exponentiation operator ** and **=
|
|
4852
4910
|
if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
|
|
4853
4911
|
++size;
|
|
4854
|
-
tokentype = types.starstar;
|
|
4912
|
+
tokentype = types$1.starstar;
|
|
4855
4913
|
next = this.input.charCodeAt(this.pos + 2);
|
|
4856
4914
|
}
|
|
4857
4915
|
|
|
4858
|
-
if (next === 61) { return this.finishOp(types.assign, size + 1) }
|
|
4916
|
+
if (next === 61) { return this.finishOp(types$1.assign, size + 1) }
|
|
4859
4917
|
return this.finishOp(tokentype, size)
|
|
4860
4918
|
};
|
|
4861
4919
|
|
|
4862
|
-
pp
|
|
4920
|
+
pp.readToken_pipe_amp = function(code) { // '|&'
|
|
4863
4921
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4864
4922
|
if (next === code) {
|
|
4865
4923
|
if (this.options.ecmaVersion >= 12) {
|
|
4866
4924
|
var next2 = this.input.charCodeAt(this.pos + 2);
|
|
4867
|
-
if (next2 === 61) { return this.finishOp(types.assign, 3) }
|
|
4925
|
+
if (next2 === 61) { return this.finishOp(types$1.assign, 3) }
|
|
4868
4926
|
}
|
|
4869
|
-
return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2)
|
|
4927
|
+
return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2)
|
|
4870
4928
|
}
|
|
4871
|
-
if (next === 61) { return this.finishOp(types.assign, 2) }
|
|
4872
|
-
return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1)
|
|
4929
|
+
if (next === 61) { return this.finishOp(types$1.assign, 2) }
|
|
4930
|
+
return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1)
|
|
4873
4931
|
};
|
|
4874
4932
|
|
|
4875
|
-
pp
|
|
4933
|
+
pp.readToken_caret = function() { // '^'
|
|
4876
4934
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4877
|
-
if (next === 61) { return this.finishOp(types.assign, 2) }
|
|
4878
|
-
return this.finishOp(types.bitwiseXOR, 1)
|
|
4935
|
+
if (next === 61) { return this.finishOp(types$1.assign, 2) }
|
|
4936
|
+
return this.finishOp(types$1.bitwiseXOR, 1)
|
|
4879
4937
|
};
|
|
4880
4938
|
|
|
4881
|
-
pp
|
|
4939
|
+
pp.readToken_plus_min = function(code) { // '+-'
|
|
4882
4940
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4883
4941
|
if (next === code) {
|
|
4884
4942
|
if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
|
|
@@ -4888,19 +4946,19 @@ pp$9.readToken_plus_min = function(code) { // '+-'
|
|
|
4888
4946
|
this.skipSpace();
|
|
4889
4947
|
return this.nextToken()
|
|
4890
4948
|
}
|
|
4891
|
-
return this.finishOp(types.incDec, 2)
|
|
4949
|
+
return this.finishOp(types$1.incDec, 2)
|
|
4892
4950
|
}
|
|
4893
|
-
if (next === 61) { return this.finishOp(types.assign, 2) }
|
|
4894
|
-
return this.finishOp(types.plusMin, 1)
|
|
4951
|
+
if (next === 61) { return this.finishOp(types$1.assign, 2) }
|
|
4952
|
+
return this.finishOp(types$1.plusMin, 1)
|
|
4895
4953
|
};
|
|
4896
4954
|
|
|
4897
|
-
pp
|
|
4955
|
+
pp.readToken_lt_gt = function(code) { // '<>'
|
|
4898
4956
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4899
4957
|
var size = 1;
|
|
4900
4958
|
if (next === code) {
|
|
4901
4959
|
size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
|
|
4902
|
-
if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
|
|
4903
|
-
return this.finishOp(types.bitShift, size)
|
|
4960
|
+
if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }
|
|
4961
|
+
return this.finishOp(types$1.bitShift, size)
|
|
4904
4962
|
}
|
|
4905
4963
|
if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
|
|
4906
4964
|
this.input.charCodeAt(this.pos + 3) === 45) {
|
|
@@ -4910,53 +4968,53 @@ pp$9.readToken_lt_gt = function(code) { // '<>'
|
|
|
4910
4968
|
return this.nextToken()
|
|
4911
4969
|
}
|
|
4912
4970
|
if (next === 61) { size = 2; }
|
|
4913
|
-
return this.finishOp(types.relational, size)
|
|
4971
|
+
return this.finishOp(types$1.relational, size)
|
|
4914
4972
|
};
|
|
4915
4973
|
|
|
4916
|
-
pp
|
|
4974
|
+
pp.readToken_eq_excl = function(code) { // '=!'
|
|
4917
4975
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4918
|
-
if (next === 61) { return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
|
|
4976
|
+
if (next === 61) { return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2) }
|
|
4919
4977
|
if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
|
|
4920
4978
|
this.pos += 2;
|
|
4921
|
-
return this.finishToken(types.arrow)
|
|
4979
|
+
return this.finishToken(types$1.arrow)
|
|
4922
4980
|
}
|
|
4923
|
-
return this.finishOp(code === 61 ? types.eq : types.prefix, 1)
|
|
4981
|
+
return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1)
|
|
4924
4982
|
};
|
|
4925
4983
|
|
|
4926
|
-
pp
|
|
4984
|
+
pp.readToken_question = function() { // '?'
|
|
4927
4985
|
var ecmaVersion = this.options.ecmaVersion;
|
|
4928
4986
|
if (ecmaVersion >= 11) {
|
|
4929
4987
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
4930
4988
|
if (next === 46) {
|
|
4931
4989
|
var next2 = this.input.charCodeAt(this.pos + 2);
|
|
4932
|
-
if (next2 < 48 || next2 > 57) { return this.finishOp(types.questionDot, 2) }
|
|
4990
|
+
if (next2 < 48 || next2 > 57) { return this.finishOp(types$1.questionDot, 2) }
|
|
4933
4991
|
}
|
|
4934
4992
|
if (next === 63) {
|
|
4935
4993
|
if (ecmaVersion >= 12) {
|
|
4936
4994
|
var next2$1 = this.input.charCodeAt(this.pos + 2);
|
|
4937
|
-
if (next2$1 === 61) { return this.finishOp(types.assign, 3) }
|
|
4995
|
+
if (next2$1 === 61) { return this.finishOp(types$1.assign, 3) }
|
|
4938
4996
|
}
|
|
4939
|
-
return this.finishOp(types.coalesce, 2)
|
|
4997
|
+
return this.finishOp(types$1.coalesce, 2)
|
|
4940
4998
|
}
|
|
4941
4999
|
}
|
|
4942
|
-
return this.finishOp(types.question, 1)
|
|
5000
|
+
return this.finishOp(types$1.question, 1)
|
|
4943
5001
|
};
|
|
4944
5002
|
|
|
4945
|
-
pp
|
|
5003
|
+
pp.readToken_numberSign = function() { // '#'
|
|
4946
5004
|
var ecmaVersion = this.options.ecmaVersion;
|
|
4947
5005
|
var code = 35; // '#'
|
|
4948
5006
|
if (ecmaVersion >= 13) {
|
|
4949
5007
|
++this.pos;
|
|
4950
5008
|
code = this.fullCharCodeAtPos();
|
|
4951
5009
|
if (isIdentifierStart(code, true) || code === 92 /* '\' */) {
|
|
4952
|
-
return this.finishToken(types.privateId, this.readWord1())
|
|
5010
|
+
return this.finishToken(types$1.privateId, this.readWord1())
|
|
4953
5011
|
}
|
|
4954
5012
|
}
|
|
4955
5013
|
|
|
4956
|
-
this.raise(this.pos, "Unexpected character '" + codePointToString
|
|
5014
|
+
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
|
|
4957
5015
|
};
|
|
4958
5016
|
|
|
4959
|
-
pp
|
|
5017
|
+
pp.getTokenFromCode = function(code) {
|
|
4960
5018
|
switch (code) {
|
|
4961
5019
|
// The interpretation of a dot depends on whether it is followed
|
|
4962
5020
|
// by a digit or another two dots.
|
|
@@ -4964,20 +5022,20 @@ pp$9.getTokenFromCode = function(code) {
|
|
|
4964
5022
|
return this.readToken_dot()
|
|
4965
5023
|
|
|
4966
5024
|
// Punctuation tokens.
|
|
4967
|
-
case 40: ++this.pos; return this.finishToken(types.parenL)
|
|
4968
|
-
case 41: ++this.pos; return this.finishToken(types.parenR)
|
|
4969
|
-
case 59: ++this.pos; return this.finishToken(types.semi)
|
|
4970
|
-
case 44: ++this.pos; return this.finishToken(types.comma)
|
|
4971
|
-
case 91: ++this.pos; return this.finishToken(types.bracketL)
|
|
4972
|
-
case 93: ++this.pos; return this.finishToken(types.bracketR)
|
|
4973
|
-
case 123: ++this.pos; return this.finishToken(types.braceL)
|
|
4974
|
-
case 125: ++this.pos; return this.finishToken(types.braceR)
|
|
4975
|
-
case 58: ++this.pos; return this.finishToken(types.colon)
|
|
5025
|
+
case 40: ++this.pos; return this.finishToken(types$1.parenL)
|
|
5026
|
+
case 41: ++this.pos; return this.finishToken(types$1.parenR)
|
|
5027
|
+
case 59: ++this.pos; return this.finishToken(types$1.semi)
|
|
5028
|
+
case 44: ++this.pos; return this.finishToken(types$1.comma)
|
|
5029
|
+
case 91: ++this.pos; return this.finishToken(types$1.bracketL)
|
|
5030
|
+
case 93: ++this.pos; return this.finishToken(types$1.bracketR)
|
|
5031
|
+
case 123: ++this.pos; return this.finishToken(types$1.braceL)
|
|
5032
|
+
case 125: ++this.pos; return this.finishToken(types$1.braceR)
|
|
5033
|
+
case 58: ++this.pos; return this.finishToken(types$1.colon)
|
|
4976
5034
|
|
|
4977
5035
|
case 96: // '`'
|
|
4978
5036
|
if (this.options.ecmaVersion < 6) { break }
|
|
4979
5037
|
++this.pos;
|
|
4980
|
-
return this.finishToken(types.backQuote)
|
|
5038
|
+
return this.finishToken(types$1.backQuote)
|
|
4981
5039
|
|
|
4982
5040
|
case 48: // '0'
|
|
4983
5041
|
var next = this.input.charCodeAt(this.pos + 1);
|
|
@@ -5000,7 +5058,6 @@ pp$9.getTokenFromCode = function(code) {
|
|
|
5000
5058
|
// often referred to. `finishOp` simply skips the amount of
|
|
5001
5059
|
// characters it is given as second argument, and returns a token
|
|
5002
5060
|
// of the type given by its first argument.
|
|
5003
|
-
|
|
5004
5061
|
case 47: // '/'
|
|
5005
5062
|
return this.readToken_slash()
|
|
5006
5063
|
|
|
@@ -5026,22 +5083,22 @@ pp$9.getTokenFromCode = function(code) {
|
|
|
5026
5083
|
return this.readToken_question()
|
|
5027
5084
|
|
|
5028
5085
|
case 126: // '~'
|
|
5029
|
-
return this.finishOp(types.prefix, 1)
|
|
5086
|
+
return this.finishOp(types$1.prefix, 1)
|
|
5030
5087
|
|
|
5031
5088
|
case 35: // '#'
|
|
5032
5089
|
return this.readToken_numberSign()
|
|
5033
5090
|
}
|
|
5034
5091
|
|
|
5035
|
-
this.raise(this.pos, "Unexpected character '" + codePointToString
|
|
5092
|
+
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
|
|
5036
5093
|
};
|
|
5037
5094
|
|
|
5038
|
-
pp
|
|
5095
|
+
pp.finishOp = function(type, size) {
|
|
5039
5096
|
var str = this.input.slice(this.pos, this.pos + size);
|
|
5040
5097
|
this.pos += size;
|
|
5041
5098
|
return this.finishToken(type, str)
|
|
5042
5099
|
};
|
|
5043
5100
|
|
|
5044
|
-
pp
|
|
5101
|
+
pp.readRegexp = function() {
|
|
5045
5102
|
var escaped, inClass, start = this.pos;
|
|
5046
5103
|
for (;;) {
|
|
5047
5104
|
if (this.pos >= this.input.length) { this.raise(start, "Unterminated regular expression"); }
|
|
@@ -5076,14 +5133,14 @@ pp$9.readRegexp = function() {
|
|
|
5076
5133
|
// https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
|
|
5077
5134
|
}
|
|
5078
5135
|
|
|
5079
|
-
return this.finishToken(types.regexp, {pattern: pattern, flags: flags, value: value})
|
|
5136
|
+
return this.finishToken(types$1.regexp, {pattern: pattern, flags: flags, value: value})
|
|
5080
5137
|
};
|
|
5081
5138
|
|
|
5082
5139
|
// Read an integer in the given radix. Return null if zero digits
|
|
5083
5140
|
// were read, the integer value otherwise. When `len` is given, this
|
|
5084
5141
|
// will return `null` unless the integer has exactly `len` digits.
|
|
5085
5142
|
|
|
5086
|
-
pp
|
|
5143
|
+
pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
|
|
5087
5144
|
// `len` is used for character escape sequences. In that case, disallow separators.
|
|
5088
5145
|
var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined;
|
|
5089
5146
|
|
|
@@ -5137,7 +5194,7 @@ function stringToBigInt(str) {
|
|
|
5137
5194
|
return BigInt(str.replace(/_/g, ""))
|
|
5138
5195
|
}
|
|
5139
5196
|
|
|
5140
|
-
pp
|
|
5197
|
+
pp.readRadixNumber = function(radix) {
|
|
5141
5198
|
var start = this.pos;
|
|
5142
5199
|
this.pos += 2; // 0x
|
|
5143
5200
|
var val = this.readInt(radix);
|
|
@@ -5146,12 +5203,12 @@ pp$9.readRadixNumber = function(radix) {
|
|
|
5146
5203
|
val = stringToBigInt(this.input.slice(start, this.pos));
|
|
5147
5204
|
++this.pos;
|
|
5148
5205
|
} else if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
|
|
5149
|
-
return this.finishToken(types.num, val)
|
|
5206
|
+
return this.finishToken(types$1.num, val)
|
|
5150
5207
|
};
|
|
5151
5208
|
|
|
5152
5209
|
// Read an integer, octal integer, or floating-point number.
|
|
5153
5210
|
|
|
5154
|
-
pp
|
|
5211
|
+
pp.readNumber = function(startsWithDot) {
|
|
5155
5212
|
var start = this.pos;
|
|
5156
5213
|
if (!startsWithDot && this.readInt(10, undefined, true) === null) { this.raise(start, "Invalid number"); }
|
|
5157
5214
|
var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
|
@@ -5161,7 +5218,7 @@ pp$9.readNumber = function(startsWithDot) {
|
|
|
5161
5218
|
var val$1 = stringToBigInt(this.input.slice(start, this.pos));
|
|
5162
5219
|
++this.pos;
|
|
5163
5220
|
if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
|
|
5164
|
-
return this.finishToken(types.num, val$1)
|
|
5221
|
+
return this.finishToken(types$1.num, val$1)
|
|
5165
5222
|
}
|
|
5166
5223
|
if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
|
|
5167
5224
|
if (next === 46 && !octal) { // '.'
|
|
@@ -5177,12 +5234,12 @@ pp$9.readNumber = function(startsWithDot) {
|
|
|
5177
5234
|
if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
|
|
5178
5235
|
|
|
5179
5236
|
var val = stringToNumber(this.input.slice(start, this.pos), octal);
|
|
5180
|
-
return this.finishToken(types.num, val)
|
|
5237
|
+
return this.finishToken(types$1.num, val)
|
|
5181
5238
|
};
|
|
5182
5239
|
|
|
5183
5240
|
// Read a string value, interpreting backslash-escapes.
|
|
5184
5241
|
|
|
5185
|
-
pp
|
|
5242
|
+
pp.readCodePoint = function() {
|
|
5186
5243
|
var ch = this.input.charCodeAt(this.pos), code;
|
|
5187
5244
|
|
|
5188
5245
|
if (ch === 123) { // '{'
|
|
@@ -5197,14 +5254,14 @@ pp$9.readCodePoint = function() {
|
|
|
5197
5254
|
return code
|
|
5198
5255
|
};
|
|
5199
5256
|
|
|
5200
|
-
function codePointToString
|
|
5257
|
+
function codePointToString(code) {
|
|
5201
5258
|
// UTF-16 Decoding
|
|
5202
5259
|
if (code <= 0xFFFF) { return String.fromCharCode(code) }
|
|
5203
5260
|
code -= 0x10000;
|
|
5204
5261
|
return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)
|
|
5205
5262
|
}
|
|
5206
5263
|
|
|
5207
|
-
pp
|
|
5264
|
+
pp.readString = function(quote) {
|
|
5208
5265
|
var out = "", chunkStart = ++this.pos;
|
|
5209
5266
|
for (;;) {
|
|
5210
5267
|
if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated string constant"); }
|
|
@@ -5214,20 +5271,27 @@ pp$9.readString = function(quote) {
|
|
|
5214
5271
|
out += this.input.slice(chunkStart, this.pos);
|
|
5215
5272
|
out += this.readEscapedChar(false);
|
|
5216
5273
|
chunkStart = this.pos;
|
|
5274
|
+
} else if (ch === 0x2028 || ch === 0x2029) {
|
|
5275
|
+
if (this.options.ecmaVersion < 10) { this.raise(this.start, "Unterminated string constant"); }
|
|
5276
|
+
++this.pos;
|
|
5277
|
+
if (this.options.locations) {
|
|
5278
|
+
this.curLine++;
|
|
5279
|
+
this.lineStart = this.pos;
|
|
5280
|
+
}
|
|
5217
5281
|
} else {
|
|
5218
|
-
if (isNewLine(ch
|
|
5282
|
+
if (isNewLine(ch)) { this.raise(this.start, "Unterminated string constant"); }
|
|
5219
5283
|
++this.pos;
|
|
5220
5284
|
}
|
|
5221
5285
|
}
|
|
5222
5286
|
out += this.input.slice(chunkStart, this.pos++);
|
|
5223
|
-
return this.finishToken(types.string, out)
|
|
5287
|
+
return this.finishToken(types$1.string, out)
|
|
5224
5288
|
};
|
|
5225
5289
|
|
|
5226
5290
|
// Reads template string tokens.
|
|
5227
5291
|
|
|
5228
5292
|
var INVALID_TEMPLATE_ESCAPE_ERROR = {};
|
|
5229
5293
|
|
|
5230
|
-
pp
|
|
5294
|
+
pp.tryReadTemplateToken = function() {
|
|
5231
5295
|
this.inTemplateElement = true;
|
|
5232
5296
|
try {
|
|
5233
5297
|
this.readTmplToken();
|
|
@@ -5242,7 +5306,7 @@ pp$9.tryReadTemplateToken = function() {
|
|
|
5242
5306
|
this.inTemplateElement = false;
|
|
5243
5307
|
};
|
|
5244
5308
|
|
|
5245
|
-
pp
|
|
5309
|
+
pp.invalidStringToken = function(position, message) {
|
|
5246
5310
|
if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
|
|
5247
5311
|
throw INVALID_TEMPLATE_ESCAPE_ERROR
|
|
5248
5312
|
} else {
|
|
@@ -5250,23 +5314,23 @@ pp$9.invalidStringToken = function(position, message) {
|
|
|
5250
5314
|
}
|
|
5251
5315
|
};
|
|
5252
5316
|
|
|
5253
|
-
pp
|
|
5317
|
+
pp.readTmplToken = function() {
|
|
5254
5318
|
var out = "", chunkStart = this.pos;
|
|
5255
5319
|
for (;;) {
|
|
5256
5320
|
if (this.pos >= this.input.length) { this.raise(this.start, "Unterminated template"); }
|
|
5257
5321
|
var ch = this.input.charCodeAt(this.pos);
|
|
5258
5322
|
if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
|
|
5259
|
-
if (this.pos === this.start && (this.type === types.template || this.type === types.invalidTemplate)) {
|
|
5323
|
+
if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
|
|
5260
5324
|
if (ch === 36) {
|
|
5261
5325
|
this.pos += 2;
|
|
5262
|
-
return this.finishToken(types.dollarBraceL)
|
|
5326
|
+
return this.finishToken(types$1.dollarBraceL)
|
|
5263
5327
|
} else {
|
|
5264
5328
|
++this.pos;
|
|
5265
|
-
return this.finishToken(types.backQuote)
|
|
5329
|
+
return this.finishToken(types$1.backQuote)
|
|
5266
5330
|
}
|
|
5267
5331
|
}
|
|
5268
5332
|
out += this.input.slice(chunkStart, this.pos);
|
|
5269
|
-
return this.finishToken(types.template, out)
|
|
5333
|
+
return this.finishToken(types$1.template, out)
|
|
5270
5334
|
}
|
|
5271
5335
|
if (ch === 92) { // '\'
|
|
5272
5336
|
out += this.input.slice(chunkStart, this.pos);
|
|
@@ -5297,7 +5361,7 @@ pp$9.readTmplToken = function() {
|
|
|
5297
5361
|
};
|
|
5298
5362
|
|
|
5299
5363
|
// Reads a template token to search for the end, without validating any escape sequences
|
|
5300
|
-
pp
|
|
5364
|
+
pp.readInvalidTemplateToken = function() {
|
|
5301
5365
|
for (; this.pos < this.input.length; this.pos++) {
|
|
5302
5366
|
switch (this.input[this.pos]) {
|
|
5303
5367
|
case "\\":
|
|
@@ -5308,10 +5372,10 @@ pp$9.readInvalidTemplateToken = function() {
|
|
|
5308
5372
|
if (this.input[this.pos + 1] !== "{") {
|
|
5309
5373
|
break
|
|
5310
5374
|
}
|
|
5311
|
-
// falls through
|
|
5312
5375
|
|
|
5376
|
+
// falls through
|
|
5313
5377
|
case "`":
|
|
5314
|
-
return this.finishToken(types.invalidTemplate, this.input.slice(this.start, this.pos))
|
|
5378
|
+
return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
|
|
5315
5379
|
|
|
5316
5380
|
// no default
|
|
5317
5381
|
}
|
|
@@ -5321,14 +5385,14 @@ pp$9.readInvalidTemplateToken = function() {
|
|
|
5321
5385
|
|
|
5322
5386
|
// Used to read escaped characters
|
|
5323
5387
|
|
|
5324
|
-
pp
|
|
5388
|
+
pp.readEscapedChar = function(inTemplate) {
|
|
5325
5389
|
var ch = this.input.charCodeAt(++this.pos);
|
|
5326
5390
|
++this.pos;
|
|
5327
5391
|
switch (ch) {
|
|
5328
5392
|
case 110: return "\n" // 'n' -> '\n'
|
|
5329
5393
|
case 114: return "\r" // 'r' -> '\r'
|
|
5330
5394
|
case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
|
|
5331
|
-
case 117: return codePointToString
|
|
5395
|
+
case 117: return codePointToString(this.readCodePoint()) // 'u'
|
|
5332
5396
|
case 116: return "\t" // 't' -> '\t'
|
|
5333
5397
|
case 98: return "\b" // 'b' -> '\b'
|
|
5334
5398
|
case 118: return "\u000b" // 'v' -> '\u000b'
|
|
@@ -5386,7 +5450,7 @@ pp$9.readEscapedChar = function(inTemplate) {
|
|
|
5386
5450
|
|
|
5387
5451
|
// Used to read character escape sequences ('\x', '\u', '\U').
|
|
5388
5452
|
|
|
5389
|
-
pp
|
|
5453
|
+
pp.readHexChar = function(len) {
|
|
5390
5454
|
var codePos = this.pos;
|
|
5391
5455
|
var n = this.readInt(16, len);
|
|
5392
5456
|
if (n === null) { this.invalidStringToken(codePos, "Bad character escape sequence"); }
|
|
@@ -5399,7 +5463,7 @@ pp$9.readHexChar = function(len) {
|
|
|
5399
5463
|
// Incrementally adds only escaped chars, adding other chunks as-is
|
|
5400
5464
|
// as a micro-optimization.
|
|
5401
5465
|
|
|
5402
|
-
pp
|
|
5466
|
+
pp.readWord1 = function() {
|
|
5403
5467
|
this.containsEsc = false;
|
|
5404
5468
|
var word = "", first = true, chunkStart = this.pos;
|
|
5405
5469
|
var astral = this.options.ecmaVersion >= 6;
|
|
@@ -5417,7 +5481,7 @@ pp$9.readWord1 = function() {
|
|
|
5417
5481
|
var esc = this.readCodePoint();
|
|
5418
5482
|
if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral))
|
|
5419
5483
|
{ this.invalidStringToken(escStart, "Invalid Unicode escape"); }
|
|
5420
|
-
word += codePointToString
|
|
5484
|
+
word += codePointToString(esc);
|
|
5421
5485
|
chunkStart = this.pos;
|
|
5422
5486
|
} else {
|
|
5423
5487
|
break
|
|
@@ -5430,18 +5494,18 @@ pp$9.readWord1 = function() {
|
|
|
5430
5494
|
// Read an identifier or keyword token. Will check for reserved
|
|
5431
5495
|
// words when necessary.
|
|
5432
5496
|
|
|
5433
|
-
pp
|
|
5497
|
+
pp.readWord = function() {
|
|
5434
5498
|
var word = this.readWord1();
|
|
5435
|
-
var type = types.name;
|
|
5499
|
+
var type = types$1.name;
|
|
5436
5500
|
if (this.keywords.test(word)) {
|
|
5437
|
-
type = keywords
|
|
5501
|
+
type = keywords[word];
|
|
5438
5502
|
}
|
|
5439
5503
|
return this.finishToken(type, word)
|
|
5440
5504
|
};
|
|
5441
5505
|
|
|
5442
5506
|
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
|
5443
5507
|
|
|
5444
|
-
var version = "8.
|
|
5508
|
+
var version = "8.6.0";
|
|
5445
5509
|
|
|
5446
5510
|
Parser.acorn = {
|
|
5447
5511
|
Parser: Parser,
|
|
@@ -5452,10 +5516,10 @@ Parser.acorn = {
|
|
|
5452
5516
|
getLineInfo: getLineInfo,
|
|
5453
5517
|
Node: Node,
|
|
5454
5518
|
TokenType: TokenType,
|
|
5455
|
-
tokTypes: types,
|
|
5456
|
-
keywordTypes: keywords
|
|
5519
|
+
tokTypes: types$1,
|
|
5520
|
+
keywordTypes: keywords,
|
|
5457
5521
|
TokContext: TokContext,
|
|
5458
|
-
tokContexts: types
|
|
5522
|
+
tokContexts: types,
|
|
5459
5523
|
isIdentifierChar: isIdentifierChar,
|
|
5460
5524
|
isIdentifierStart: isIdentifierStart,
|
|
5461
5525
|
Token: Token,
|
|
@@ -5491,4 +5555,4 @@ function tokenizer(input, options) {
|
|
|
5491
5555
|
return Parser.tokenizer(input, options)
|
|
5492
5556
|
}
|
|
5493
5557
|
|
|
5494
|
-
export { Node, Parser, Position, SourceLocation, TokContext, Token, TokenType, defaultOptions, getLineInfo, isIdentifierChar, isIdentifierStart, isNewLine, keywords
|
|
5558
|
+
export { Node, Parser, Position, SourceLocation, TokContext, Token, TokenType, defaultOptions, getLineInfo, isIdentifierChar, isIdentifierStart, isNewLine, keywords as keywordTypes, lineBreak, lineBreakG, nonASCIIwhitespace, parse, parseExpressionAt, types as tokContexts, types$1 as tokTypes, tokenizer, version };
|