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