meriyah 4.2.1 → 4.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.
@@ -869,7 +869,7 @@
869
869
  break;
870
870
  case 117:
871
871
  if (mask & 16)
872
- report(parser, 34, 'g');
872
+ report(parser, 34, 'u');
873
873
  mask |= 16;
874
874
  break;
875
875
  case 121:
@@ -882,6 +882,11 @@
882
882
  report(parser, 34, 's');
883
883
  mask |= 32;
884
884
  break;
885
+ case 100:
886
+ if (mask & 64)
887
+ report(parser, 34, 'd');
888
+ mask |= 64;
889
+ break;
885
890
  default:
886
891
  report(parser, 33);
887
892
  }
@@ -900,7 +905,13 @@
900
905
  return new RegExp(pattern, flags);
901
906
  }
902
907
  catch (e) {
903
- report(parser, 32);
908
+ try {
909
+ new RegExp(pattern, flags.replace('d', ''));
910
+ return null;
911
+ }
912
+ catch (e) {
913
+ report(parser, 32);
914
+ }
904
915
  }
905
916
  }
906
917
 
@@ -1211,8 +1222,8 @@
1211
1222
  digits++;
1212
1223
  char = advanceChar(parser);
1213
1224
  }
1214
- if (digits < 1 || !allowSeparator) {
1215
- report(parser, digits < 1 ? 19 : 147);
1225
+ if (digits === 0 || !allowSeparator) {
1226
+ report(parser, digits === 0 ? 19 : 147);
1216
1227
  }
1217
1228
  }
1218
1229
  else if ((char | 32) === 111) {
@@ -1232,8 +1243,8 @@
1232
1243
  digits++;
1233
1244
  char = advanceChar(parser);
1234
1245
  }
1235
- if (digits < 1 || !allowSeparator) {
1236
- report(parser, digits < 1 ? 0 : 147);
1246
+ if (digits === 0 || !allowSeparator) {
1247
+ report(parser, digits === 0 ? 0 : 147);
1237
1248
  }
1238
1249
  }
1239
1250
  else if ((char | 32) === 98) {
@@ -1253,8 +1264,8 @@
1253
1264
  digits++;
1254
1265
  char = advanceChar(parser);
1255
1266
  }
1256
- if (digits < 1 || !allowSeparator) {
1257
- report(parser, digits < 1 ? 0 : 147);
1267
+ if (digits === 0 || !allowSeparator) {
1268
+ report(parser, digits === 0 ? 0 : 147);
1258
1269
  }
1259
1270
  }
1260
1271
  else if (CharTypes[char] & 32) {
@@ -1330,7 +1341,7 @@
1330
1341
  if (CharTypes[char] & 256)
1331
1342
  char = advanceChar(parser);
1332
1343
  const { index } = parser;
1333
- if ((CharTypes[char] & 16) < 1)
1344
+ if ((CharTypes[char] & 16) === 0)
1334
1345
  report(parser, 10);
1335
1346
  value += parser.source.substring(end, index) + scanDecimalDigitsOrSeparator(parser, char);
1336
1347
  char = parser.currentChar;
@@ -1811,7 +1822,7 @@
1811
1822
  return 8456258;
1812
1823
  }
1813
1824
  if (ch === 47) {
1814
- if ((context & 16) < 1)
1825
+ if ((context & 16) === 0)
1815
1826
  return 8456258;
1816
1827
  const index = parser.index + 1;
1817
1828
  if (index < parser.end) {
@@ -4917,7 +4928,7 @@
4917
4928
  case 86106:
4918
4929
  report(parser, context & 1024
4919
4930
  ? 73
4920
- : (context & 256) < 1
4931
+ : (context & 256) === 0
4921
4932
  ? 75
4922
4933
  : 74);
4923
4934
  case 86096:
@@ -4963,7 +4974,7 @@
4963
4974
  });
4964
4975
  }
4965
4976
  function parseReturnStatement(parser, context, start, line, column) {
4966
- if ((context & 32) < 1 && context & 8192)
4977
+ if ((context & 32) === 0 && context & 8192)
4967
4978
  report(parser, 89);
4968
4979
  nextToken(parser, context | 32768);
4969
4980
  const argument = parser.flags & 1 || parser.token & 1048576
@@ -4987,7 +4998,7 @@
4987
4998
  validateAndDeclareLabel(parser, labels, value);
4988
4999
  nextToken(parser, context | 32768);
4989
5000
  const body = allowFuncDecl &&
4990
- (context & 1024) < 1 &&
5001
+ (context & 1024) === 0 &&
4991
5002
  context & 256 &&
4992
5003
  parser.token === 86106
4993
5004
  ? parseFunctionDeclaration(parser, context, addChildScope(scope, 2), origin, 0, 0, 0, parser.tokenPos, parser.linePos, parser.colPos)
@@ -5096,7 +5107,7 @@
5096
5107
  }
5097
5108
  function parseConsequentOrAlternative(parser, context, scope, labels, start, line, column) {
5098
5109
  return context & 1024 ||
5099
- (context & 256) < 1 ||
5110
+ (context & 256) === 0 ||
5100
5111
  parser.token !== 86106
5101
5112
  ? parseStatement(parser, context, scope, 0, { $: labels }, 0, parser.tokenPos, parser.linePos, parser.colPos)
5102
5113
  : parseFunctionDeclaration(parser, context, addChildScope(scope, 2), 0, 0, 0, 0, start, line, column);
@@ -5161,11 +5172,11 @@
5161
5172
  return parseStatement(parser, ((context | 134217728) ^ 134217728) | 131072, scope, 0, { loop: 1, $: labels }, 0, parser.tokenPos, parser.linePos, parser.colPos);
5162
5173
  }
5163
5174
  function parseContinueStatement(parser, context, labels, start, line, column) {
5164
- if ((context & 131072) < 1)
5175
+ if ((context & 131072) === 0)
5165
5176
  report(parser, 65);
5166
5177
  nextToken(parser, context);
5167
5178
  let label = null;
5168
- if ((parser.flags & 1) < 1 && parser.token & 143360) {
5179
+ if ((parser.flags & 1) === 0 && parser.token & 143360) {
5169
5180
  const { tokenValue } = parser;
5170
5181
  label = parseIdentifier(parser, context | 32768, 0);
5171
5182
  if (!isValidLabel(parser, labels, tokenValue, 1))
@@ -5180,13 +5191,13 @@
5180
5191
  function parseBreakStatement(parser, context, labels, start, line, column) {
5181
5192
  nextToken(parser, context | 32768);
5182
5193
  let label = null;
5183
- if ((parser.flags & 1) < 1 && parser.token & 143360) {
5194
+ if ((parser.flags & 1) === 0 && parser.token & 143360) {
5184
5195
  const { tokenValue } = parser;
5185
5196
  label = parseIdentifier(parser, context | 32768, 0);
5186
5197
  if (!isValidLabel(parser, labels, tokenValue, 0))
5187
5198
  report(parser, 134, tokenValue);
5188
5199
  }
5189
- else if ((context & (4096 | 131072)) < 1) {
5200
+ else if ((context & (4096 | 131072)) === 0) {
5190
5201
  report(parser, 66);
5191
5202
  }
5192
5203
  matchOrInsertSemicolon(parser, context | 32768);
@@ -5266,6 +5277,17 @@
5266
5277
  body
5267
5278
  });
5268
5279
  }
5280
+ function parseStaticBlock(parser, context, scope, start, line, column) {
5281
+ if (scope)
5282
+ scope = addChildScope(scope, 2);
5283
+ const ctorContext = 16384 | 524288;
5284
+ context = ((context | ctorContext) ^ ctorContext) | 262144;
5285
+ const { body } = parseBlock(parser, context, scope, {}, start, line, column);
5286
+ return finishNode(parser, context, start, line, column, {
5287
+ type: 'StaticBlock',
5288
+ body
5289
+ });
5290
+ }
5269
5291
  function parseDoWhileStatement(parser, context, scope, labels, start, line, column) {
5270
5292
  nextToken(parser, context | 32768);
5271
5293
  const body = parseIterationStatementBody(parser, context, scope, labels);
@@ -5353,10 +5375,10 @@
5353
5375
  if (parser.token === 1077936157) {
5354
5376
  nextToken(parser, context | 32768);
5355
5377
  init = parseExpression(parser, context, 1, 0, 0, parser.tokenPos, parser.linePos, parser.colPos);
5356
- if (origin & 32 || (token & 2097152) < 1) {
5378
+ if (origin & 32 || (token & 2097152) === 0) {
5357
5379
  if (parser.token === 274549 ||
5358
5380
  (parser.token === 8738868 &&
5359
- (token & 2097152 || (kind & 4) < 1 || context & 1024))) {
5381
+ (token & 2097152 || (kind & 4) === 0 || context & 1024))) {
5360
5382
  reportMessageAt(tokenPos, parser.line, parser.index - 3, 57, parser.token === 274549 ? 'of' : 'in');
5361
5383
  }
5362
5384
  }
@@ -5373,7 +5395,8 @@
5373
5395
  }
5374
5396
  function parseForStatement(parser, context, scope, labels, start, line, column) {
5375
5397
  nextToken(parser, context);
5376
- const forAwait = (context & 4194304) > 0 && consumeOpt(parser, context, 209008);
5398
+ const forAwait = ((context & 4194304) > 0 || ((context & 2048) > 0 && (context & 8192) > 0)) &&
5399
+ consumeOpt(parser, context, 209008);
5377
5400
  consume(parser, context | 32768, 67174411);
5378
5401
  if (scope)
5379
5402
  scope = addChildScope(scope, 1);
@@ -5662,7 +5685,7 @@
5662
5685
  const { tokenPos, linePos, colPos } = parser;
5663
5686
  declaration = parseIdentifier(parser, context, 0);
5664
5687
  const { flags } = parser;
5665
- if ((flags & 1) < 1) {
5688
+ if ((flags & 1) === 0) {
5666
5689
  if (parser.token === 86106) {
5667
5690
  declaration = parseFunctionDeclaration(parser, context, scope, 4, 1, 1, 1, tokenPos, linePos, colPos);
5668
5691
  }
@@ -5786,7 +5809,7 @@
5786
5809
  case 209007:
5787
5810
  const { tokenPos, linePos, colPos } = parser;
5788
5811
  nextToken(parser, context);
5789
- if ((parser.flags & 1) < 1 && parser.token === 86106) {
5812
+ if ((parser.flags & 1) === 0 && parser.token === 86106) {
5790
5813
  declaration = parseFunctionDeclaration(parser, context, scope, 4, 1, 2, 1, tokenPos, linePos, colPos);
5791
5814
  if (scope) {
5792
5815
  key = declaration.id ? declaration.id.name : '';
@@ -5943,7 +5966,7 @@
5943
5966
  const { token } = parser;
5944
5967
  const expr = parseIdentifier(parser, context, isPattern);
5945
5968
  const { flags } = parser;
5946
- if ((flags & 1) < 1) {
5969
+ if ((flags & 1) === 0) {
5947
5970
  if (parser.token === 86106) {
5948
5971
  return parseFunctionExpression(parser, context, 1, inGroup, start, line, column);
5949
5972
  }
@@ -5977,7 +6000,7 @@
5977
6000
  report(parser, 120);
5978
6001
  let argument = null;
5979
6002
  let delegate = false;
5980
- if ((parser.flags & 1) < 1) {
6003
+ if ((parser.flags & 1) === 0) {
5981
6004
  delegate = consumeOpt(parser, context | 32768, 8457014);
5982
6005
  if (parser.token & (12288 | 65536) || delegate) {
5983
6006
  argument = parseExpression(parser, context, 1, 0, 0, parser.tokenPos, parser.linePos, parser.colPos);
@@ -6054,8 +6077,8 @@
6054
6077
  if (context & 64 &&
6055
6078
  scope &&
6056
6079
  scopeError !== void 0 &&
6057
- (prevContext & 1024) < 1 &&
6058
- (context & 8192) < 1) {
6080
+ (prevContext & 1024) === 0 &&
6081
+ (context & 8192) === 0) {
6059
6082
  reportScopeError(scopeError);
6060
6083
  }
6061
6084
  }
@@ -6081,7 +6104,7 @@
6081
6104
  case 67108991:
6082
6105
  report(parser, 161);
6083
6106
  case 67174411: {
6084
- if ((context & 524288) < 1)
6107
+ if ((context & 524288) === 0)
6085
6108
  report(parser, 26);
6086
6109
  if (context & 16384)
6087
6110
  report(parser, 27);
@@ -6090,7 +6113,7 @@
6090
6113
  }
6091
6114
  case 69271571:
6092
6115
  case 67108877: {
6093
- if ((context & 262144) < 1)
6116
+ if ((context & 262144) === 0)
6094
6117
  report(parser, 27);
6095
6118
  if (context & 16384)
6096
6119
  report(parser, 27);
@@ -6120,7 +6143,7 @@
6120
6143
  });
6121
6144
  }
6122
6145
  function parseMemberOrUpdateExpression(parser, context, expr, inGroup, inChain, start, line, column) {
6123
- if ((parser.token & 33619968) === 33619968 && (parser.flags & 1) < 1) {
6146
+ if ((parser.token & 33619968) === 33619968 && (parser.flags & 1) === 0) {
6124
6147
  expr = parseUpdateExpression(parser, context, expr, start, line, column);
6125
6148
  }
6126
6149
  else if ((parser.token & 67108864) === 67108864) {
@@ -6247,7 +6270,7 @@
6247
6270
  });
6248
6271
  }
6249
6272
  else {
6250
- if ((parser.token & (143360 | 4096)) < 1)
6273
+ if ((parser.token & (143360 | 4096)) === 0)
6251
6274
  report(parser, 154);
6252
6275
  const property = parseIdentifier(parser, context, 0);
6253
6276
  parser.assignable = 2;
@@ -6265,7 +6288,7 @@
6265
6288
  return node;
6266
6289
  }
6267
6290
  function parsePropertyOrPrivatePropertyName(parser, context) {
6268
- if ((parser.token & (143360 | 4096)) < 1 && parser.token !== 131) {
6291
+ if ((parser.token & (143360 | 4096)) === 0 && parser.token !== 131) {
6269
6292
  report(parser, 154);
6270
6293
  }
6271
6294
  return context & 1 && parser.token === 131
@@ -6590,11 +6613,11 @@
6590
6613
  let firstRestricted;
6591
6614
  let functionScope = scope ? createScope() : void 0;
6592
6615
  if (parser.token === 67174411) {
6593
- if ((flags & 1) < 1)
6616
+ if ((flags & 1) === 0)
6594
6617
  report(parser, 37, 'Function');
6595
6618
  }
6596
6619
  else {
6597
- const kind = origin & 4 && ((context & 8192) < 1 || (context & 2048) < 1)
6620
+ const kind = origin & 4 && ((context & 8192) === 0 || (context & 2048) === 0)
6598
6621
  ? 4
6599
6622
  : 64;
6600
6623
  validateFunctionName(parser, context | ((context & 3072) << 11), parser.token);
@@ -6740,7 +6763,7 @@
6740
6763
  destructible |=
6741
6764
  kind & 1
6742
6765
  ? 32
6743
- : (kind & 2) < 1
6766
+ : (kind & 2) === 0
6744
6767
  ? 16
6745
6768
  : 0;
6746
6769
  left = parseMemberOrUpdateExpression(parser, context, left, inGroup, 0, tokenPos, linePos, colPos);
@@ -6799,7 +6822,7 @@
6799
6822
  left = parseLeftHandSideExpression(parser, context, 1, 0, 1, tokenPos, linePos, colPos);
6800
6823
  if (parser.token !== 18 && parser.token !== 20) {
6801
6824
  left = parseAssignmentExpression(parser, context, inGroup, isPattern, tokenPos, linePos, colPos, left);
6802
- if ((kind & (2 | 1)) < 1 && token === 67174411)
6825
+ if ((kind & (2 | 1)) === 0 && token === 67174411)
6803
6826
  destructible |= 16;
6804
6827
  }
6805
6828
  else if (parser.assignable & 2) {
@@ -6988,7 +7011,7 @@
6988
7011
  });
6989
7012
  }
6990
7013
  function parseMethodDefinition(parser, context, kind, inGroup, start, line, column) {
6991
- const modifierFlags = (kind & 64) < 1 ? 31981568 : 14680064;
7014
+ const modifierFlags = (kind & 64) === 0 ? 31981568 : 14680064;
6992
7015
  context =
6993
7016
  ((context | modifierFlags) ^ modifierFlags) |
6994
7017
  ((kind & 88) << 18) |
@@ -7556,7 +7579,7 @@
7556
7579
  let left = null;
7557
7580
  const { tokenPos, linePos, colPos } = parser;
7558
7581
  if (parser.token & 143360) {
7559
- if ((context & 1024) < 1) {
7582
+ if ((context & 1024) === 0) {
7560
7583
  if ((parser.token & 36864) === 36864) {
7561
7584
  parser.flags |= 256;
7562
7585
  }
@@ -7817,7 +7840,7 @@
7817
7840
  (134221824 | 8192 | 16384), scope, 16, void 0, void 0);
7818
7841
  switch (parser.token) {
7819
7842
  case 69271571:
7820
- if ((parser.flags & 1) < 1) {
7843
+ if ((parser.flags & 1) === 0) {
7821
7844
  report(parser, 112);
7822
7845
  }
7823
7846
  break;
@@ -7826,13 +7849,13 @@
7826
7849
  case 22:
7827
7850
  report(parser, 113);
7828
7851
  case 67174411:
7829
- if ((parser.flags & 1) < 1) {
7852
+ if ((parser.flags & 1) === 0) {
7830
7853
  report(parser, 112);
7831
7854
  }
7832
7855
  parser.flags |= 1024;
7833
7856
  break;
7834
7857
  }
7835
- if ((parser.token & 8454144) === 8454144 && (parser.flags & 1) < 1)
7858
+ if ((parser.token & 8454144) === 8454144 && (parser.flags & 1) === 0)
7836
7859
  report(parser, 28, KeywordDescTable[parser.token & 255]);
7837
7860
  if ((parser.token & 33619968) === 33619968)
7838
7861
  report(parser, 121);
@@ -7858,7 +7881,7 @@
7858
7881
  let left;
7859
7882
  const { tokenPos, linePos, colPos } = parser;
7860
7883
  if (parser.token & 143360) {
7861
- if ((context & 1024) < 1) {
7884
+ if ((context & 1024) === 0) {
7862
7885
  if ((parser.token & 36864) === 36864) {
7863
7886
  parser.flags |= 256;
7864
7887
  }
@@ -8178,7 +8201,7 @@
8178
8201
  id = parseIdentifier(parser, context, 0);
8179
8202
  }
8180
8203
  else {
8181
- if ((flags & 1) < 1)
8204
+ if ((flags & 1) === 0)
8182
8205
  report(parser, 37, 'Class');
8183
8206
  }
8184
8207
  let inheritedContext = context;
@@ -8309,7 +8332,7 @@
8309
8332
  }
8310
8333
  break;
8311
8334
  case 209007:
8312
- if (parser.token !== 67174411 && (parser.flags & 1) < 1) {
8335
+ if (parser.token !== 67174411 && (parser.flags & 1) === 0) {
8313
8336
  if (context & 1 && (parser.token & 1073741824) === 1073741824) {
8314
8337
  return parsePropertyDefinition(parser, context, key, kind, decorators, tokenPos, linePos, colPos);
8315
8338
  }
@@ -8352,6 +8375,9 @@
8352
8375
  else if (context & 1 && (parser.token & 1073741824) === 1073741824) {
8353
8376
  kind |= 128;
8354
8377
  }
8378
+ else if (isStatic && token === 2162700) {
8379
+ return parseStaticBlock(parser, context, scope, tokenPos, linePos, colPos);
8380
+ }
8355
8381
  else if (token === 122) {
8356
8382
  key = parseIdentifier(parser, context, 0);
8357
8383
  if (parser.token !== 67174411)
@@ -8381,16 +8407,16 @@
8381
8407
  else
8382
8408
  report(parser, 131);
8383
8409
  }
8384
- if ((kind & 2) < 1) {
8410
+ if ((kind & 2) === 0) {
8385
8411
  if (parser.tokenValue === 'constructor') {
8386
8412
  if ((parser.token & 1073741824) === 1073741824) {
8387
8413
  report(parser, 125);
8388
8414
  }
8389
- else if ((kind & 32) < 1 && parser.token === 67174411) {
8415
+ else if ((kind & 32) === 0 && parser.token === 67174411) {
8390
8416
  if (kind & (768 | 16 | 128 | 8)) {
8391
8417
  report(parser, 50, 'accessor');
8392
8418
  }
8393
- else if ((context & 524288) < 1) {
8419
+ else if ((context & 524288) === 0) {
8394
8420
  if (parser.flags & 32)
8395
8421
  report(parser, 51);
8396
8422
  else
@@ -8399,7 +8425,7 @@
8399
8425
  }
8400
8426
  kind |= 64;
8401
8427
  }
8402
- else if ((kind & 4096) < 1 &&
8428
+ else if ((kind & 4096) === 0 &&
8403
8429
  kind & (32 | 768 | 8 | 16) &&
8404
8430
  parser.tokenValue === 'prototype') {
8405
8431
  report(parser, 49);
@@ -8412,7 +8438,7 @@
8412
8438
  return finishNode(parser, context, start, line, column, context & 1
8413
8439
  ? {
8414
8440
  type: 'MethodDefinition',
8415
- kind: (kind & 32) < 1 && kind & 64
8441
+ kind: (kind & 32) === 0 && kind & 64
8416
8442
  ? 'constructor'
8417
8443
  : kind & 256
8418
8444
  ? 'get'
@@ -8427,7 +8453,7 @@
8427
8453
  }
8428
8454
  : {
8429
8455
  type: 'MethodDefinition',
8430
- kind: (kind & 32) < 1 && kind & 64
8456
+ kind: (kind & 32) === 0 && kind & 64
8431
8457
  ? 'constructor'
8432
8458
  : kind & 256
8433
8459
  ? 'get'
@@ -8770,7 +8796,7 @@
8770
8796
  __proto__: null
8771
8797
  });
8772
8798
 
8773
- var version$1 = "4.2.1";
8799
+ var version$1 = "4.3.0";
8774
8800
 
8775
8801
  const version = version$1;
8776
8802
  function parseScript(source, options) {