meriyah 7.1.2 → 7.3.0

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/dist/meriyah.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var version$1 = "7.1.2";
1
+ var version$1 = "7.3.0";
2
2
  var packageJson = {
3
3
  version: version$1};
4
4
 
@@ -486,7 +486,7 @@ function convertTokenType(t) {
486
486
  return 'RegularExpression';
487
487
  case 67174408:
488
488
  case 67174409:
489
- case 131:
489
+ case 132:
490
490
  return 'TemplateLiteral';
491
491
  default:
492
492
  if ((t & 143360) === 143360)
@@ -621,7 +621,7 @@ const errorMessages = {
621
621
  [9]: 'Octal literals are not allowed in strict mode',
622
622
  [8]: 'Decimal integer literals with a leading zero are forbidden in strict mode',
623
623
  [10]: 'Expected number in radix %0',
624
- [151]: 'Invalid left-hand side assignment to a destructible right-hand side',
624
+ [153]: 'Invalid left-hand side assignment to a destructible right-hand side',
625
625
  [11]: 'Non-number found after exponent indicator',
626
626
  [12]: 'Invalid BigIntLiteral',
627
627
  [13]: 'No identifiers allowed directly after numeric literal',
@@ -645,7 +645,7 @@ const errorMessages = {
645
645
  [32]: 'Yield expression not allowed in formal parameter',
646
646
  [95]: "Unexpected token: 'escaped keyword'",
647
647
  [33]: 'Unary expressions as the left operand of an exponentiation expression must be disambiguated with parentheses',
648
- [123]: 'Async functions can only be declared at the top level or inside a block',
648
+ [125]: 'Async functions can only be declared at the top level or inside a block',
649
649
  [34]: 'Unterminated regular expression',
650
650
  [35]: 'Unexpected regular expression flag',
651
651
  [36]: "Duplicate regular expression flag '%0'",
@@ -657,7 +657,7 @@ const errorMessages = {
657
657
  [42]: 'A getter cannot be a generator',
658
658
  [43]: 'A setter cannot be a generator',
659
659
  [44]: 'A computed property name must be followed by a colon or paren',
660
- [134]: 'Object literal keys that are strings or numbers must be a method or have a colon',
660
+ [136]: 'Object literal keys that are strings or numbers must be a method or have a colon',
661
661
  [46]: 'Found `* async x(){}` but this should be `async * x(){}`',
662
662
  [45]: 'Getters and setters can not be generators',
663
663
  [47]: "'%0' can not be generator method",
@@ -719,73 +719,75 @@ const errorMessages = {
719
719
  [105]: '%0 source must be string',
720
720
  [106]: 'Only a identifier or string can be used to indicate alias',
721
721
  [107]: "Only '*' or '{...}' can be imported after default",
722
- [108]: 'Trailing decorator may be followed by method',
723
- [109]: "Decorators can't be used with a constructor",
724
- [110]: 'Can not use `await` as identifier in module or async func',
725
- [111]: 'Can not use `await` as identifier in module',
726
- [112]: 'HTML comments are only allowed with web compatibility (Annex B)',
727
- [113]: "The identifier 'let' must not be in expression position in strict mode",
728
- [114]: 'Cannot assign to `eval` and `arguments` in strict mode',
729
- [115]: "The left-hand side of a for-of loop may not start with 'let'",
730
- [116]: 'Block body arrows can not be immediately invoked without a group',
731
- [117]: 'Block body arrows can not be immediately accessed without a group',
732
- [118]: 'Unexpected strict mode reserved word',
733
- [119]: 'Unexpected eval or arguments in strict mode',
734
- [120]: 'Decorators must not be followed by a semicolon',
735
- [121]: 'Calling delete on expression not allowed in strict mode',
736
- [122]: 'Pattern can not have a tail',
737
- [124]: 'Can not have a `yield` expression on the left side of a ternary',
738
- [125]: 'An arrow function can not have a postfix update operator',
739
- [126]: 'Invalid object literal key character after generator star',
740
- [127]: 'Private fields can not be deleted',
741
- [129]: 'Classes may not have a field called constructor',
742
- [128]: 'Classes may not have a private element named constructor',
743
- [130]: 'A class field initializer or static block may not contain arguments',
744
- [131]: 'Generators can only be declared at the top level or inside a block',
745
- [132]: 'Async methods are a restricted production and cannot have a newline following it',
746
- [133]: 'Unexpected character after object literal property name',
747
- [135]: 'Invalid key token',
748
- [136]: "Label '%0' has already been declared",
749
- [137]: 'continue statement must be nested within an iteration statement',
750
- [138]: "Undefined label '%0'",
751
- [139]: 'Trailing comma is disallowed inside import(...) arguments',
752
- [140]: 'Invalid binding in JSON import',
753
- [141]: 'import() requires exactly one argument',
754
- [142]: 'Cannot use new with import(...)',
755
- [143]: '... is not allowed in import()',
756
- [144]: "Expected '=>'",
757
- [145]: "Duplicate binding '%0'",
758
- [146]: 'Duplicate private identifier #%0',
759
- [147]: "Cannot export a duplicate name '%0'",
760
- [150]: 'Duplicate %0 for-binding',
761
- [148]: "Exported binding '%0' needs to refer to a top-level declared variable",
762
- [149]: 'Unexpected private field',
763
- [153]: 'Numeric separators are not allowed at the end of numeric literals',
764
- [152]: 'Only one underscore is allowed as numeric separator',
765
- [154]: 'JSX value should be either an expression or a quoted JSX text',
766
- [155]: 'Expected corresponding JSX closing tag for %0',
767
- [156]: 'Adjacent JSX elements must be wrapped in an enclosing tag',
768
- [157]: "JSX attributes must only be assigned a non-empty 'expression'",
769
- [158]: "'%0' has already been declared",
770
- [159]: "'%0' shadowed a catch clause binding",
771
- [160]: 'Dot property must be an identifier',
772
- [161]: 'Encountered invalid input after spread/rest argument',
773
- [162]: 'Catch without try',
774
- [163]: 'Finally without try',
775
- [164]: 'Expected corresponding closing tag for JSX fragment',
776
- [165]: 'Coalescing and logical operators used together in the same expression must be disambiguated with parentheses',
777
- [166]: 'Invalid tagged template on optional chain',
778
- [167]: 'Invalid optional chain from super property',
779
- [168]: 'Invalid optional chain from new expression',
780
- [169]: 'Cannot use "import.meta" outside a module',
781
- [170]: 'Leading decorators must be attached to a class declaration',
782
- [171]: 'An export name cannot include a lone surrogate',
783
- [172]: 'A string literal cannot be used as an exported binding without `from`',
784
- [173]: "Private fields can't be accessed on super",
785
- [174]: "The only valid meta property for import is 'import.meta'",
786
- [175]: "'import.meta' must not contain escaped characters",
787
- [176]: 'cannot use "await" as identifier inside an async function',
788
- [177]: 'cannot use "await" in static blocks',
722
+ [108]: "'import defer' must be followed by a namespace import",
723
+ [109]: "'import source' must be followed by a default import",
724
+ [110]: 'Trailing decorator may be followed by method',
725
+ [111]: "Decorators can't be used with a constructor",
726
+ [112]: 'Can not use `await` as identifier in module or async func',
727
+ [113]: 'Can not use `await` as identifier in module',
728
+ [114]: 'HTML comments are only allowed with web compatibility (Annex B)',
729
+ [115]: "The identifier 'let' must not be in expression position in strict mode",
730
+ [116]: 'Cannot assign to `eval` and `arguments` in strict mode',
731
+ [117]: "The left-hand side of a for-of loop may not start with 'let'",
732
+ [118]: 'Block body arrows can not be immediately invoked without a group',
733
+ [119]: 'Block body arrows can not be immediately accessed without a group',
734
+ [120]: 'Unexpected strict mode reserved word',
735
+ [121]: 'Unexpected eval or arguments in strict mode',
736
+ [122]: 'Decorators must not be followed by a semicolon',
737
+ [123]: 'Calling delete on expression not allowed in strict mode',
738
+ [124]: 'Pattern can not have a tail',
739
+ [126]: 'Can not have a `yield` expression on the left side of a ternary',
740
+ [127]: 'An arrow function can not have a postfix update operator',
741
+ [128]: 'Invalid object literal key character after generator star',
742
+ [129]: 'Private fields can not be deleted',
743
+ [131]: 'Classes may not have a field called constructor',
744
+ [130]: 'Classes may not have a private element named constructor',
745
+ [132]: 'A class field initializer or static block may not contain arguments',
746
+ [133]: 'Generators can only be declared at the top level or inside a block',
747
+ [134]: 'Async methods are a restricted production and cannot have a newline following it',
748
+ [135]: 'Unexpected character after object literal property name',
749
+ [137]: 'Invalid key token',
750
+ [138]: "Label '%0' has already been declared",
751
+ [139]: 'continue statement must be nested within an iteration statement',
752
+ [140]: "Undefined label '%0'",
753
+ [141]: 'Trailing comma is disallowed inside import(...) arguments',
754
+ [142]: 'Invalid binding in JSON import',
755
+ [143]: 'import() requires exactly one argument',
756
+ [144]: 'Cannot use new with import(...)',
757
+ [145]: '... is not allowed in import()',
758
+ [146]: "Expected '=>'",
759
+ [147]: "Duplicate binding '%0'",
760
+ [148]: 'Duplicate private identifier #%0',
761
+ [149]: "Cannot export a duplicate name '%0'",
762
+ [152]: 'Duplicate %0 for-binding',
763
+ [150]: "Exported binding '%0' needs to refer to a top-level declared variable",
764
+ [151]: 'Unexpected private field',
765
+ [155]: 'Numeric separators are not allowed at the end of numeric literals',
766
+ [154]: 'Only one underscore is allowed as numeric separator',
767
+ [156]: 'JSX value should be either an expression or a quoted JSX text',
768
+ [157]: 'Expected corresponding JSX closing tag for %0',
769
+ [158]: 'Adjacent JSX elements must be wrapped in an enclosing tag',
770
+ [159]: "JSX attributes must only be assigned a non-empty 'expression'",
771
+ [160]: "'%0' has already been declared",
772
+ [161]: "'%0' shadowed a catch clause binding",
773
+ [162]: 'Dot property must be an identifier',
774
+ [163]: 'Encountered invalid input after spread/rest argument',
775
+ [164]: 'Catch without try',
776
+ [165]: 'Finally without try',
777
+ [166]: 'Expected corresponding closing tag for JSX fragment',
778
+ [167]: 'Coalescing and logical operators used together in the same expression must be disambiguated with parentheses',
779
+ [168]: 'Invalid tagged template on optional chain',
780
+ [169]: 'Invalid optional chain from super property',
781
+ [170]: 'Invalid optional chain from new expression',
782
+ [171]: 'Cannot use "import.meta" outside a module',
783
+ [172]: 'Leading decorators must be attached to a class declaration',
784
+ [173]: 'An export name cannot include a lone surrogate',
785
+ [174]: 'A string literal cannot be used as an exported binding without `from`',
786
+ [175]: "Private fields can't be accessed on super",
787
+ [176]: "The only valid meta property for import is 'import.meta'",
788
+ [177]: "'import.meta' must not contain escaped characters",
789
+ [178]: 'cannot use "await" as identifier inside an async function',
790
+ [179]: 'cannot use "await" in static blocks',
789
791
  };
790
792
  class ParseError extends SyntaxError {
791
793
  start;
@@ -794,7 +796,7 @@ class ParseError extends SyntaxError {
794
796
  loc;
795
797
  description;
796
798
  constructor(start, end, type, ...params) {
797
- const description = errorMessages[type].replace(/%(\d+)/g, (_, i) => params[i]);
799
+ const description = errorMessages[type].replaceAll(/%(\d+)/g, (_, i) => params[i]);
798
800
  const message = '[' + start.line + ':' + start.column + '-' + end.line + ':' + end.column + ']: ' + description;
799
801
  super(message);
800
802
  this.start = start.index;
@@ -809,10 +811,6 @@ class ParseError extends SyntaxError {
809
811
  }
810
812
  const isParseError = (error) => error instanceof ParseError;
811
813
 
812
- function getOwnProperty(object, key) {
813
- return Object.hasOwn(object, key) ? object[key] : undefined;
814
- }
815
-
816
814
  const KeywordDescTable = [
817
815
  'end of source',
818
816
  'identifier', 'number', 'string', 'regular expression',
@@ -829,79 +827,87 @@ const KeywordDescTable = [
829
827
  'extends', 'finally', 'for', 'function', 'if', 'import', 'new', 'return', 'super', 'switch',
830
828
  'this', 'throw', 'try', 'while', 'with',
831
829
  'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield',
832
- 'as', 'async', 'await', 'constructor', 'get', 'set', 'accessor', 'from', 'of',
830
+ 'as', 'async', 'await', 'constructor', 'get', 'set', 'accessor', 'from', 'of', 'using',
833
831
  'enum', 'eval', 'arguments', 'escaped keyword', 'escaped future reserved keyword', 'reserved if strict', '#',
834
832
  'BigIntLiteral', '??', '?.', 'WhiteSpace', 'Illegal', 'LineTerminator', 'PrivateField',
835
833
  'Template', '@', 'target', 'meta', 'LineFeed', 'Escaped', 'JSXText'
836
834
  ];
837
- const descKeywordTable = {
838
- this: 86111,
839
- function: 86104,
840
- if: 20569,
841
- return: 20572,
842
- var: 86088,
843
- else: 20563,
844
- for: 20567,
845
- new: 86107,
846
- in: 8673330,
847
- typeof: 16863275,
848
- while: 20578,
849
- case: 20556,
850
- break: 20555,
851
- try: 20577,
852
- catch: 20557,
853
- delete: 16863276,
854
- throw: 86112,
855
- switch: 86110,
856
- continue: 20559,
857
- default: 20561,
858
- instanceof: 8411187,
859
- do: 20562,
860
- void: 16863277,
861
- finally: 20566,
862
- async: 209005,
863
- await: 209006,
864
- class: 86094,
865
- const: 86090,
866
- constructor: 12399,
867
- debugger: 20560,
868
- export: 20564,
869
- extends: 20565,
870
- false: 86021,
871
- from: 209011,
872
- get: 209008,
873
- implements: 36964,
874
- import: 86106,
875
- interface: 36965,
876
- let: 241737,
877
- null: 86023,
878
- of: 471156,
879
- package: 36966,
880
- private: 36967,
881
- protected: 36968,
882
- public: 36969,
883
- set: 209009,
884
- static: 36970,
885
- super: 86109,
886
- true: 86022,
887
- with: 20579,
888
- yield: 241771,
889
- enum: 86133,
890
- eval: 537079926,
891
- as: 77932,
892
- arguments: 537079927,
893
- target: 209029,
894
- meta: 209030,
895
- accessor: 12402,
896
- };
835
+ const descKeywordTable = new Map([
836
+ ['this', 86111],
837
+ ['function', 86104],
838
+ ['if', 20569],
839
+ ['return', 20572],
840
+ ['var', 86088],
841
+ ['else', 20563],
842
+ ['for', 20567],
843
+ ['new', 86107],
844
+ ['in', 8673330],
845
+ ['typeof', 16863275],
846
+ ['while', 20578],
847
+ ['case', 20556],
848
+ ['break', 20555],
849
+ ['try', 20577],
850
+ ['catch', 20557],
851
+ ['delete', 16863276],
852
+ ['throw', 86112],
853
+ ['switch', 86110],
854
+ ['continue', 20559],
855
+ ['default', 20561],
856
+ ['instanceof', 8411187],
857
+ ['do', 20562],
858
+ ['void', 16863277],
859
+ ['finally', 20566],
860
+ ['async', 209005],
861
+ ['await', 209006],
862
+ ['class', 86094],
863
+ ['const', 86090],
864
+ ['constructor', 12399],
865
+ ['debugger', 20560],
866
+ ['export', 20564],
867
+ ['extends', 20565],
868
+ ['false', 86021],
869
+ ['from', 209011],
870
+ ['get', 209008],
871
+ ['implements', 36964],
872
+ ['import', 86106],
873
+ ['interface', 36965],
874
+ ['let', 241737],
875
+ ['null', 86023],
876
+ ['of', 471156],
877
+ ['using', 209013],
878
+ ['package', 36966],
879
+ ['private', 36967],
880
+ ['protected', 36968],
881
+ ['public', 36969],
882
+ ['set', 209009],
883
+ ['static', 36970],
884
+ ['super', 86109],
885
+ ['true', 86022],
886
+ ['with', 20579],
887
+ ['yield', 241771],
888
+ ['enum', 86134],
889
+ ['eval', 537079927],
890
+ ['as', 77932],
891
+ ['arguments', 537079928],
892
+ ['target', 209030],
893
+ ['meta', 209031],
894
+ ['accessor', 12402],
895
+ ]);
896
+ const keywordLengths = [...descKeywordTable.keys()].map((keyword) => keyword.length);
897
+ const minKeywordLength = Math.min(...keywordLengths);
898
+ const maxKeywordLength = Math.max(...keywordLengths);
897
899
 
898
900
  function scanIdentifier(parser, context, isValidAsKeyword) {
899
901
  while (isIdPart[advanceChar(parser)])
900
902
  ;
901
903
  parser.tokenValue = parser.source.slice(parser.tokenIndex, parser.index);
902
- return parser.currentChar !== 92 && parser.currentChar <= 0x7e
903
- ? (getOwnProperty(descKeywordTable, parser.tokenValue) ?? 208897)
904
- : scanIdentifierSlowCase(parser, context, 0, isValidAsKeyword);
904
+ if (parser.currentChar === 92 || parser.currentChar > 0x7e) {
905
+ return scanIdentifierSlowCase(parser, context, 0, isValidAsKeyword);
906
+ }
907
+ const length = parser.index - parser.tokenIndex;
908
+ if (length < minKeywordLength || length > maxKeywordLength)
909
+ return 208897;
910
+ return descKeywordTable.get(parser.tokenValue) ?? 208897;
905
911
  }
906
912
  function scanUnicodeIdentifier(parser, context) {
907
913
  const cookedChar = scanIdentifierUnicodeEscape(parser);
@@ -943,8 +949,8 @@ function scanIdentifierSlowCase(parser, context, hasEscape, isValidAsKeyword) {
943
949
  parser.tokenValue += parser.source.slice(start, parser.index);
944
950
  }
945
951
  const { length } = parser.tokenValue;
946
- if (isValidAsKeyword && length >= 2 && length <= 11) {
947
- const token = getOwnProperty(descKeywordTable, parser.tokenValue);
952
+ if (isValidAsKeyword && length >= minKeywordLength && length <= maxKeywordLength) {
953
+ const token = descKeywordTable.get(parser.tokenValue);
948
954
  if (token === void 0)
949
955
  return 208897 | (hasEscape ? -2147483648 : 0);
950
956
  if (!hasEscape)
@@ -953,24 +959,24 @@ function scanIdentifierSlowCase(parser, context, hasEscape, isValidAsKeyword) {
953
959
  if ((context & (2 | 2048)) === 0) {
954
960
  return token | -2147483648;
955
961
  }
956
- return -2147483528;
962
+ return -2147483527;
957
963
  }
958
964
  if (context & 1) {
959
965
  if (token === 36970) {
960
- return -2147483527;
966
+ return -2147483526;
961
967
  }
962
968
  if ((token & 36864) === 36864) {
963
- return -2147483527;
969
+ return -2147483526;
964
970
  }
965
971
  if ((token & 20480) === 20480) {
966
972
  if (context & 262144 && (context & 8) === 0) {
967
973
  return token | -2147483648;
968
974
  }
969
975
  else {
970
- return -2147483528;
976
+ return -2147483527;
971
977
  }
972
978
  }
973
- return 209018 | -2147483648;
979
+ return 209019 | -2147483648;
974
980
  }
975
981
  if (context & 262144 &&
976
982
  (context & 8) === 0 &&
@@ -979,31 +985,31 @@ function scanIdentifierSlowCase(parser, context, hasEscape, isValidAsKeyword) {
979
985
  }
980
986
  if (token === 241771) {
981
987
  return context & 262144
982
- ? 209018 | -2147483648
988
+ ? 209019 | -2147483648
983
989
  : context & 1024
984
- ? -2147483528
990
+ ? -2147483527
985
991
  : token | -2147483648;
986
992
  }
987
993
  if (token === 209005) {
988
- return 209018 | -2147483648;
994
+ return 209019 | -2147483648;
989
995
  }
990
996
  if ((token & 36864) === 36864) {
991
997
  return token | 12288 | -2147483648;
992
998
  }
993
- return -2147483528;
999
+ return -2147483527;
994
1000
  }
995
1001
  return 208897 | (hasEscape ? -2147483648 : 0);
996
1002
  }
997
1003
  function scanPrivateIdentifier(parser) {
998
1004
  let char = advanceChar(parser);
999
1005
  if (char === 92)
1000
- return 130;
1006
+ return 131;
1001
1007
  const merged = consumePossibleSurrogatePair(parser);
1002
1008
  if (merged)
1003
1009
  char = merged;
1004
1010
  if (!isIdentifierStart(char))
1005
1011
  parser.report(96);
1006
- return 130;
1012
+ return 131;
1007
1013
  }
1008
1014
  function scanIdentifierUnicodeEscape(parser) {
1009
1015
  if (parser.source.charCodeAt(parser.index + 1) !== 117) {
@@ -1068,7 +1074,7 @@ function scanNumber(parser, context, kind) {
1068
1074
  while (CharTypes[char] & (64 | 4096)) {
1069
1075
  if (char === 95) {
1070
1076
  if (!allowSeparator)
1071
- parser.report(152);
1077
+ parser.report(154);
1072
1078
  allowSeparator = 0;
1073
1079
  char = advanceChar(parser);
1074
1080
  continue;
@@ -1079,7 +1085,7 @@ function scanNumber(parser, context, kind) {
1079
1085
  char = advanceChar(parser);
1080
1086
  }
1081
1087
  if (digits === 0 || !allowSeparator) {
1082
- parser.report(digits === 0 ? 21 : 153);
1088
+ parser.report(digits === 0 ? 21 : 155);
1083
1089
  }
1084
1090
  }
1085
1091
  else if ((char | 32) === 111) {
@@ -1088,7 +1094,7 @@ function scanNumber(parser, context, kind) {
1088
1094
  while (CharTypes[char] & (32 | 4096)) {
1089
1095
  if (char === 95) {
1090
1096
  if (!allowSeparator) {
1091
- parser.report(152);
1097
+ parser.report(154);
1092
1098
  }
1093
1099
  allowSeparator = 0;
1094
1100
  char = advanceChar(parser);
@@ -1100,7 +1106,7 @@ function scanNumber(parser, context, kind) {
1100
1106
  char = advanceChar(parser);
1101
1107
  }
1102
1108
  if (digits === 0 || !allowSeparator) {
1103
- parser.report(digits === 0 ? 0 : 153);
1109
+ parser.report(digits === 0 ? 0 : 155);
1104
1110
  }
1105
1111
  }
1106
1112
  else if ((char | 32) === 98) {
@@ -1109,7 +1115,7 @@ function scanNumber(parser, context, kind) {
1109
1115
  while (CharTypes[char] & (128 | 4096)) {
1110
1116
  if (char === 95) {
1111
1117
  if (!allowSeparator) {
1112
- parser.report(152);
1118
+ parser.report(154);
1113
1119
  }
1114
1120
  allowSeparator = 0;
1115
1121
  char = advanceChar(parser);
@@ -1121,7 +1127,7 @@ function scanNumber(parser, context, kind) {
1121
1127
  char = advanceChar(parser);
1122
1128
  }
1123
1129
  if (digits === 0 || !allowSeparator) {
1124
- parser.report(digits === 0 ? 0 : 153);
1130
+ parser.report(digits === 0 ? 0 : 155);
1125
1131
  }
1126
1132
  }
1127
1133
  else if (CharTypes[char] & 32) {
@@ -1154,7 +1160,7 @@ function scanNumber(parser, context, kind) {
1154
1160
  if (char === 95) {
1155
1161
  char = advanceChar(parser);
1156
1162
  if (char === 95 || kind & 32) {
1157
- throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 152);
1163
+ throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 154);
1158
1164
  }
1159
1165
  allowSeparator = 1;
1160
1166
  continue;
@@ -1165,7 +1171,7 @@ function scanNumber(parser, context, kind) {
1165
1171
  --digit;
1166
1172
  }
1167
1173
  if (allowSeparator) {
1168
- throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 153);
1174
+ throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 155);
1169
1175
  }
1170
1176
  if (digit >= 0 && !isIdentifierStart(char) && char !== 46) {
1171
1177
  parser.tokenValue = value;
@@ -1209,7 +1215,7 @@ function scanNumber(parser, context, kind) {
1209
1215
  if (isBigInt) {
1210
1216
  parser.tokenRaw = parser.source.slice(parser.tokenIndex, parser.index);
1211
1217
  parser.tokenValue = BigInt(parser.tokenRaw.slice(0, -1).replaceAll('_', ''));
1212
- return 134283388;
1218
+ return 134283389;
1213
1219
  }
1214
1220
  parser.tokenValue =
1215
1221
  kind & (1 | 2 | 8 | 4)
@@ -1230,7 +1236,7 @@ function scanDecimalDigitsOrSeparator(parser, char) {
1230
1236
  const { index } = parser;
1231
1237
  char = advanceChar(parser);
1232
1238
  if (char === 95) {
1233
- throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 152);
1239
+ throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 154);
1234
1240
  }
1235
1241
  allowSeparator = 1;
1236
1242
  ret += parser.source.substring(start, index);
@@ -1241,7 +1247,7 @@ function scanDecimalDigitsOrSeparator(parser, char) {
1241
1247
  char = advanceChar(parser);
1242
1248
  }
1243
1249
  if (allowSeparator) {
1244
- throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 153);
1250
+ throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 155);
1245
1251
  }
1246
1252
  return ret + parser.source.substring(start, parser.index);
1247
1253
  }
@@ -1578,6 +1584,7 @@ function scanTemplate(parser, context) {
1578
1584
  const { index: start } = parser;
1579
1585
  let token = 67174409;
1580
1586
  let ret = '';
1587
+ let hasCarriageReturn = false;
1581
1588
  let char = advanceChar(parser);
1582
1589
  while (char !== 96) {
1583
1590
  if (char === 36 && parser.source.charCodeAt(parser.index + 1) === 123) {
@@ -1587,6 +1594,8 @@ function scanTemplate(parser, context) {
1587
1594
  }
1588
1595
  else if (char === 92) {
1589
1596
  char = advanceChar(parser);
1597
+ if (char === 13)
1598
+ hasCarriageReturn = true;
1590
1599
  if (char > 0x7e) {
1591
1600
  ret += String.fromCodePoint(char);
1592
1601
  }
@@ -1601,7 +1610,9 @@ function scanTemplate(parser, context) {
1601
1610
  parser.line = line;
1602
1611
  parser.column = column;
1603
1612
  ret = null;
1604
- char = scanBadTemplate(parser, char);
1613
+ char = scanBadTemplate(parser, char, () => {
1614
+ hasCarriageReturn = true;
1615
+ });
1605
1616
  if (char < 0)
1606
1617
  token = 67174408;
1607
1618
  break;
@@ -1612,10 +1623,13 @@ function scanTemplate(parser, context) {
1612
1623
  }
1613
1624
  }
1614
1625
  else if (parser.index < parser.end) {
1615
- if (char === 13 && parser.source.charCodeAt(parser.index) === 10) {
1616
- ret += String.fromCodePoint(char);
1626
+ if (char === 13)
1627
+ hasCarriageReturn = true;
1628
+ if (char === 13 && parser.source.charCodeAt(parser.index + 1) === 10) {
1617
1629
  parser.currentChar = parser.source.charCodeAt(++parser.index);
1618
1630
  }
1631
+ if (char === 13)
1632
+ char = 10;
1619
1633
  if (((char & 83) < 3 && char === 10) || (char ^ 8232) <= 1) {
1620
1634
  parser.column = -1;
1621
1635
  parser.line++;
@@ -1628,12 +1642,16 @@ function scanTemplate(parser, context) {
1628
1642
  }
1629
1643
  advanceChar(parser);
1630
1644
  parser.tokenValue = ret;
1631
- parser.tokenRaw = parser.source.slice(start + 1, parser.index - (token === 67174409 ? 1 : 2));
1645
+ const tokenRaw = parser.source.slice(start + 1, parser.index - (token === 67174409 ? 1 : 2));
1646
+ parser.tokenRaw = hasCarriageReturn ? tokenRaw.replaceAll(/\r\n?/g, '\n') : tokenRaw;
1632
1647
  return token;
1633
1648
  }
1634
- function scanBadTemplate(parser, ch) {
1649
+ function scanBadTemplate(parser, ch, onCarriageReturn) {
1635
1650
  while (ch !== 96) {
1636
1651
  switch (ch) {
1652
+ case 13:
1653
+ onCarriageReturn();
1654
+ break;
1637
1655
  case 36: {
1638
1656
  const index = parser.index + 1;
1639
1657
  if (index < parser.end && parser.source.charCodeAt(index) === 123) {
@@ -1664,42 +1682,42 @@ function scanTemplateTail(parser, context) {
1664
1682
  }
1665
1683
 
1666
1684
  const TokenLookup = [
1667
- 128,
1668
- 128,
1669
- 128,
1670
- 128,
1671
- 128,
1672
- 128,
1673
- 128,
1674
- 128,
1675
- 128,
1676
- 127,
1677
- 135,
1678
- 127,
1679
- 127,
1685
+ 129,
1686
+ 129,
1687
+ 129,
1688
+ 129,
1689
+ 129,
1690
+ 129,
1691
+ 129,
1692
+ 129,
1680
1693
  129,
1681
1694
  128,
1695
+ 136,
1682
1696
  128,
1683
1697
  128,
1698
+ 130,
1699
+ 129,
1700
+ 129,
1701
+ 129,
1702
+ 129,
1703
+ 129,
1704
+ 129,
1705
+ 129,
1706
+ 129,
1707
+ 129,
1708
+ 129,
1709
+ 129,
1710
+ 129,
1711
+ 129,
1712
+ 129,
1713
+ 129,
1714
+ 129,
1715
+ 129,
1716
+ 129,
1684
1717
  128,
1685
- 128,
1686
- 128,
1687
- 128,
1688
- 128,
1689
- 128,
1690
- 128,
1691
- 128,
1692
- 128,
1693
- 128,
1694
- 128,
1695
- 128,
1696
- 128,
1697
- 128,
1698
- 128,
1699
- 127,
1700
1718
  16842798,
1701
1719
  134283267,
1702
- 130,
1720
+ 131,
1703
1721
  208897,
1704
1722
  8391477,
1705
1723
  8390213,
@@ -1728,7 +1746,7 @@ const TokenLookup = [
1728
1746
  1077936155,
1729
1747
  8390721,
1730
1748
  22,
1731
- 132,
1749
+ 133,
1732
1750
  208897,
1733
1751
  208897,
1734
1752
  208897,
@@ -1756,11 +1774,11 @@ const TokenLookup = [
1756
1774
  208897,
1757
1775
  208897,
1758
1776
  69271571,
1759
- 136,
1777
+ 137,
1760
1778
  20,
1761
1779
  8389959,
1762
1780
  208897,
1763
- 131,
1781
+ 132,
1764
1782
  4096,
1765
1783
  4096,
1766
1784
  4096,
@@ -1791,7 +1809,7 @@ const TokenLookup = [
1791
1809
  8389702,
1792
1810
  1074790415,
1793
1811
  16842799,
1794
- 128,
1812
+ 129,
1795
1813
  ];
1796
1814
  function nextToken(parser, context) {
1797
1815
  parser.flags = (parser.flags | 1) ^ 1;
@@ -1821,8 +1839,8 @@ function scanSingleToken(parser, context, state) {
1821
1839
  case 1074790417:
1822
1840
  case 18:
1823
1841
  case 16842799:
1824
- case 132:
1825
- case 128:
1842
+ case 133:
1843
+ case 129:
1826
1844
  advanceChar(parser);
1827
1845
  return token;
1828
1846
  case 208897:
@@ -1833,20 +1851,20 @@ function scanSingleToken(parser, context, state) {
1833
1851
  return scanNumber(parser, context, 16 | 128);
1834
1852
  case 134283267:
1835
1853
  return scanString(parser, context, char);
1836
- case 131:
1854
+ case 132:
1837
1855
  return scanTemplate(parser, context);
1838
- case 136:
1856
+ case 137:
1839
1857
  return scanUnicodeIdentifier(parser, context);
1840
- case 130:
1858
+ case 131:
1841
1859
  return scanPrivateIdentifier(parser);
1842
- case 127:
1860
+ case 128:
1843
1861
  advanceChar(parser);
1844
1862
  break;
1845
- case 129:
1863
+ case 130:
1846
1864
  state |= 1 | 4;
1847
1865
  scanNewLine(parser);
1848
1866
  break;
1849
- case 135:
1867
+ case 136:
1850
1868
  consumeLineFeed(parser, state);
1851
1869
  state = (state & -5) | 1;
1852
1870
  break;
@@ -1950,7 +1968,7 @@ function scanSingleToken(parser, context, state) {
1950
1968
  advanceChar(parser);
1951
1969
  if ((state & 1 || isStartOfLine) && parser.currentChar === 62) {
1952
1970
  if (!parser.options.webcompat)
1953
- parser.report(112);
1971
+ parser.report(114);
1954
1972
  advanceChar(parser);
1955
1973
  state = skipSingleHTMLComment(parser, source, state, context, 3, parser.tokenStart);
1956
1974
  continue;
@@ -2069,7 +2087,7 @@ function scanSingleToken(parser, context, state) {
2069
2087
  advanceChar(parser);
2070
2088
  return 4718634;
2071
2089
  }
2072
- return 276824445;
2090
+ return 276824446;
2073
2091
  }
2074
2092
  if (ch === 46) {
2075
2093
  const index = parser.index + 1;
@@ -2077,7 +2095,7 @@ function scanSingleToken(parser, context, state) {
2077
2095
  ch = source.charCodeAt(index);
2078
2096
  if (!(ch >= 48 && ch <= 57)) {
2079
2097
  advanceChar(parser);
2080
- return 67108990;
2098
+ return 67108991;
2081
2099
  }
2082
2100
  }
2083
2101
  }
@@ -2179,20 +2197,20 @@ function reinterpretToPattern(parser, node) {
2179
2197
  function validateBindingIdentifier(parser, context, kind, t, skipEvalArgCheck) {
2180
2198
  if (context & 1) {
2181
2199
  if ((t & 36864) === 36864) {
2182
- parser.report(118);
2200
+ parser.report(120);
2183
2201
  }
2184
2202
  if (!skipEvalArgCheck && (t & 537079808) === 537079808) {
2185
- parser.report(119);
2203
+ parser.report(121);
2186
2204
  }
2187
2205
  }
2188
- if ((t & 20480) === 20480 || t === -2147483528) {
2206
+ if ((t & 20480) === 20480 || t === -2147483527) {
2189
2207
  parser.report(102);
2190
2208
  }
2191
2209
  if (kind & (8 | 16) && (t & 255) === (241737 & 255)) {
2192
2210
  parser.report(100);
2193
2211
  }
2194
2212
  if (context & (2048 | 2) && t === 209006) {
2195
- parser.report(110);
2213
+ parser.report(112);
2196
2214
  }
2197
2215
  if (context & (1024 | 1) && t === 241771) {
2198
2216
  parser.report(97, 'yield');
@@ -2201,15 +2219,15 @@ function validateBindingIdentifier(parser, context, kind, t, skipEvalArgCheck) {
2201
2219
  function validateFunctionName(parser, context, t) {
2202
2220
  if (context & 1) {
2203
2221
  if ((t & 36864) === 36864) {
2204
- parser.report(118);
2222
+ parser.report(120);
2205
2223
  }
2206
2224
  if ((t & 537079808) === 537079808) {
2207
- parser.report(119);
2225
+ parser.report(121);
2208
2226
  }
2209
- if (t === -2147483527) {
2227
+ if (t === -2147483526) {
2210
2228
  parser.report(95);
2211
2229
  }
2212
- if (t === -2147483528) {
2230
+ if (t === -2147483527) {
2213
2231
  parser.report(95);
2214
2232
  }
2215
2233
  }
@@ -2217,7 +2235,7 @@ function validateFunctionName(parser, context, t) {
2217
2235
  parser.report(102);
2218
2236
  }
2219
2237
  if (context & (2048 | 2) && t === 209006) {
2220
- parser.report(110);
2238
+ parser.report(112);
2221
2239
  }
2222
2240
  if (context & (1024 | 1) && t === 241771) {
2223
2241
  parser.report(97, 'yield');
@@ -2226,14 +2244,14 @@ function validateFunctionName(parser, context, t) {
2226
2244
  function isStrictReservedWord(parser, context, t) {
2227
2245
  if (t === 209006) {
2228
2246
  if (context & (2048 | 2))
2229
- parser.report(110);
2247
+ parser.report(112);
2230
2248
  parser.destructible |= 128;
2231
2249
  }
2232
2250
  if (t === 241771 && context & 1024)
2233
2251
  parser.report(97, 'yield');
2234
2252
  return ((t & 20480) === 20480 ||
2235
2253
  (t & 36864) === 36864 ||
2236
- t == -2147483527);
2254
+ t == -2147483526);
2237
2255
  }
2238
2256
  function isPropertyWithPrivateFieldKey(expr) {
2239
2257
  return !expr.property ? false : expr.property.type === 'PrivateIdentifier';
@@ -2242,7 +2260,7 @@ function isValidLabel(parser, labels, name, isIterationStatement) {
2242
2260
  while (labels) {
2243
2261
  if (labels['$' + name]) {
2244
2262
  if (isIterationStatement)
2245
- parser.report(137);
2263
+ parser.report(139);
2246
2264
  return 1;
2247
2265
  }
2248
2266
  if (isIterationStatement && labels.loop)
@@ -2255,7 +2273,7 @@ function validateAndDeclareLabel(parser, labels, name) {
2255
2273
  let set = labels;
2256
2274
  while (set) {
2257
2275
  if (set['$' + name])
2258
- parser.report(136, name);
2276
+ parser.report(138, name);
2259
2277
  set = set['$'];
2260
2278
  }
2261
2279
  labels['$' + name] = 1;
@@ -2283,14 +2301,14 @@ function isValidIdentifier(context, t) {
2283
2301
  function classifyIdentifier(parser, context, t) {
2284
2302
  if ((t & 537079808) === 537079808) {
2285
2303
  if (context & 1)
2286
- parser.report(119);
2304
+ parser.report(121);
2287
2305
  parser.flags |= 512;
2288
2306
  }
2289
2307
  if (!isValidIdentifier(context, t))
2290
2308
  parser.report(0);
2291
2309
  }
2292
2310
 
2293
- const entities = {
2311
+ const entities = new Map(Object.entries({
2294
2312
  AElig: '\u00C6',
2295
2313
  AMP: '\u0026',
2296
2314
  Aacute: '\u00C1',
@@ -4416,8 +4434,8 @@ const entities = {
4416
4434
  zscr: '\uD835\uDCCF',
4417
4435
  zwj: '\u200D',
4418
4436
  zwnj: '\u200C',
4419
- };
4420
- const decodeMap = {
4437
+ }));
4438
+ const decodeMap = new Map(Object.entries({
4421
4439
  '0': 65533,
4422
4440
  '128': 8364,
4423
4441
  '130': 8218,
@@ -4446,22 +4464,22 @@ const decodeMap = {
4446
4464
  '156': 339,
4447
4465
  '158': 382,
4448
4466
  '159': 376,
4449
- };
4467
+ }).map(([key, value]) => [Number(key), value]));
4450
4468
  function decodeHTMLStrict(text) {
4451
- return text.replace(/&(?:[a-zA-Z]+|#[xX][\da-fA-F]+|#\d+);/g, (key) => {
4469
+ return text.replaceAll(/&(?:[a-zA-Z]+|#[xX][\da-fA-F]+|#\d+);/g, (key) => {
4452
4470
  if (key.charAt(1) === '#') {
4453
4471
  const secondChar = key.charAt(2);
4454
4472
  const codePoint = secondChar === 'X' || secondChar === 'x' ? parseInt(key.slice(3), 16) : parseInt(key.slice(2), 10);
4455
4473
  return decodeCodePoint(codePoint);
4456
4474
  }
4457
- return getOwnProperty(entities, key.slice(1, -1)) ?? key;
4475
+ return entities.get(key.slice(1, -1)) ?? key;
4458
4476
  });
4459
4477
  }
4460
4478
  function decodeCodePoint(codePoint) {
4461
4479
  if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
4462
4480
  return '\uFFFD';
4463
4481
  }
4464
- return String.fromCodePoint(getOwnProperty(decodeMap, codePoint) ?? codePoint);
4482
+ return String.fromCodePoint(decodeMap.get(codePoint) ?? codePoint);
4465
4483
  }
4466
4484
 
4467
4485
  function scanJSXAttributeValue(parser, context) {
@@ -4531,7 +4549,7 @@ function nextJSXToken(parser) {
4531
4549
  if (parser.options.raw)
4532
4550
  parser.tokenRaw = raw;
4533
4551
  parser.tokenValue = decodeHTMLStrict(raw);
4534
- parser.setToken(137);
4552
+ parser.setToken(138);
4535
4553
  }
4536
4554
  function rescanJSXIdentifier(parser) {
4537
4555
  if ((parser.getToken() & 143360) === 143360) {
@@ -4546,6 +4564,8 @@ function rescanJSXIdentifier(parser) {
4546
4564
  return parser.getToken();
4547
4565
  }
4548
4566
 
4567
+ const nextFeatures = 1 | 2 | 4;
4568
+
4549
4569
  function normalizeRanges(ranges) {
4550
4570
  if (!ranges)
4551
4571
  return undefined;
@@ -4558,17 +4578,27 @@ function normalizeRanges(ranges) {
4558
4578
  };
4559
4579
  }
4560
4580
  function normalizeOptions(rawOptions) {
4561
- const options = {
4581
+ let { features, next, ranges, module, sourceType, globalReturn, ...restOptions } = {
4562
4582
  validateRegex: true,
4583
+ features: 0,
4563
4584
  ...rawOptions,
4564
- ranges: normalizeRanges(rawOptions.ranges),
4565
4585
  };
4566
- if (options.module && !options.sourceType) {
4567
- options.sourceType = 'module';
4586
+ if (next) {
4587
+ features |= nextFeatures;
4568
4588
  }
4569
- if (options.globalReturn && (!options.sourceType || options.sourceType === 'script')) {
4570
- options.sourceType = 'commonjs';
4589
+ ranges = normalizeRanges(ranges);
4590
+ if (module && !sourceType) {
4591
+ sourceType = 'module';
4571
4592
  }
4593
+ if (globalReturn && (!sourceType || sourceType === 'script')) {
4594
+ sourceType = 'commonjs';
4595
+ }
4596
+ const options = {
4597
+ ...restOptions,
4598
+ ranges,
4599
+ features,
4600
+ sourceType,
4601
+ };
4572
4602
  return options;
4573
4603
  }
4574
4604
 
@@ -4589,7 +4619,7 @@ class PrivateScope {
4589
4619
  const value = privateIdentifiers.get(name);
4590
4620
  if (this.hasPrivateIdentifier(name) &&
4591
4621
  ((value & 32) !== (focusKind & 32) || value & focusKind & 768)) {
4592
- this.parser.report(146, name);
4622
+ this.parser.report(148, name);
4593
4623
  }
4594
4624
  privateIdentifiers.set(name, this.hasPrivateIdentifier(name) ? value | focusKind : focusKind);
4595
4625
  }
@@ -4650,17 +4680,17 @@ class Scope {
4650
4680
  ((kind & 128 && value & 68) ||
4651
4681
  (value & 128 && kind & 68))) ;
4652
4682
  else {
4653
- parser.report(145, name);
4683
+ parser.report(147, name);
4654
4684
  }
4655
4685
  }
4656
4686
  if (currentScope === this) {
4657
4687
  if (value && value & 1 && kind & 1) {
4658
- currentScope.recordScopeError(145, name);
4688
+ currentScope.recordScopeError(147, name);
4659
4689
  }
4660
4690
  }
4661
4691
  if (value &&
4662
4692
  (value & 256 || (value & 512 && !parser.options.webcompat))) {
4663
- parser.report(145, name);
4693
+ parser.report(147, name);
4664
4694
  }
4665
4695
  currentScope.variableBindings.set(name, kind);
4666
4696
  currentScope = currentScope.parent;
@@ -4674,7 +4704,7 @@ class Scope {
4674
4704
  const value = this.variableBindings.get(name);
4675
4705
  if (value && (value & 2) === 0) {
4676
4706
  if (kind & 1) {
4677
- this.recordScopeError(145, name);
4707
+ this.recordScopeError(147, name);
4678
4708
  }
4679
4709
  else if (parser.options.webcompat &&
4680
4710
  (context & 1) === 0 &&
@@ -4682,22 +4712,22 @@ class Scope {
4682
4712
  value === 64 &&
4683
4713
  kind === 64) ;
4684
4714
  else {
4685
- parser.report(145, name);
4715
+ parser.report(147, name);
4686
4716
  }
4687
4717
  }
4688
4718
  if (this.type & 64 &&
4689
4719
  this.parent?.hasVariable(name) &&
4690
4720
  (this.parent.variableBindings.get(name) & 2) === 0) {
4691
- parser.report(145, name);
4721
+ parser.report(147, name);
4692
4722
  }
4693
4723
  if (this.type & 512 && value && (value & 2) === 0) {
4694
4724
  if (kind & 1) {
4695
- this.recordScopeError(145, name);
4725
+ this.recordScopeError(147, name);
4696
4726
  }
4697
4727
  }
4698
4728
  if (this.type & 32) {
4699
4729
  if (this.parent.variableBindings.get(name) & 768)
4700
- parser.report(159, name);
4730
+ parser.report(161, name);
4701
4731
  }
4702
4732
  this.variableBindings.set(name, kind);
4703
4733
  }
@@ -4729,6 +4759,7 @@ class Parser {
4729
4759
  options;
4730
4760
  token = 1048576;
4731
4761
  flags = 0;
4762
+ features = 0;
4732
4763
  index = 0;
4733
4764
  line = 1;
4734
4765
  column = 0;
@@ -4754,6 +4785,7 @@ class Parser {
4754
4785
  this.end = source.length;
4755
4786
  this.currentChar = source.charCodeAt(0);
4756
4787
  this.options = normalizeOptions(rawOptions);
4788
+ this.features = this.options.features;
4757
4789
  if (Array.isArray(this.options.onComment)) {
4758
4790
  this.options.onComment = pushComment(this.options.onComment, this.options);
4759
4791
  }
@@ -4834,7 +4866,7 @@ class Parser {
4834
4866
  declareUnboundVariable(name) {
4835
4867
  const { exportedNames } = this;
4836
4868
  if (exportedNames.has(name)) {
4837
- this.report(147, name);
4869
+ this.report(149, name);
4838
4870
  }
4839
4871
  exportedNames.add(name);
4840
4872
  }
@@ -4857,29 +4889,10 @@ class Parser {
4857
4889
  return undefined;
4858
4890
  }
4859
4891
  cloneIdentifier(original) {
4860
- return this.cloneLocationInformation({ ...original }, original);
4892
+ return structuredClone(original);
4861
4893
  }
4862
4894
  cloneStringLiteral(original) {
4863
- return this.cloneLocationInformation({ ...original }, original);
4864
- }
4865
- cloneLocationInformation(node, original) {
4866
- const { ranges } = this.options;
4867
- if (ranges) {
4868
- if (ranges.start)
4869
- node.start = original.start;
4870
- if (ranges.end)
4871
- node.end = original.end;
4872
- if (ranges.range)
4873
- node.range = [...original.range];
4874
- }
4875
- if (this.options.loc) {
4876
- node.loc = {
4877
- ...original.loc,
4878
- start: { ...original.loc.start },
4879
- end: { ...original.loc.end },
4880
- };
4881
- }
4882
- return node;
4895
+ return structuredClone(original);
4883
4896
  }
4884
4897
  }
4885
4898
  function pushComment(comments, options) {
@@ -4942,7 +4955,7 @@ function parseSource(source, rawOptions = {}, context = 0) {
4942
4955
  if (scope) {
4943
4956
  for (const name of parser.exportedBindings) {
4944
4957
  if (!scope.hasVariable(name))
4945
- parser.report(148, name);
4958
+ parser.report(150, name);
4946
4959
  }
4947
4960
  }
4948
4961
  }
@@ -4992,7 +5005,7 @@ function parseModuleItemList(parser, context, scope) {
4992
5005
  return statements;
4993
5006
  }
4994
5007
  function parseModuleItem(parser, context, scope) {
4995
- if (parser.getToken() === 132) {
5008
+ if (parser.getToken() === 133) {
4996
5009
  Object.assign(parser.leadingDecorators, {
4997
5010
  start: parser.tokenStart,
4998
5011
  decorators: parseDecorators(parser, context, undefined),
@@ -5004,28 +5017,42 @@ function parseModuleItem(parser, context, scope) {
5004
5017
  moduleItem = parseExportDeclaration(parser, context, scope);
5005
5018
  break;
5006
5019
  case 86106:
5020
+ if (parser.leadingDecorators.decorators.length) {
5021
+ parser.report(172);
5022
+ }
5007
5023
  moduleItem = parseImportDeclaration(parser, context, scope);
5008
5024
  break;
5009
5025
  default:
5010
5026
  moduleItem = parseStatementListItem(parser, context, scope, undefined, 4, {});
5011
5027
  }
5012
- if (parser.leadingDecorators?.decorators.length) {
5013
- parser.report(170);
5014
- }
5015
5028
  return moduleItem;
5016
5029
  }
5017
5030
  function parseStatementListItem(parser, context, scope, privateScope, origin, labels) {
5018
5031
  const start = parser.tokenStart;
5032
+ if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
5033
+ parser.report(172);
5034
+ }
5019
5035
  switch (parser.getToken()) {
5020
5036
  case 86104:
5021
5037
  return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 0, start);
5022
- case 132:
5038
+ case 133:
5039
+ if (!(parser.features & 1)) {
5040
+ parser.report(30, '@');
5041
+ }
5023
5042
  case 86094:
5024
5043
  return parseClassDeclaration(parser, context, scope, privateScope, 0);
5025
5044
  case 86090:
5026
5045
  return parseLexicalDeclaration(parser, context, scope, privateScope, 16, 0);
5027
5046
  case 241737:
5028
5047
  return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
5048
+ case 209013:
5049
+ return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5050
+ case 209006:
5051
+ if ((context & 2048 || (context & 2 && context & 8)) &&
5052
+ nextTokenIsUsingOnSameLine(parser)) {
5053
+ return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels);
5054
+ }
5055
+ return parseStatement(parser, context, scope, privateScope, origin, labels, 1);
5029
5056
  case 20564:
5030
5057
  parser.report(103, 'export');
5031
5058
  case 86106:
@@ -5079,9 +5106,9 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
5079
5106
  case 209005:
5080
5107
  return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, origin, labels, 0);
5081
5108
  case 20557:
5082
- parser.report(162);
5109
+ parser.report(164);
5083
5110
  case 20566:
5084
- parser.report(163);
5111
+ parser.report(165);
5085
5112
  case 86104:
5086
5113
  parser.report(context & 1
5087
5114
  ? 76
@@ -5109,15 +5136,18 @@ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope
5109
5136
  default:
5110
5137
  expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
5111
5138
  }
5139
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, expr, token, tokenValue, tokenStart);
5140
+ }
5141
+ function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart) {
5112
5142
  if (token & 143360 && parser.getToken() === 21) {
5113
- return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, expr, token, allowFuncDecl, tokenStart);
5143
+ return parseLabelledStatement(parser, context, scope, privateScope, origin, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart);
5114
5144
  }
5115
- expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, tokenStart);
5116
- expr = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expr);
5145
+ let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
5146
+ expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
5117
5147
  if (parser.getToken() === 18) {
5118
- expr = parseSequenceExpression(parser, context, privateScope, 0, tokenStart, expr);
5148
+ expression = parseSequenceExpression(parser, context, privateScope, 0, tokenStart, expression);
5119
5149
  }
5120
- return parseExpressionStatement(parser, context, expr, tokenStart);
5150
+ return parseExpressionStatement(parser, context, expression, tokenStart);
5121
5151
  }
5122
5152
  function parseBlock(parser, context, scope, privateScope, labels, start = parser.tokenStart, type = 'BlockStatement') {
5123
5153
  const body = [];
@@ -5179,7 +5209,7 @@ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, priva
5179
5209
  if (!asyncNewLine) {
5180
5210
  if (parser.getToken() === 86104) {
5181
5211
  if (!allowFuncDecl)
5182
- parser.report(123);
5212
+ parser.report(125);
5183
5213
  return parseFunctionDeclaration(parser, context, scope, privateScope, origin, 1, 0, 1, start);
5184
5214
  }
5185
5215
  if (isValidIdentifier(context, parser.getToken())) {
@@ -5306,9 +5336,14 @@ function parseSwitchStatement(parser, context, scope, privateScope, labels) {
5306
5336
  while (parser.getToken() !== 20556 &&
5307
5337
  parser.getToken() !== 1074790415 &&
5308
5338
  parser.getToken() !== 20561) {
5309
- consequent.push(parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5339
+ const statement = parseStatementListItem(parser, context | 4, scope, privateScope, 2, {
5310
5340
  $: labels,
5311
- }));
5341
+ });
5342
+ if (statement.type === 'VariableDeclaration' &&
5343
+ (statement.kind === 'using' || statement.kind === 'await using')) {
5344
+ parser.report(30, statement.kind);
5345
+ }
5346
+ consequent.push(statement);
5312
5347
  }
5313
5348
  cases.push(parser.finishNode({
5314
5349
  type: 'SwitchCase',
@@ -5349,7 +5384,7 @@ function parseContinueStatement(parser, context, labels) {
5349
5384
  const { tokenValue } = parser;
5350
5385
  label = parseIdentifier(parser, context | 32);
5351
5386
  if (!isValidLabel(parser, labels, tokenValue, 1))
5352
- parser.report(138, tokenValue);
5387
+ parser.report(140, tokenValue);
5353
5388
  }
5354
5389
  matchOrInsertSemicolon(parser, context | 32);
5355
5390
  return parser.finishNode({
@@ -5365,7 +5400,7 @@ function parseBreakStatement(parser, context, labels) {
5365
5400
  const { tokenValue } = parser;
5366
5401
  label = parseIdentifier(parser, context | 32);
5367
5402
  if (!isValidLabel(parser, labels, tokenValue, 0))
5368
- parser.report(138, tokenValue);
5403
+ parser.report(140, tokenValue);
5369
5404
  }
5370
5405
  else if ((context & (4 | 128)) === 0) {
5371
5406
  parser.report(69);
@@ -5510,14 +5545,90 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
5510
5545
  }
5511
5546
  return parseExpressionStatement(parser, context, expr, tokenStart);
5512
5547
  }
5513
- function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin) {
5548
+ function nextTokenIsUsingOnSameLine(parser) {
5549
+ const { index: parserIndex, source } = parser;
5550
+ let index = parserIndex;
5551
+ while (index < parser.end) {
5552
+ const char = source.charCodeAt(index);
5553
+ if (char === 0x0a || char === 0x0d || char === 0x2028 || char === 0x2029)
5554
+ return false;
5555
+ if (/\s/u.test(source[index])) {
5556
+ index++;
5557
+ continue;
5558
+ }
5559
+ if (char === 0x2f && source.charCodeAt(index + 1) === 0x2a) {
5560
+ index += 2;
5561
+ while (index < parser.end) {
5562
+ const commentChar = source.charCodeAt(index);
5563
+ if (commentChar === 0x0a || commentChar === 0x0d || commentChar === 0x2028 || commentChar === 0x2029) {
5564
+ return false;
5565
+ }
5566
+ if (commentChar === 0x2a && source.charCodeAt(index + 1) === 0x2f) {
5567
+ index += 2;
5568
+ break;
5569
+ }
5570
+ index++;
5571
+ }
5572
+ continue;
5573
+ }
5574
+ break;
5575
+ }
5576
+ if (source.slice(index, index + 5) !== 'using')
5577
+ return false;
5578
+ const following = source.codePointAt(index + 5);
5579
+ return following === undefined || (following !== 0x5c && !isIdentifierPart(following));
5580
+ }
5581
+ function isResourceBindingStart(token) {
5582
+ return (token & 143360) === 143360 && (token & 20480) !== 20480;
5583
+ }
5584
+ function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5585
+ const { tokenStart, tokenValue } = parser;
5586
+ const token = parser.getToken();
5587
+ const expression = parseIdentifier(parser, context);
5588
+ if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5589
+ if (origin & 4 && context & 8 && (context & 2) === 0) {
5590
+ parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5591
+ }
5592
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
5593
+ }
5594
+ parser.assignable = 1;
5595
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 1, expression, token, tokenValue, tokenStart);
5596
+ }
5597
+ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, origin, labels) {
5514
5598
  const start = parser.tokenStart;
5515
- nextToken(parser, context);
5516
- const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin);
5599
+ if (context & 524288)
5600
+ parser.report(179);
5601
+ nextToken(parser, context | 32);
5602
+ let argument;
5603
+ if ((parser.flags & 1) === 0 && parser.getToken() === 209013) {
5604
+ const usingStart = parser.tokenStart;
5605
+ const usingIdentifier = parseIdentifier(parser, context);
5606
+ if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5607
+ return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'await using', start, 1);
5608
+ }
5609
+ argument = parseMemberOrUpdateExpression(parser, context, privateScope, usingIdentifier, 0, 0, usingStart);
5610
+ }
5611
+ else {
5612
+ argument = parseLeftHandSideExpression(parser, context, privateScope, 0, 0, 1);
5613
+ }
5614
+ if (parser.getToken() === 8391735)
5615
+ parser.report(33);
5616
+ parser.assignable = 2;
5617
+ const expression = parser.finishNode({
5618
+ type: 'AwaitExpression',
5619
+ argument,
5620
+ }, start);
5621
+ return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, origin, labels, 0, expression, 1048576, '', start);
5622
+ }
5623
+ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
5624
+ const start = declarationStart;
5625
+ if (!keywordConsumed)
5626
+ nextToken(parser, context);
5627
+ const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind);
5517
5628
  matchOrInsertSemicolon(parser, context | 32);
5518
5629
  return parser.finishNode({
5519
5630
  type: 'VariableDeclaration',
5520
- kind: kind & 8 ? 'let' : 'const',
5631
+ kind: declarationKind ?? (kind & 8 ? 'let' : 'const'),
5521
5632
  declarations,
5522
5633
  }, start);
5523
5634
  }
@@ -5532,24 +5643,34 @@ function parseVariableStatement(parser, context, scope, privateScope, origin) {
5532
5643
  declarations,
5533
5644
  }, start);
5534
5645
  }
5535
- function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin) {
5646
+ function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
5536
5647
  let bindingCount = 1;
5537
- const list = [
5538
- parseVariableDeclaration(parser, context, scope, privateScope, kind, origin),
5539
- ];
5648
+ const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5649
+ const list = [firstDeclaration];
5650
+ const resourceNames = declarationKind && parser.options.lexical ? new Set([firstDeclaration.id.name]) : undefined;
5540
5651
  while (consumeOpt(parser, context, 18)) {
5541
5652
  bindingCount++;
5542
- list.push(parseVariableDeclaration(parser, context, scope, privateScope, kind, origin));
5653
+ const declaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
5654
+ if (resourceNames) {
5655
+ const { name } = declaration.id;
5656
+ if (resourceNames.has(name))
5657
+ parser.report(147, name);
5658
+ resourceNames.add(name);
5659
+ }
5660
+ list.push(declaration);
5543
5661
  }
5544
5662
  if (bindingCount > 1 && origin & 32 && parser.getToken() & 262144) {
5545
5663
  parser.report(61, KeywordDescTable[parser.getToken() & 255]);
5546
5664
  }
5547
5665
  return list;
5548
5666
  }
5549
- function parseVariableDeclaration(parser, context, scope, privateScope, kind, origin) {
5667
+ function parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind) {
5550
5668
  const { tokenStart } = parser;
5551
5669
  const token = parser.getToken();
5552
5670
  let init = null;
5671
+ if (declarationKind && (token & 2097152) === 2097152) {
5672
+ parser.report(50);
5673
+ }
5553
5674
  const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
5554
5675
  if (parser.getToken() === 1077936155) {
5555
5676
  nextToken(parser, context | 32);
@@ -5564,7 +5685,7 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5564
5685
  }
5565
5686
  else if ((kind & 16 || (token & 2097152) > 0) &&
5566
5687
  (parser.getToken() & 262144) !== 262144) {
5567
- parser.report(59, kind & 16 ? 'const' : 'destructuring');
5688
+ parser.report(59, declarationKind ?? (kind & 16 ? 'const' : 'destructuring'));
5568
5689
  }
5569
5690
  return parser.finishNode({
5570
5691
  type: 'VariableDeclarator',
@@ -5585,7 +5706,10 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5585
5706
  let init = null;
5586
5707
  let isVarDecl = parser.getToken() === 86088 ||
5587
5708
  parser.getToken() === 241737 ||
5588
- parser.getToken() === 86090;
5709
+ parser.getToken() === 86090 ||
5710
+ parser.getToken() === 209013;
5711
+ let resourceDeclarationKind;
5712
+ let consumedForOfDelimiter = false;
5589
5713
  let right;
5590
5714
  const { tokenStart } = parser;
5591
5715
  const token = parser.getToken();
@@ -5609,7 +5733,82 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5609
5733
  parser.assignable = 1;
5610
5734
  init = parseMemberOrUpdateExpression(parser, context, privateScope, init, 0, 0, tokenStart);
5611
5735
  if (parser.getToken() === 471156)
5612
- parser.report(115);
5736
+ parser.report(117);
5737
+ }
5738
+ }
5739
+ else if (token === 209013) {
5740
+ const usingIdentifier = parseIdentifier(parser, context);
5741
+ if ((parser.flags & 1) !== 0 || !isResourceBindingStart(parser.getToken())) {
5742
+ isVarDecl = false;
5743
+ parser.assignable = 1;
5744
+ init = parseMemberOrUpdateExpression(parser, context, privateScope, usingIdentifier, 0, 0, tokenStart);
5745
+ }
5746
+ else if (parser.getToken() === 471156) {
5747
+ const ofStart = parser.tokenStart;
5748
+ const ofToken = parser.getToken();
5749
+ const ofValue = parser.tokenValue;
5750
+ const ofIdentifier = parseIdentifier(parser, context);
5751
+ if (parser.getToken() !== 1077936155 &&
5752
+ parser.getToken() !== 8673330 &&
5753
+ parser.getToken() !== 1074790417 &&
5754
+ parser.getToken() !== 18) {
5755
+ isVarDecl = false;
5756
+ consumedForOfDelimiter = true;
5757
+ parser.assignable = 1;
5758
+ init = usingIdentifier;
5759
+ }
5760
+ else {
5761
+ resourceDeclarationKind = 'using';
5762
+ validateBindingIdentifier(parser, context, 16, ofToken, 0);
5763
+ scope?.addBlockName(context, ofValue, 16, 32);
5764
+ let declarationInitializer = null;
5765
+ if (parser.getToken() === 1077936155) {
5766
+ nextToken(parser, context | 32);
5767
+ declarationInitializer = parseExpression(parser, context | 131072, privateScope, 1, 0, parser.tokenStart);
5768
+ if ((parser.getToken() & 262144) === 262144) {
5769
+ throw new ParseError(ofStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
5770
+ }
5771
+ }
5772
+ else if (parser.getToken() !== 8673330) {
5773
+ parser.report(59, resourceDeclarationKind);
5774
+ }
5775
+ const declarations = [
5776
+ parser.finishNode({
5777
+ type: 'VariableDeclarator',
5778
+ id: ofIdentifier,
5779
+ init: declarationInitializer,
5780
+ }, ofStart),
5781
+ ];
5782
+ const resourceNames = parser.options.lexical ? new Set([ofValue]) : undefined;
5783
+ while (consumeOpt(parser, context | 131072, 18)) {
5784
+ const declaration = parseVariableDeclaration(parser, context | 131072, scope, privateScope, 16, 32, resourceDeclarationKind);
5785
+ if (resourceNames) {
5786
+ const { name } = declaration.id;
5787
+ if (resourceNames.has(name))
5788
+ parser.report(147, name);
5789
+ resourceNames.add(name);
5790
+ }
5791
+ declarations.push(declaration);
5792
+ }
5793
+ if (declarations.length > 1 && parser.getToken() & 262144) {
5794
+ parser.report(61, KeywordDescTable[parser.getToken() & 255]);
5795
+ }
5796
+ init = parser.finishNode({
5797
+ type: 'VariableDeclaration',
5798
+ kind: resourceDeclarationKind,
5799
+ declarations,
5800
+ }, tokenStart);
5801
+ parser.assignable = 1;
5802
+ }
5803
+ }
5804
+ else {
5805
+ resourceDeclarationKind = 'using';
5806
+ init = parser.finishNode({
5807
+ type: 'VariableDeclaration',
5808
+ kind: resourceDeclarationKind,
5809
+ declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 16, 32, resourceDeclarationKind),
5810
+ }, tokenStart);
5811
+ parser.assignable = 1;
5613
5812
  }
5614
5813
  }
5615
5814
  else {
@@ -5628,6 +5827,42 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5628
5827
  parser.assignable = 1;
5629
5828
  }
5630
5829
  }
5830
+ else if (token === 209006 &&
5831
+ (context & 2048 || (context & 2 && context & 8))) {
5832
+ if (context & 524288)
5833
+ parser.report(179);
5834
+ nextToken(parser, context | 32);
5835
+ let awaitArgument;
5836
+ if ((parser.flags & 1) === 0 && parser.getToken() === 209013) {
5837
+ const usingStart = parser.tokenStart;
5838
+ const usingIdentifier = parseIdentifier(parser, context);
5839
+ if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
5840
+ resourceDeclarationKind = 'await using';
5841
+ isVarDecl = true;
5842
+ init = parser.finishNode({
5843
+ type: 'VariableDeclaration',
5844
+ kind: resourceDeclarationKind,
5845
+ declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 16, 32, resourceDeclarationKind),
5846
+ }, tokenStart);
5847
+ parser.assignable = 1;
5848
+ }
5849
+ else {
5850
+ awaitArgument = parseMemberOrUpdateExpression(parser, context, privateScope, usingIdentifier, 0, 0, usingStart);
5851
+ }
5852
+ }
5853
+ else {
5854
+ awaitArgument = parseLeftHandSideExpression(parser, context, privateScope, 0, 0, 1);
5855
+ }
5856
+ if (!isVarDecl) {
5857
+ if (parser.getToken() === 8391735)
5858
+ parser.report(33);
5859
+ parser.assignable = 2;
5860
+ init = parser.finishNode({
5861
+ type: 'AwaitExpression',
5862
+ argument: awaitArgument,
5863
+ }, tokenStart);
5864
+ }
5865
+ }
5631
5866
  else if (token === 1074790417) {
5632
5867
  if (forAwait)
5633
5868
  parser.report(82);
@@ -5649,12 +5884,13 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5649
5884
  else {
5650
5885
  init = parseLeftHandSideExpression(parser, context | 131072, privateScope, 1, 0, 1);
5651
5886
  }
5652
- if ((parser.getToken() & 262144) === 262144) {
5653
- if (parser.getToken() === 471156) {
5887
+ if (consumedForOfDelimiter || (parser.getToken() & 262144) === 262144) {
5888
+ if (consumedForOfDelimiter || parser.getToken() === 471156) {
5654
5889
  if (parser.assignable & 2)
5655
5890
  parser.report(80, forAwait ? 'await' : 'of');
5656
5891
  reinterpretToPattern(parser, init);
5657
- nextToken(parser, context | 32);
5892
+ if (!consumedForOfDelimiter)
5893
+ nextToken(parser, context | 32);
5658
5894
  right = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5659
5895
  consume(parser, context | 32, 16);
5660
5896
  const body = parseIterationStatementBody(parser, context, scope, privateScope, labels);
@@ -5666,6 +5902,8 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5666
5902
  await: forAwait,
5667
5903
  }, start);
5668
5904
  }
5905
+ if (resourceDeclarationKind)
5906
+ parser.report(30, 'in');
5669
5907
  if (parser.assignable & 2)
5670
5908
  parser.report(80, 'in');
5671
5909
  reinterpretToPattern(parser, init);
@@ -5710,9 +5948,9 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
5710
5948
  }
5711
5949
  function parseRestrictedIdentifier(parser, context, scope) {
5712
5950
  if (!isValidIdentifier(context, parser.getToken()))
5713
- parser.report(118);
5951
+ parser.report(120);
5714
5952
  if ((parser.getToken() & 537079808) === 537079808)
5715
- parser.report(119);
5953
+ parser.report(121);
5716
5954
  scope?.addBlockName(context, parser.tokenValue, 8, 0);
5717
5955
  return parseIdentifier(parser, context);
5718
5956
  }
@@ -5720,6 +5958,8 @@ function parseImportDeclaration(parser, context, scope) {
5720
5958
  const start = parser.tokenStart;
5721
5959
  nextToken(parser, context);
5722
5960
  let source;
5961
+ let sourceParsed = false;
5962
+ let phase = null;
5723
5963
  const { tokenStart } = parser;
5724
5964
  let specifiers = [];
5725
5965
  if (parser.getToken() === 134283267) {
@@ -5727,14 +5967,93 @@ function parseImportDeclaration(parser, context, scope) {
5727
5967
  }
5728
5968
  else {
5729
5969
  if (parser.getToken() & 143360) {
5730
- const local = parseRestrictedIdentifier(parser, context, scope);
5731
- specifiers = [
5732
- parser.finishNode({
5733
- type: 'ImportDefaultSpecifier',
5734
- local,
5735
- }, tokenStart),
5736
- ];
5737
- if (consumeOpt(parser, context, 18)) {
5970
+ const token = parser.getToken();
5971
+ const { tokenValue } = parser;
5972
+ const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && tokenValue == 'defer';
5973
+ const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && tokenValue == 'source';
5974
+ if (isPhaseDefer || isPhaseSource) {
5975
+ const phaseOrLocal = parseIdentifier(parser, context);
5976
+ if (tokenValue === 'defer') {
5977
+ if (parser.getToken() === 8391476) {
5978
+ phase = 'defer';
5979
+ specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
5980
+ }
5981
+ else if (parser.getToken() === 209011 || parser.getToken() === 18) {
5982
+ scope?.addBlockName(context, tokenValue, 8, 0);
5983
+ specifiers = [
5984
+ parser.finishNode({
5985
+ type: 'ImportDefaultSpecifier',
5986
+ local: phaseOrLocal,
5987
+ }, tokenStart),
5988
+ ];
5989
+ }
5990
+ else {
5991
+ parser.report(108);
5992
+ }
5993
+ }
5994
+ else if (parser.getToken() === 209011) {
5995
+ const fromToken = parser.getToken();
5996
+ const fromStart = parser.tokenStart;
5997
+ const fromLocal = parseIdentifier(parser, context);
5998
+ if (parser.getToken() === 209011) {
5999
+ validateBindingIdentifier(parser, context, 16, fromToken, 0);
6000
+ scope?.addBlockName(context, fromLocal.name, 8, 0);
6001
+ phase = 'source';
6002
+ specifiers = [
6003
+ parser.finishNode({
6004
+ type: 'ImportDefaultSpecifier',
6005
+ local: fromLocal,
6006
+ }, fromStart),
6007
+ ];
6008
+ }
6009
+ else {
6010
+ scope?.addBlockName(context, tokenValue, 8, 0);
6011
+ specifiers = [
6012
+ parser.finishNode({
6013
+ type: 'ImportDefaultSpecifier',
6014
+ local: phaseOrLocal,
6015
+ }, tokenStart),
6016
+ ];
6017
+ if (parser.getToken() !== 134283267)
6018
+ parser.report(105, 'Import');
6019
+ source = parseLiteral(parser, context);
6020
+ sourceParsed = true;
6021
+ }
6022
+ }
6023
+ else if (parser.getToken() & 143360) {
6024
+ phase = 'source';
6025
+ const localStart = parser.tokenStart;
6026
+ const local = parseRestrictedIdentifier(parser, context, scope);
6027
+ specifiers = [
6028
+ parser.finishNode({
6029
+ type: 'ImportDefaultSpecifier',
6030
+ local,
6031
+ }, localStart),
6032
+ ];
6033
+ }
6034
+ else if (parser.getToken() === 18) {
6035
+ scope?.addBlockName(context, tokenValue, 8, 0);
6036
+ specifiers = [
6037
+ parser.finishNode({
6038
+ type: 'ImportDefaultSpecifier',
6039
+ local: phaseOrLocal,
6040
+ }, tokenStart),
6041
+ ];
6042
+ }
6043
+ else {
6044
+ parser.report(109);
6045
+ }
6046
+ }
6047
+ else {
6048
+ const local = parseRestrictedIdentifier(parser, context, scope);
6049
+ specifiers = [
6050
+ parser.finishNode({
6051
+ type: 'ImportDefaultSpecifier',
6052
+ local,
6053
+ }, tokenStart),
6054
+ ];
6055
+ }
6056
+ if (phase === null && !sourceParsed && consumeOpt(parser, context, 18)) {
5738
6057
  switch (parser.getToken()) {
5739
6058
  case 8391476:
5740
6059
  specifiers.push(parseImportNamespaceSpecifier(parser, context, scope));
@@ -5763,7 +6082,8 @@ function parseImportDeclaration(parser, context, scope) {
5763
6082
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
5764
6083
  }
5765
6084
  }
5766
- source = parseModuleSpecifier(parser, context);
6085
+ if (!sourceParsed)
6086
+ source = parseModuleSpecifier(parser, context);
5767
6087
  }
5768
6088
  const attributes = parseImportAttributes(parser, context);
5769
6089
  const node = {
@@ -5771,6 +6091,7 @@ function parseImportDeclaration(parser, context, scope) {
5771
6091
  specifiers,
5772
6092
  source,
5773
6093
  attributes,
6094
+ ...(parser.features & 2 || parser.features & 4 ? { phase } : null),
5774
6095
  };
5775
6096
  matchOrInsertSemicolon(parser, context | 32);
5776
6097
  return parser.finishNode(node, start);
@@ -5853,17 +6174,24 @@ function parseImportCallDeclaration(parser, context, privateScope, start) {
5853
6174
  function parseExportDeclaration(parser, context, scope) {
5854
6175
  const start = parser.leadingDecorators.decorators.length ? parser.leadingDecorators.start : parser.tokenStart;
5855
6176
  nextToken(parser, context | 32);
6177
+ const isDefaultExport = consumeOpt(parser, context | 32, 20561);
6178
+ if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
6179
+ parser.report(172);
6180
+ }
5856
6181
  const specifiers = [];
5857
6182
  let declaration = null;
5858
6183
  let source = null;
5859
6184
  let attributes = [];
5860
- if (consumeOpt(parser, context | 32, 20561)) {
6185
+ if (isDefaultExport) {
5861
6186
  switch (parser.getToken()) {
5862
6187
  case 86104: {
5863
6188
  declaration = parseFunctionDeclaration(parser, context, scope, undefined, 4, 1, 1, 0, parser.tokenStart);
5864
6189
  break;
5865
6190
  }
5866
- case 132:
6191
+ case 133:
6192
+ if (!(parser.features & 1)) {
6193
+ parser.report(30, '@');
6194
+ }
5867
6195
  case 86094:
5868
6196
  declaration = parseClassDeclaration(parser, context, scope, undefined, 1);
5869
6197
  break;
@@ -5976,7 +6304,7 @@ function parseExportDeclaration(parser, context, scope) {
5976
6304
  }
5977
6305
  else {
5978
6306
  if (hasLiteralLocal) {
5979
- parser.report(172);
6307
+ parser.report(174);
5980
6308
  }
5981
6309
  if (scope) {
5982
6310
  tmpExportedNames.forEach((n) => parser.declareUnboundVariable(n));
@@ -5986,7 +6314,10 @@ function parseExportDeclaration(parser, context, scope) {
5986
6314
  matchOrInsertSemicolon(parser, context | 32);
5987
6315
  break;
5988
6316
  }
5989
- case 132:
6317
+ case 133:
6318
+ if (!(parser.features & 1)) {
6319
+ parser.report(30, '@');
6320
+ }
5990
6321
  case 86094:
5991
6322
  declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
5992
6323
  break;
@@ -6119,7 +6450,7 @@ function parseBinaryExpression(parser, context, privateScope, inGroup, start, mi
6119
6450
  t = parser.getToken();
6120
6451
  precedence = t & 3840;
6121
6452
  if ((t & 524288 && operator & 268435456) || (operator & 524288 && t & 268435456)) {
6122
- parser.report(165);
6453
+ parser.report(167);
6123
6454
  }
6124
6455
  if (precedence + ((t === 8391735) << 8) - ((bit === t) << 12) <= minPrecedence)
6125
6456
  break;
@@ -6146,10 +6477,10 @@ function parseUnaryExpression(parser, context, privateScope, isLHS, inGroup) {
6146
6477
  parser.report(33);
6147
6478
  if (context & 1 && unaryOperator === 16863276) {
6148
6479
  if (arg.type === 'Identifier') {
6149
- parser.report(121);
6480
+ parser.report(123);
6150
6481
  }
6151
6482
  else if (isPropertyWithPrivateFieldKey(arg)) {
6152
- parser.report(127);
6483
+ parser.report(129);
6153
6484
  }
6154
6485
  }
6155
6486
  parser.assignable = 2;
@@ -6202,7 +6533,7 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
6202
6533
  if (!canAssign)
6203
6534
  parser.report(26);
6204
6535
  if (parser.getToken() === 22)
6205
- parser.report(124);
6536
+ parser.report(126);
6206
6537
  let argument = null;
6207
6538
  let delegate = false;
6208
6539
  if ((parser.flags & 1) === 0) {
@@ -6229,17 +6560,17 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
6229
6560
  if (inGroup)
6230
6561
  parser.destructible |= 128;
6231
6562
  if (context & 524288)
6232
- parser.report(177);
6563
+ parser.report(179);
6233
6564
  const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
6234
6565
  const isIdentifier = possibleIdentifierOrArrowFunc.type === 'ArrowFunctionExpression' ||
6235
6566
  (parser.getToken() & 65536) === 0;
6236
6567
  if (isIdentifier) {
6237
6568
  if (context & 2048)
6238
- throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 176);
6569
+ throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 178);
6239
6570
  if (context & 2)
6240
- throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 110);
6571
+ throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 112);
6241
6572
  if (context & 8192 && context & 2048)
6242
- throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 110);
6573
+ throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 112);
6243
6574
  return possibleIdentifierOrArrowFunc;
6244
6575
  }
6245
6576
  if (context & 8192) {
@@ -6263,6 +6594,7 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
6263
6594
  }
6264
6595
  function parseFunctionBody(parser, context, scope, privateScope, origin, funcNameToken, functionScope) {
6265
6596
  const { tokenStart } = parser;
6597
+ parser.flags &= -4161;
6266
6598
  consume(parser, context | 32, 2162700);
6267
6599
  const body = [];
6268
6600
  if (parser.getToken() !== 1074790415) {
@@ -6288,19 +6620,19 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6288
6620
  if (context & 1) {
6289
6621
  if (funcNameToken) {
6290
6622
  if ((funcNameToken & 537079808) === 537079808) {
6291
- parser.report(119);
6623
+ parser.report(121);
6292
6624
  }
6293
6625
  if ((funcNameToken & 36864) === 36864) {
6294
6626
  parser.report(40);
6295
6627
  }
6296
6628
  }
6297
6629
  if (parser.flags & 512)
6298
- parser.report(119);
6630
+ parser.report(121);
6299
6631
  if (parser.flags & 256) {
6300
6632
  if (parser.strictReservedRange) {
6301
- throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
6633
+ throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 120);
6302
6634
  }
6303
- parser.report(118);
6635
+ parser.report(120);
6304
6636
  }
6305
6637
  }
6306
6638
  }
@@ -6324,8 +6656,8 @@ function parseSuperExpression(parser, context) {
6324
6656
  const { tokenStart } = parser;
6325
6657
  nextToken(parser, context);
6326
6658
  switch (parser.getToken()) {
6327
- case 67108990:
6328
- parser.report(167);
6659
+ case 67108991:
6660
+ parser.report(169);
6329
6661
  case 67174411: {
6330
6662
  if ((context & 512) === 0)
6331
6663
  parser.report(28);
@@ -6371,10 +6703,13 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6371
6703
  switch (parser.getToken()) {
6372
6704
  case 67108877: {
6373
6705
  nextToken(parser, (context | 262144 | 8) ^ 8);
6374
- if (context & 16 && parser.getToken() === 130 && parser.tokenValue === 'super') {
6375
- parser.report(173);
6706
+ if (context & 16 && parser.getToken() === 131 && parser.tokenValue === 'super') {
6707
+ parser.report(175);
6376
6708
  }
6377
- parser.assignable = 1;
6709
+ parser.assignable =
6710
+ (parser.flags & 2048) === 2048
6711
+ ? 2
6712
+ : 1;
6378
6713
  const property = parsePropertyOrPrivatePropertyName(parser, context | 64, privateScope);
6379
6714
  expr = parser.finishNode({
6380
6715
  type: 'MemberExpression',
@@ -6399,7 +6734,7 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6399
6734
  const { tokenStart } = parser;
6400
6735
  const property = parseExpressions(parser, context, privateScope, inGroup, 1, tokenStart);
6401
6736
  consume(parser, context, 20);
6402
- parser.assignable = 1;
6737
+ parser.assignable = restoreHasOptionalChaining ? 2 : 1;
6403
6738
  expr = parser.finishNode({
6404
6739
  type: 'MemberExpression',
6405
6740
  object: expr,
@@ -6440,7 +6775,7 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6440
6775
  }
6441
6776
  break;
6442
6777
  }
6443
- case 67108990: {
6778
+ case 67108991: {
6444
6779
  nextToken(parser, (context | 262144 | 8) ^ 8);
6445
6780
  parser.flags |= 2048;
6446
6781
  parser.assignable = 2;
@@ -6449,7 +6784,7 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6449
6784
  }
6450
6785
  default:
6451
6786
  if ((parser.flags & 2048) === 2048) {
6452
- parser.report(166);
6787
+ parser.report(168);
6453
6788
  }
6454
6789
  parser.assignable = 2;
6455
6790
  expr = parser.finishNode({
@@ -6527,12 +6862,12 @@ function parseOptionalChain(parser, context, privateScope, expr, start) {
6527
6862
  }
6528
6863
  function parsePropertyOrPrivatePropertyName(parser, context, privateScope) {
6529
6864
  if ((parser.getToken() & 143360) === 0 &&
6530
- parser.getToken() !== -2147483528 &&
6531
6865
  parser.getToken() !== -2147483527 &&
6532
- parser.getToken() !== 130) {
6533
- parser.report(160);
6866
+ parser.getToken() !== -2147483526 &&
6867
+ parser.getToken() !== 131) {
6868
+ parser.report(162);
6534
6869
  }
6535
- return parser.getToken() === 130
6870
+ return parser.getToken() === 131
6536
6871
  ? parsePrivateIdentifier(parser, context, privateScope, 0)
6537
6872
  : parseIdentifier(parser, context);
6538
6873
  }
@@ -6581,10 +6916,10 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6581
6916
  !(context & 32768) &&
6582
6917
  !(context & 8192) &&
6583
6918
  parser.tokenValue === 'arguments')
6584
- parser.report(130);
6919
+ parser.report(132);
6585
6920
  if ((token & 255) === (241737 & 255)) {
6586
6921
  if (context & 1)
6587
- parser.report(113);
6922
+ parser.report(115);
6588
6923
  if (kind & (8 | 16))
6589
6924
  parser.report(100);
6590
6925
  }
@@ -6625,7 +6960,10 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6625
6960
  return parseThisExpression(parser, context);
6626
6961
  case 65540:
6627
6962
  return parseRegExpLiteral(parser, context);
6628
- case 132:
6963
+ case 133:
6964
+ if (!(parser.features & 1)) {
6965
+ parser.report(30, '@');
6966
+ }
6629
6967
  case 86094:
6630
6968
  return parseClassExpression(parser, context, privateScope, inGroup, start);
6631
6969
  case 86109:
@@ -6636,9 +6974,9 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6636
6974
  return parseTemplate(parser, context, privateScope);
6637
6975
  case 86107:
6638
6976
  return parseNewExpression(parser, context, privateScope, inGroup);
6639
- case 134283388:
6977
+ case 134283389:
6640
6978
  return parseBigIntLiteral(parser, context);
6641
- case 130:
6979
+ case 131:
6642
6980
  return parsePrivateIdentifier(parser, context, privateScope, 0);
6643
6981
  case 86106:
6644
6982
  return parseImportCallOrMetaExpression(parser, context, privateScope, inNew, inGroup, start);
@@ -6654,24 +6992,37 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
6654
6992
  function parseImportCallOrMetaExpression(parser, context, privateScope, inNew, inGroup, start) {
6655
6993
  let expr = parseIdentifier(parser, context);
6656
6994
  if (parser.getToken() === 67108877) {
6657
- return parseImportMetaExpression(parser, context, expr, start);
6995
+ return parseImportMetaExpression(parser, context, expr, start, privateScope, inGroup, inNew);
6658
6996
  }
6659
6997
  if (inNew)
6660
- parser.report(142);
6998
+ parser.report(144);
6661
6999
  expr = parseImportExpression(parser, context, privateScope, inGroup, start);
6662
7000
  parser.assignable = 2;
6663
7001
  return parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
6664
7002
  }
6665
- function parseImportMetaExpression(parser, context, meta, start) {
6666
- if ((context & 2) === 0)
6667
- parser.report(169);
7003
+ function parseImportMetaExpression(parser, context, meta, start, privateScope, inGroup = 0, inNew = 0) {
7004
+ const propertyStart = parser.tokenStart;
7005
+ const propertyEnd = parser.currentLocation;
6668
7006
  nextToken(parser, context);
6669
7007
  const token = parser.getToken();
6670
- if (token !== 209030 && parser.tokenValue !== 'meta') {
6671
- parser.report(174);
7008
+ const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && parser.tokenValue === 'defer';
7009
+ const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && parser.tokenValue === 'source';
7010
+ if (isPhaseDefer || isPhaseSource) {
7011
+ if (inNew)
7012
+ parser.report(144);
7013
+ nextToken(parser, context);
7014
+ const expression = parseImportExpression(parser, context, privateScope, inGroup, start, parser.tokenValue);
7015
+ parser.assignable = 2;
7016
+ return expression;
7017
+ }
7018
+ if ((context & 2) === 0) {
7019
+ throw new ParseError(propertyStart, propertyEnd, 171);
7020
+ }
7021
+ if (token !== 209031 && parser.tokenValue !== 'meta') {
7022
+ parser.report(176);
6672
7023
  }
6673
7024
  else if (token & -2147483648) {
6674
- parser.report(175);
7025
+ parser.report(177);
6675
7026
  }
6676
7027
  parser.assignable = 2;
6677
7028
  return parser.finishNode({
@@ -6680,10 +7031,10 @@ function parseImportMetaExpression(parser, context, meta, start) {
6680
7031
  property: parseIdentifier(parser, context),
6681
7032
  }, start);
6682
7033
  }
6683
- function parseImportExpression(parser, context, privateScope, inGroup, start) {
7034
+ function parseImportExpression(parser, context, privateScope, inGroup, start, phase = null) {
6684
7035
  consume(parser, context | 32, 67174411);
6685
7036
  if (parser.getToken() === 14)
6686
- parser.report(143);
7037
+ parser.report(145);
6687
7038
  const source = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
6688
7039
  let options = null;
6689
7040
  if (parser.getToken() === 18) {
@@ -6698,6 +7049,7 @@ function parseImportExpression(parser, context, privateScope, inGroup, start) {
6698
7049
  type: 'ImportExpression',
6699
7050
  source,
6700
7051
  options,
7052
+ ...(parser.features & 2 || parser.features & 4 ? { phase } : null),
6701
7053
  };
6702
7054
  consume(parser, context, 16);
6703
7055
  return parser.finishNode(node, start);
@@ -6715,7 +7067,7 @@ function parseImportAttributes(parser, context) {
6715
7067
  const value = parseStringLiteral(parser, context);
6716
7068
  const keyContent = key.type === 'Literal' ? key.value : key.name;
6717
7069
  if (keysContent.has(keyContent)) {
6718
- parser.report(145, `${keyContent}`);
7070
+ parser.report(147, keyContent);
6719
7071
  }
6720
7072
  keysContent.add(keyContent);
6721
7073
  attributes.push(parser.finishNode({
@@ -6753,7 +7105,7 @@ function parseModuleExportName(parser, context) {
6753
7105
  if (parser.getToken() === 134283267) {
6754
7106
  const value = parser.tokenValue;
6755
7107
  if (!value.isWellFormed()) {
6756
- parser.report(171);
7108
+ parser.report(173);
6757
7109
  }
6758
7110
  return parseLiteral(parser, context);
6759
7111
  }
@@ -6891,7 +7243,7 @@ function parseIdentifier(parser, context) {
6891
7243
  }
6892
7244
  function parseLiteral(parser, context) {
6893
7245
  const { tokenValue, tokenRaw, tokenStart } = parser;
6894
- if (parser.getToken() === 134283388) {
7246
+ if (parser.getToken() === 134283389) {
6895
7247
  return parseBigIntLiteral(parser, context);
6896
7248
  }
6897
7249
  const node = {
@@ -7314,7 +7666,7 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
7314
7666
  }
7315
7667
  parser.destructible = destructible;
7316
7668
  if (parser.getToken() !== closingToken && parser.getToken() !== 18)
7317
- parser.report(161);
7669
+ parser.report(163);
7318
7670
  return parser.finishNode({
7319
7671
  type: isPattern ? 'RestElement' : 'SpreadElement',
7320
7672
  argument: argument,
@@ -7408,9 +7760,9 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7408
7760
  let key = null;
7409
7761
  let value;
7410
7762
  if (parser.getToken() & 143360 ||
7411
- parser.getToken() === -2147483528 ||
7412
- parser.getToken() === -2147483527) {
7413
- if (parser.getToken() === -2147483527)
7763
+ parser.getToken() === -2147483527 ||
7764
+ parser.getToken() === -2147483526) {
7765
+ if (parser.getToken() === -2147483526)
7414
7766
  destructible |= 16;
7415
7767
  key = parseIdentifier(parser, context);
7416
7768
  if (parser.getToken() === 18 ||
@@ -7442,7 +7794,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7442
7794
  else {
7443
7795
  destructible |=
7444
7796
  (token === 209006 ? 128 : 0) |
7445
- (token === -2147483528 ? 16 : 0);
7797
+ (token === -2147483527 ? 16 : 0);
7446
7798
  value = parser.cloneIdentifier(key);
7447
7799
  }
7448
7800
  }
@@ -7569,11 +7921,11 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7569
7921
  }
7570
7922
  else if (parser.getToken() & 143360) {
7571
7923
  destructible |= 16;
7572
- if (token === -2147483528)
7924
+ if (token === -2147483527)
7573
7925
  parser.report(95);
7574
7926
  if (token === 209005) {
7575
7927
  if (parser.flags & 1)
7576
- parser.report(132);
7928
+ parser.report(134);
7577
7929
  state |= 16 | 1;
7578
7930
  }
7579
7931
  else if (token === 209008) {
@@ -7637,7 +7989,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7637
7989
  value = parseMethodDefinition(parser, context, privateScope, state, inGroup, parser.tokenStart);
7638
7990
  }
7639
7991
  else {
7640
- parser.report(133);
7992
+ parser.report(135);
7641
7993
  }
7642
7994
  }
7643
7995
  else if ((parser.getToken() & 134217728) === 134217728) {
@@ -7741,7 +8093,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7741
8093
  destructible = 16;
7742
8094
  }
7743
8095
  else {
7744
- parser.report(134);
8096
+ parser.report(136);
7745
8097
  }
7746
8098
  }
7747
8099
  else if (parser.getToken() === 69271571) {
@@ -7888,7 +8240,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
7888
8240
  value = parseMethodDefinition(parser, context, privateScope, state, inGroup, parser.tokenStart);
7889
8241
  }
7890
8242
  else {
7891
- parser.report(126);
8243
+ parser.report(128);
7892
8244
  }
7893
8245
  }
7894
8246
  else {
@@ -8066,7 +8418,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8066
8418
  parser.assignable = 2;
8067
8419
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
8068
8420
  if (destructible & 8)
8069
- parser.report(122);
8421
+ parser.report(124);
8070
8422
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, tokenStart);
8071
8423
  destructible |= 16;
8072
8424
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
@@ -8139,7 +8491,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8139
8491
  }
8140
8492
  consume(parser, context, 16);
8141
8493
  if (destructible & 16 && destructible & 8)
8142
- parser.report(151);
8494
+ parser.report(153);
8143
8495
  destructible |=
8144
8496
  parser.destructible & 256
8145
8497
  ? 256
@@ -8164,7 +8516,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
8164
8516
  parser.report(63);
8165
8517
  }
8166
8518
  if (destructible & 8) {
8167
- parser.report(144);
8519
+ parser.report(146);
8168
8520
  }
8169
8521
  parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
8170
8522
  return parser.options.preserveParens
@@ -8235,17 +8587,17 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8235
8587
  switch (parser.getToken()) {
8236
8588
  case 69271571:
8237
8589
  if ((parser.flags & 1) === 0) {
8238
- parser.report(116);
8590
+ parser.report(118);
8239
8591
  }
8240
8592
  parser.flags |= 8192;
8241
8593
  break;
8242
8594
  case 67108877:
8243
8595
  case 67174409:
8244
8596
  case 22:
8245
- parser.report(117);
8597
+ parser.report(119);
8246
8598
  case 67174411:
8247
8599
  if ((parser.flags & 1) === 0) {
8248
- parser.report(116);
8600
+ parser.report(118);
8249
8601
  }
8250
8602
  parser.flags |= 1024;
8251
8603
  break;
@@ -8253,7 +8605,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
8253
8605
  if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
8254
8606
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
8255
8607
  if ((parser.getToken() & 33619968) === 33619968)
8256
- parser.report(125);
8608
+ parser.report(127);
8257
8609
  }
8258
8610
  parser.assignable = 2;
8259
8611
  return parser.finishNode({
@@ -8380,7 +8732,7 @@ function parseNewExpression(parser, context, privateScope, inGroup) {
8380
8732
  const id = parseIdentifier(parser, context | 32);
8381
8733
  const { tokenStart } = parser;
8382
8734
  if (consumeOpt(parser, context, 67108877)) {
8383
- if (context & 65536 && parser.getToken() === 209029) {
8735
+ if (context & 65536 && parser.getToken() === 209030) {
8384
8736
  parser.assignable = 2;
8385
8737
  return parseMetaProperty(parser, context, id, start);
8386
8738
  }
@@ -8392,8 +8744,8 @@ function parseNewExpression(parser, context, privateScope, inGroup) {
8392
8744
  }
8393
8745
  const expr = parsePrimaryExpression(parser, context, privateScope, 2, 1, 0, inGroup, 1, tokenStart);
8394
8746
  context = (context | 131072) ^ 131072;
8395
- if (parser.getToken() === 67108990)
8396
- parser.report(168);
8747
+ if (parser.getToken() === 67108991)
8748
+ parser.report(170);
8397
8749
  const callee = parseMemberExpressionNoCall(parser, context, privateScope, expr, inGroup, tokenStart);
8398
8750
  parser.assignable = 2;
8399
8751
  return parser.finishNode({
@@ -8492,7 +8844,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
8492
8844
  isNonSimpleParameterList = 1;
8493
8845
  if (parser.getToken() !== 16 && parser.getToken() !== 18) {
8494
8846
  if (destructible & 8)
8495
- parser.report(122);
8847
+ parser.report(124);
8496
8848
  expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, tokenStart);
8497
8849
  destructible |= 16;
8498
8850
  if ((parser.getToken() & 8388608) === 8388608) {
@@ -8593,9 +8945,6 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8593
8945
  let start;
8594
8946
  let decorators;
8595
8947
  if (parser.leadingDecorators.decorators.length) {
8596
- if (parser.getToken() === 132) {
8597
- parser.report(30, '@');
8598
- }
8599
8948
  start = parser.leadingDecorators.start;
8600
8949
  decorators = [...parser.leadingDecorators.decorators];
8601
8950
  parser.leadingDecorators.decorators.length = 0;
@@ -8605,16 +8954,16 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8605
8954
  decorators = parseDecorators(parser, context, privateScope);
8606
8955
  }
8607
8956
  context = (context | 16384 | 1) ^ 16384;
8608
- nextToken(parser, context);
8957
+ consume(parser, context, 86094);
8609
8958
  let id = null;
8610
8959
  let superClass = null;
8611
8960
  const { tokenValue } = parser;
8612
8961
  if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
8613
8962
  if (isStrictReservedWord(parser, context, parser.getToken())) {
8614
- parser.report(118);
8963
+ parser.report(120);
8615
8964
  }
8616
8965
  if ((parser.getToken() & 537079808) === 537079808) {
8617
- parser.report(119);
8966
+ parser.report(121);
8618
8967
  }
8619
8968
  if (scope) {
8620
8969
  scope.addBlockName(context, tokenValue, 32, 0);
@@ -8644,7 +8993,7 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
8644
8993
  id,
8645
8994
  superClass,
8646
8995
  body,
8647
- ...(parser.options.next ? { decorators } : null),
8996
+ ...(parser.features & 1 ? { decorators } : null),
8648
8997
  }, start);
8649
8998
  }
8650
8999
  function parseClassExpression(parser, context, privateScope, inGroup, start) {
@@ -8652,12 +9001,12 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
8652
9001
  let superClass = null;
8653
9002
  const decorators = parseDecorators(parser, context, privateScope);
8654
9003
  context = (context | 1 | 16384) ^ 16384;
8655
- nextToken(parser, context);
9004
+ consume(parser, context, 86094);
8656
9005
  if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
8657
9006
  if (isStrictReservedWord(parser, context, parser.getToken()))
8658
- parser.report(118);
9007
+ parser.report(120);
8659
9008
  if ((parser.getToken() & 537079808) === 537079808) {
8660
- parser.report(119);
9009
+ parser.report(121);
8661
9010
  }
8662
9011
  id = parseIdentifier(parser, context);
8663
9012
  }
@@ -8676,24 +9025,61 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
8676
9025
  id,
8677
9026
  superClass,
8678
9027
  body,
8679
- ...(parser.options.next ? { decorators } : null),
9028
+ ...(parser.features & 1 ? { decorators } : null),
8680
9029
  }, start);
8681
9030
  }
8682
9031
  function parseDecorators(parser, context, privateScope) {
8683
9032
  const list = [];
8684
- if (parser.options.next) {
8685
- while (parser.getToken() === 132) {
8686
- list.push(parseDecoratorList(parser, context, privateScope));
9033
+ if (parser.features & 1) {
9034
+ while (parser.getToken() === 133) {
9035
+ list.push(parseDecorator(parser, context, privateScope));
8687
9036
  }
8688
9037
  }
8689
9038
  return list;
8690
9039
  }
8691
- function parseDecoratorList(parser, context, privateScope) {
9040
+ function parseDecorator(parser, context, privateScope) {
8692
9041
  const start = parser.tokenStart;
8693
9042
  nextToken(parser, context | 32);
8694
9043
  const expressionStart = parser.tokenStart;
8695
- let expression = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, start);
8696
- expression = parseMemberOrUpdateExpression(parser, context, privateScope, expression, 0, 0, expressionStart);
9044
+ let expression;
9045
+ if (parser.getToken() === 67174411) {
9046
+ expression = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, start);
9047
+ }
9048
+ else {
9049
+ const token = parser.getToken();
9050
+ if (((token & 143360) !== 143360 && !isValidIdentifier(context, token)) ||
9051
+ (context & 1 && (token & 36864) === 36864)) {
9052
+ parser.report(30, KeywordDescTable[token & 255]);
9053
+ }
9054
+ if (token === 209006 && context & (2048 | 2)) {
9055
+ parser.report(112);
9056
+ }
9057
+ if (token === 241771 && context & 1024) {
9058
+ parser.report(97, 'yield');
9059
+ }
9060
+ let memberExpression = parseIdentifier(parser, context | 64);
9061
+ while (parser.getToken() === 67108877) {
9062
+ nextToken(parser, (context | 262144 | 8) ^ 8);
9063
+ const property = parsePropertyOrPrivatePropertyName(parser, context | 64, privateScope);
9064
+ memberExpression = parser.finishNode({
9065
+ type: 'MemberExpression',
9066
+ object: memberExpression,
9067
+ computed: false,
9068
+ property,
9069
+ optional: false,
9070
+ }, expressionStart);
9071
+ }
9072
+ expression = memberExpression;
9073
+ if (parser.getToken() === 67174411) {
9074
+ const args = parseArguments(parser, context, privateScope, 0);
9075
+ expression = parser.finishNode({
9076
+ type: 'CallExpression',
9077
+ callee: memberExpression,
9078
+ arguments: args,
9079
+ optional: false,
9080
+ }, expressionStart);
9081
+ }
9082
+ }
8697
9083
  return parser.finishNode({
8698
9084
  type: 'Decorator',
8699
9085
  expression,
@@ -8712,13 +9098,13 @@ function parseClassBody(parser, context, inheritedContext, scope, parentScope, k
8712
9098
  const decoratorStart = parser.tokenStart;
8713
9099
  const decorators = parseDecorators(parser, context, privateScope);
8714
9100
  if (decorators.length > 0 && parser.tokenValue === 'constructor') {
8715
- parser.report(109);
9101
+ parser.report(111);
8716
9102
  }
8717
9103
  if (parser.getToken() === 1074790415)
8718
- parser.report(108);
9104
+ parser.report(110);
8719
9105
  if (consumeOpt(parser, context, 1074790417)) {
8720
9106
  if (decorators.length > 0)
8721
- parser.report(120);
9107
+ parser.report(122);
8722
9108
  continue;
8723
9109
  }
8724
9110
  body.push(parseClassElementList(parser, context, scope, privateScope, inheritedContext, kind, decorators, 0, inGroup, decorators.length > 0 ? decoratorStart : parser.tokenStart));
@@ -8735,7 +9121,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8735
9121
  let kind = isStatic ? 32 : 0;
8736
9122
  let key = null;
8737
9123
  const token = parser.getToken();
8738
- if (token & (143360 | 36864) || token === -2147483528) {
9124
+ if (token & (143360 | 36864) || token === -2147483527) {
8739
9125
  key = parseIdentifier(parser, context);
8740
9126
  switch (token) {
8741
9127
  case 36970:
@@ -8781,7 +9167,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8781
9167
  if ((parser.getToken() & 1073741824) === 1073741824) {
8782
9168
  return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8783
9169
  }
8784
- if (parser.options.next)
9170
+ if (parser.features & 1)
8785
9171
  kind |= 1024;
8786
9172
  }
8787
9173
  break;
@@ -8798,7 +9184,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8798
9184
  kind |= 8;
8799
9185
  nextToken(parser, context);
8800
9186
  }
8801
- else if (parser.getToken() === 130) {
9187
+ else if (parser.getToken() === 131) {
8802
9188
  kind |= 8192;
8803
9189
  key = parsePrivateIdentifier(parser, context | 16, privateScope, 768);
8804
9190
  }
@@ -8808,7 +9194,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8808
9194
  else if (isStatic && token === 2162700) {
8809
9195
  return parseStaticBlock(parser, context | 16, scope, privateScope, start);
8810
9196
  }
8811
- else if (token === -2147483527) {
9197
+ else if (token === -2147483526) {
8812
9198
  key = parseIdentifier(parser, context);
8813
9199
  if (parser.getToken() !== 67174411)
8814
9200
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -8818,8 +9204,8 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8818
9204
  }
8819
9205
  if (kind & (8 | 16 | 768 | 1024)) {
8820
9206
  if (parser.getToken() & 143360 ||
8821
- parser.getToken() === -2147483528 ||
8822
- parser.getToken() === -2147483527) {
9207
+ parser.getToken() === -2147483527 ||
9208
+ parser.getToken() === -2147483526) {
8823
9209
  key = parseIdentifier(parser, context);
8824
9210
  }
8825
9211
  else if ((parser.getToken() & 134217728) === 134217728) {
@@ -8829,17 +9215,17 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8829
9215
  kind |= 2;
8830
9216
  key = parseComputedPropertyName(parser, context, privateScope, 0);
8831
9217
  }
8832
- else if (parser.getToken() === 130) {
9218
+ else if (parser.getToken() === 131) {
8833
9219
  kind |= 8192;
8834
9220
  key = parsePrivateIdentifier(parser, context, privateScope, kind);
8835
9221
  }
8836
9222
  else
8837
- parser.report(135);
9223
+ parser.report(137);
8838
9224
  }
8839
9225
  if ((kind & 2) === 0) {
8840
9226
  if (parser.tokenValue === 'constructor') {
8841
9227
  if ((parser.getToken() & 1073741824) === 1073741824) {
8842
- parser.report(129);
9228
+ parser.report(131);
8843
9229
  }
8844
9230
  else if ((kind & 32) === 0 && parser.getToken() === 67174411) {
8845
9231
  if (kind & (768 | 16 | 128 | 8)) {
@@ -8877,7 +9263,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
8877
9263
  computed: (kind & 2) > 0,
8878
9264
  key,
8879
9265
  value,
8880
- ...(parser.options.next ? { decorators } : null),
9266
+ ...(parser.features & 1 ? { decorators } : null),
8881
9267
  }, start);
8882
9268
  }
8883
9269
  function parsePrivateIdentifier(parser, context, privateScope, kind) {
@@ -8885,7 +9271,7 @@ function parsePrivateIdentifier(parser, context, privateScope, kind) {
8885
9271
  nextToken(parser, context);
8886
9272
  const { tokenValue } = parser;
8887
9273
  if (tokenValue === 'constructor')
8888
- parser.report(128);
9274
+ parser.report(130);
8889
9275
  if (parser.options.lexical) {
8890
9276
  if (!privateScope)
8891
9277
  parser.report(4, tokenValue);
@@ -8909,8 +9295,8 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
8909
9295
  if (parser.getToken() === 1077936155) {
8910
9296
  nextToken(parser, context | 32);
8911
9297
  const { tokenStart } = parser;
8912
- if (parser.getToken() === 537079927)
8913
- parser.report(119);
9298
+ if (parser.getToken() === 537079928)
9299
+ parser.report(121);
8914
9300
  const modifierFlags = 1024 |
8915
9301
  2048 |
8916
9302
  8192 |
@@ -8936,12 +9322,12 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
8936
9322
  value,
8937
9323
  static: (state & 32) > 0,
8938
9324
  computed: (state & 2) > 0,
8939
- ...(parser.options.next ? { decorators } : null),
9325
+ ...(parser.features & 1 ? { decorators } : null),
8940
9326
  }, start);
8941
9327
  }
8942
9328
  function parseBindingPattern(parser, context, scope, privateScope, type, origin) {
8943
9329
  if (parser.getToken() & 143360 ||
8944
- ((context & 1) === 0 && parser.getToken() === -2147483527))
9330
+ ((context & 1) === 0 && parser.getToken() === -2147483526))
8945
9331
  return parseAndClassifyIdentifier(parser, context, scope, type, origin);
8946
9332
  if ((parser.getToken() & 2097152) !== 2097152)
8947
9333
  parser.report(30, KeywordDescTable[parser.getToken() & 255]);
@@ -8958,10 +9344,10 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
8958
9344
  const token = parser.getToken();
8959
9345
  if (context & 1) {
8960
9346
  if ((token & 537079808) === 537079808) {
8961
- parser.report(119);
9347
+ parser.report(121);
8962
9348
  }
8963
- else if ((token & 36864) === 36864 || token === -2147483527) {
8964
- parser.report(118);
9349
+ else if ((token & 36864) === 36864 || token === -2147483526) {
9350
+ parser.report(120);
8965
9351
  }
8966
9352
  }
8967
9353
  if ((token & 20480) === 20480) {
@@ -8971,7 +9357,7 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
8971
9357
  if (context & 1024)
8972
9358
  parser.report(32);
8973
9359
  if (context & 2)
8974
- parser.report(111);
9360
+ parser.report(113);
8975
9361
  }
8976
9362
  if ((token & 255) === (241737 & 255)) {
8977
9363
  if (kind & (8 | 16))
@@ -8979,9 +9365,9 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
8979
9365
  }
8980
9366
  if (token === 209006) {
8981
9367
  if (context & 2048)
8982
- parser.report(176);
9368
+ parser.report(178);
8983
9369
  if (context & 2)
8984
- parser.report(110);
9370
+ parser.report(112);
8985
9371
  }
8986
9372
  const { tokenValue, tokenStart: start } = parser;
8987
9373
  nextToken(parser, context);
@@ -9013,7 +9399,7 @@ function parseJSXRootElementOrFragment(parser, context, privateScope, inJSXChild
9013
9399
  [children, closingElement] = parseJSXChildrenAndClosingElement(parser, context, privateScope, inJSXChild);
9014
9400
  const close = isEqualTagName(closingElement.name);
9015
9401
  if (isEqualTagName(openingElement.name) !== close)
9016
- parser.report(155, close);
9402
+ parser.report(157, close);
9017
9403
  }
9018
9404
  return parser.finishNode({
9019
9405
  type: 'JSXElement',
@@ -9081,7 +9467,7 @@ function parseJSXChildrenAndClosingFragment(parser, context, privateScope, inJSX
9081
9467
  }
9082
9468
  }
9083
9469
  function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
9084
- if (parser.getToken() === 137)
9470
+ if (parser.getToken() === 138)
9085
9471
  return parseJSXText(parser, context);
9086
9472
  if (parser.getToken() === 2162700)
9087
9473
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
@@ -9095,7 +9481,7 @@ function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild
9095
9481
  parser.report(0);
9096
9482
  }
9097
9483
  function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
9098
- if (parser.getToken() === 137)
9484
+ if (parser.getToken() === 138)
9099
9485
  return parseJSXText(parser, context);
9100
9486
  if (parser.getToken() === 2162700)
9101
9487
  return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
@@ -9208,7 +9594,7 @@ function parseJsxAttribute(parser, context, privateScope) {
9208
9594
  value = parseJSXExpressionContainer(parser, context, privateScope, 0, 1);
9209
9595
  break;
9210
9596
  default:
9211
- parser.report(154);
9597
+ parser.report(156);
9212
9598
  }
9213
9599
  }
9214
9600
  return parser.finishNode({
@@ -9235,7 +9621,7 @@ function parseJSXExpressionContainer(parser, context, privateScope, inJSXChild,
9235
9621
  let expression;
9236
9622
  if (parser.getToken() === 1074790415) {
9237
9623
  if (isAttr)
9238
- parser.report(157);
9624
+ parser.report(159);
9239
9625
  expression = parseJSXEmptyExpression(parser, {
9240
9626
  index: parser.startIndex,
9241
9627
  line: parser.startLine,