meriyah 4.1.5 → 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.
- package/CHANGELOG.md +45 -0
- package/README.md +2 -1
- package/dist/meriyah.amd.js +96 -72
- package/dist/meriyah.amd.min.js +1 -1
- package/dist/meriyah.cjs +94 -70
- package/dist/meriyah.cjs.js +94 -70
- package/dist/meriyah.cjs.min.js +1 -1
- package/dist/meriyah.esm.js +94 -70
- package/dist/meriyah.esm.min.js +1 -1
- package/dist/meriyah.esm.min.mjs +1 -0
- package/dist/meriyah.esm.mjs +8806 -0
- package/dist/meriyah.iife.js +95 -71
- package/dist/meriyah.iife.min.js +1 -1
- package/dist/meriyah.min.cjs +1 -1
- package/dist/meriyah.system.js +98 -74
- package/dist/meriyah.system.min.js +1 -1
- package/dist/meriyah.umd.cjs +96 -72
- package/dist/meriyah.umd.es5.js +108 -80
- package/dist/meriyah.umd.es5.min.js +1 -15
- package/dist/meriyah.umd.js +96 -72
- package/dist/meriyah.umd.min.cjs +1 -1
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/estree.d.ts +9 -4
- package/dist/src/estree.d.ts.map +1 -1
- package/dist/src/lexer/regexp.d.ts.map +1 -1
- package/dist/src/parser.d.ts +1 -0
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/token.d.ts +2 -2
- package/package.json +25 -30
- package/src/errors.ts +0 -2
- package/src/estree.ts +11 -3
- package/src/lexer/numeric.ts +7 -7
- package/src/lexer/regexp.ts +22 -9
- package/src/lexer/scan.ts +1 -1
- package/src/parser.ts +94 -56
- package/src/token.ts +2 -2
package/src/parser.ts
CHANGED
|
@@ -613,7 +613,7 @@ export function parseStatement(
|
|
|
613
613
|
parser,
|
|
614
614
|
context & Context.Strict
|
|
615
615
|
? Errors.StrictFunction
|
|
616
|
-
: (context & Context.OptionsWebCompat)
|
|
616
|
+
: (context & Context.OptionsWebCompat) === 0
|
|
617
617
|
? Errors.WebCompatFunction
|
|
618
618
|
: Errors.SloppyFunction
|
|
619
619
|
);
|
|
@@ -827,14 +827,14 @@ export function parseReturnStatement(
|
|
|
827
827
|
): ESTree.ReturnStatement {
|
|
828
828
|
// ReturnStatement ::
|
|
829
829
|
// 'return' [no line terminator] Expression? ';'
|
|
830
|
-
if ((context & Context.OptionsGlobalReturn)
|
|
830
|
+
if ((context & Context.OptionsGlobalReturn) === 0 && context & Context.InGlobal) report(parser, Errors.IllegalReturn);
|
|
831
831
|
|
|
832
832
|
nextToken(parser, context | Context.AllowRegExp);
|
|
833
833
|
|
|
834
834
|
const argument =
|
|
835
835
|
parser.flags & Flags.NewLine || parser.token & Token.IsAutoSemicolon
|
|
836
836
|
? null
|
|
837
|
-
: parseExpressions(parser, context, 0, 1, parser.tokenPos, parser.
|
|
837
|
+
: parseExpressions(parser, context, 0, 1, parser.tokenPos, parser.linePos, parser.colPos);
|
|
838
838
|
|
|
839
839
|
matchOrInsertSemicolon(parser, context | Context.AllowRegExp);
|
|
840
840
|
|
|
@@ -909,7 +909,7 @@ export function parseLabelledStatement(
|
|
|
909
909
|
|
|
910
910
|
const body =
|
|
911
911
|
allowFuncDecl &&
|
|
912
|
-
(context & Context.Strict)
|
|
912
|
+
(context & Context.Strict) === 0 &&
|
|
913
913
|
context & Context.OptionsWebCompat &&
|
|
914
914
|
// In sloppy mode, Annex B.3.2 allows labelled function declarations.
|
|
915
915
|
// Otherwise it's a parse error.
|
|
@@ -1310,7 +1310,7 @@ export function parseConsequentOrAlternative(
|
|
|
1310
1310
|
): ESTree.Statement | ESTree.FunctionDeclaration {
|
|
1311
1311
|
return context & Context.Strict ||
|
|
1312
1312
|
// Disallow if web compatibility is off
|
|
1313
|
-
(context & Context.OptionsWebCompat)
|
|
1313
|
+
(context & Context.OptionsWebCompat) === 0 ||
|
|
1314
1314
|
parser.token !== Token.FunctionKeyword
|
|
1315
1315
|
? parseStatement(
|
|
1316
1316
|
parser,
|
|
@@ -1494,10 +1494,10 @@ export function parseContinueStatement(
|
|
|
1494
1494
|
): ESTree.ContinueStatement {
|
|
1495
1495
|
// ContinueStatement ::
|
|
1496
1496
|
// 'continue' Identifier? ';'
|
|
1497
|
-
if ((context & Context.InIteration)
|
|
1497
|
+
if ((context & Context.InIteration) === 0) report(parser, Errors.IllegalContinue);
|
|
1498
1498
|
nextToken(parser, context);
|
|
1499
1499
|
let label: ESTree.Identifier | undefined | null = null;
|
|
1500
|
-
if ((parser.flags & Flags.NewLine)
|
|
1500
|
+
if ((parser.flags & Flags.NewLine) === 0 && parser.token & Token.IsIdentifier) {
|
|
1501
1501
|
const { tokenValue } = parser;
|
|
1502
1502
|
label = parseIdentifier(parser, context | Context.AllowRegExp, 0);
|
|
1503
1503
|
if (!isValidLabel(parser, labels, tokenValue, /* requireIterationStatement */ 1))
|
|
@@ -1533,12 +1533,12 @@ export function parseBreakStatement(
|
|
|
1533
1533
|
// 'break' Identifier? ';'
|
|
1534
1534
|
nextToken(parser, context | Context.AllowRegExp);
|
|
1535
1535
|
let label: ESTree.Identifier | undefined | null = null;
|
|
1536
|
-
if ((parser.flags & Flags.NewLine)
|
|
1536
|
+
if ((parser.flags & Flags.NewLine) === 0 && parser.token & Token.IsIdentifier) {
|
|
1537
1537
|
const { tokenValue } = parser;
|
|
1538
1538
|
label = parseIdentifier(parser, context | Context.AllowRegExp, 0);
|
|
1539
1539
|
if (!isValidLabel(parser, labels, tokenValue, /* requireIterationStatement */ 0))
|
|
1540
1540
|
report(parser, Errors.UnknownLabel, tokenValue);
|
|
1541
|
-
} else if ((context & (Context.InSwitch | Context.InIteration))
|
|
1541
|
+
} else if ((context & (Context.InSwitch | Context.InIteration)) === 0) {
|
|
1542
1542
|
report(parser, Errors.IllegalBreak);
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
@@ -1770,6 +1770,41 @@ export function parseCatchBlock(
|
|
|
1770
1770
|
});
|
|
1771
1771
|
}
|
|
1772
1772
|
|
|
1773
|
+
/**
|
|
1774
|
+
* Parses class static initialization block
|
|
1775
|
+
*
|
|
1776
|
+
* @see [Link](https://github.com/tc39/proposal-class-static-block)
|
|
1777
|
+
*
|
|
1778
|
+
* @param parser Parser object
|
|
1779
|
+
* @param context Context masks
|
|
1780
|
+
* @param scope Scope instance
|
|
1781
|
+
* @param start Start pos of node
|
|
1782
|
+
* @param line
|
|
1783
|
+
* @param column
|
|
1784
|
+
*/
|
|
1785
|
+
export function parseStaticBlock(
|
|
1786
|
+
parser: ParserState,
|
|
1787
|
+
context: Context,
|
|
1788
|
+
scope: ScopeState | undefined,
|
|
1789
|
+
start: number,
|
|
1790
|
+
line: number,
|
|
1791
|
+
column: number
|
|
1792
|
+
): ESTree.StaticBlock {
|
|
1793
|
+
// StaticBlock ::
|
|
1794
|
+
// '{' StatementList '}'
|
|
1795
|
+
|
|
1796
|
+
if (scope) scope = addChildScope(scope, ScopeKind.Block);
|
|
1797
|
+
|
|
1798
|
+
const ctorContext = Context.InClass | Context.SuperCall;
|
|
1799
|
+
context = ((context | ctorContext) ^ ctorContext) | Context.SuperProperty;
|
|
1800
|
+
const { body } = parseBlock(parser, context, scope, {}, start, line, column);
|
|
1801
|
+
|
|
1802
|
+
return finishNode(parser, context, start, line, column, {
|
|
1803
|
+
type: 'StaticBlock',
|
|
1804
|
+
body
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1773
1808
|
/**
|
|
1774
1809
|
* Parses do while statement
|
|
1775
1810
|
*
|
|
@@ -2072,13 +2107,13 @@ function parseVariableDeclaration(
|
|
|
2072
2107
|
if (parser.token === Token.Assign) {
|
|
2073
2108
|
nextToken(parser, context | Context.AllowRegExp);
|
|
2074
2109
|
init = parseExpression(parser, context, 1, 0, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
2075
|
-
if (origin & Origin.ForStatement || (token & Token.IsPatternStart)
|
|
2110
|
+
if (origin & Origin.ForStatement || (token & Token.IsPatternStart) === 0) {
|
|
2076
2111
|
// Lexical declarations in for-in / for-of loops can't be initialized
|
|
2077
2112
|
|
|
2078
2113
|
if (
|
|
2079
2114
|
parser.token === Token.OfKeyword ||
|
|
2080
2115
|
(parser.token === Token.InKeyword &&
|
|
2081
|
-
(token & Token.IsPatternStart || (kind & BindingKind.Variable)
|
|
2116
|
+
(token & Token.IsPatternStart || (kind & BindingKind.Variable) === 0 || context & Context.Strict))
|
|
2082
2117
|
) {
|
|
2083
2118
|
reportMessageAt(
|
|
2084
2119
|
tokenPos,
|
|
@@ -2128,7 +2163,9 @@ export function parseForStatement(
|
|
|
2128
2163
|
): ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement {
|
|
2129
2164
|
nextToken(parser, context);
|
|
2130
2165
|
|
|
2131
|
-
const forAwait =
|
|
2166
|
+
const forAwait =
|
|
2167
|
+
((context & Context.InAwaitContext) > 0 || ((context & Context.Module) > 0 && (context & Context.InGlobal) > 0)) &&
|
|
2168
|
+
consumeOpt(parser, context, Token.AwaitKeyword);
|
|
2132
2169
|
|
|
2133
2170
|
consume(parser, context | Context.AllowRegExp, Token.LeftParen);
|
|
2134
2171
|
|
|
@@ -2771,7 +2808,7 @@ function parseExportDeclaration(
|
|
|
2771
2808
|
|
|
2772
2809
|
const { flags } = parser;
|
|
2773
2810
|
|
|
2774
|
-
if ((flags & Flags.NewLine)
|
|
2811
|
+
if ((flags & Flags.NewLine) === 0) {
|
|
2775
2812
|
if (parser.token === Token.FunctionKeyword) {
|
|
2776
2813
|
declaration = parseFunctionDeclaration(
|
|
2777
2814
|
parser,
|
|
@@ -3030,7 +3067,7 @@ function parseExportDeclaration(
|
|
|
3030
3067
|
|
|
3031
3068
|
nextToken(parser, context);
|
|
3032
3069
|
|
|
3033
|
-
if ((parser.flags & Flags.NewLine)
|
|
3070
|
+
if ((parser.flags & Flags.NewLine) === 0 && parser.token === Token.FunctionKeyword) {
|
|
3034
3071
|
declaration = parseFunctionDeclaration(
|
|
3035
3072
|
parser,
|
|
3036
3073
|
context,
|
|
@@ -3488,7 +3525,7 @@ export function parseAsyncExpression(
|
|
|
3488
3525
|
const expr = parseIdentifier(parser, context, isPattern);
|
|
3489
3526
|
const { flags } = parser;
|
|
3490
3527
|
|
|
3491
|
-
if ((flags & Flags.NewLine)
|
|
3528
|
+
if ((flags & Flags.NewLine) === 0) {
|
|
3492
3529
|
// async function ...
|
|
3493
3530
|
if (parser.token === Token.FunctionKeyword) {
|
|
3494
3531
|
return parseFunctionExpression(parser, context, /* isAsync */ 1, inGroup, start, line, column);
|
|
@@ -3555,7 +3592,7 @@ export function parseYieldExpression(
|
|
|
3555
3592
|
let argument: ESTree.Expression | null = null;
|
|
3556
3593
|
let delegate = false; // yield*
|
|
3557
3594
|
|
|
3558
|
-
if ((parser.flags & Flags.NewLine)
|
|
3595
|
+
if ((parser.flags & Flags.NewLine) === 0) {
|
|
3559
3596
|
delegate = consumeOpt(parser, context | Context.AllowRegExp, Token.Multiply);
|
|
3560
3597
|
if (parser.token & (Token.Contextual | Token.IsExpressionStart) || delegate) {
|
|
3561
3598
|
argument = parseExpression(parser, context, 1, 0, 0, parser.tokenPos, parser.linePos, parser.colPos);
|
|
@@ -3593,7 +3630,7 @@ export function parseAwaitExpression(
|
|
|
3593
3630
|
column: number
|
|
3594
3631
|
): ESTree.IdentifierOrExpression | ESTree.AwaitExpression {
|
|
3595
3632
|
if (inGroup) parser.destructible |= DestructuringKind.Await;
|
|
3596
|
-
if (context & Context.InAwaitContext) {
|
|
3633
|
+
if (context & Context.InAwaitContext || (context & Context.Module && context & Context.InGlobal)) {
|
|
3597
3634
|
if (inNew) report(parser, Errors.Unexpected);
|
|
3598
3635
|
|
|
3599
3636
|
if (context & Context.InArgumentList) {
|
|
@@ -3613,6 +3650,8 @@ export function parseAwaitExpression(
|
|
|
3613
3650
|
parser.colPos
|
|
3614
3651
|
);
|
|
3615
3652
|
|
|
3653
|
+
if (parser.token === Token.Exponentiate) report(parser, Errors.InvalidExponentiationLHS);
|
|
3654
|
+
|
|
3616
3655
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3617
3656
|
|
|
3618
3657
|
return finishNode(parser, context, start, line, column, {
|
|
@@ -3621,8 +3660,7 @@ export function parseAwaitExpression(
|
|
|
3621
3660
|
});
|
|
3622
3661
|
}
|
|
3623
3662
|
|
|
3624
|
-
if (context & Context.Module) report(parser, Errors.
|
|
3625
|
-
|
|
3663
|
+
if (context & Context.Module) report(parser, Errors.AwaitOutsideAsync);
|
|
3626
3664
|
return parseIdentifierOrArrow(parser, context, start, line, column);
|
|
3627
3665
|
}
|
|
3628
3666
|
|
|
@@ -3687,8 +3725,8 @@ export function parseFunctionBody(
|
|
|
3687
3725
|
context & Context.OptionsLexical &&
|
|
3688
3726
|
scope &&
|
|
3689
3727
|
scopeError !== void 0 &&
|
|
3690
|
-
(prevContext & Context.Strict)
|
|
3691
|
-
(context & Context.InGlobal)
|
|
3728
|
+
(prevContext & Context.Strict) === 0 &&
|
|
3729
|
+
(context & Context.InGlobal) === 0
|
|
3692
3730
|
) {
|
|
3693
3731
|
reportScopeError(scopeError);
|
|
3694
3732
|
}
|
|
@@ -3740,8 +3778,8 @@ export function parseSuperExpression(
|
|
|
3740
3778
|
report(parser, Errors.OptionalChainingNoSuper);
|
|
3741
3779
|
case Token.LeftParen: {
|
|
3742
3780
|
// The super property has to be within a class constructor
|
|
3743
|
-
if ((context & Context.SuperCall)
|
|
3744
|
-
if (context & Context.InClass) report(parser, Errors.
|
|
3781
|
+
if ((context & Context.SuperCall) === 0) report(parser, Errors.SuperNoConstructor);
|
|
3782
|
+
if (context & Context.InClass) report(parser, Errors.InvalidSuperProperty);
|
|
3745
3783
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3746
3784
|
break;
|
|
3747
3785
|
}
|
|
@@ -3749,8 +3787,8 @@ export function parseSuperExpression(
|
|
|
3749
3787
|
case Token.Period: {
|
|
3750
3788
|
// new super() is never allowed.
|
|
3751
3789
|
// super() is only allowed in derived constructor
|
|
3752
|
-
if ((context & Context.SuperProperty)
|
|
3753
|
-
if (context & Context.InClass) report(parser, Errors.
|
|
3790
|
+
if ((context & Context.SuperProperty) === 0) report(parser, Errors.InvalidSuperProperty);
|
|
3791
|
+
if (context & Context.InClass) report(parser, Errors.InvalidSuperProperty);
|
|
3754
3792
|
parser.assignable = AssignmentKind.Assignable;
|
|
3755
3793
|
break;
|
|
3756
3794
|
}
|
|
@@ -3855,15 +3893,15 @@ export function parseMemberOrUpdateExpression(
|
|
|
3855
3893
|
line: number,
|
|
3856
3894
|
column: number
|
|
3857
3895
|
): any {
|
|
3858
|
-
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp && (parser.flags & Flags.NewLine)
|
|
3896
|
+
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp && (parser.flags & Flags.NewLine) === 0) {
|
|
3859
3897
|
expr = parseUpdateExpression(parser, context, expr, start, line, column);
|
|
3860
3898
|
} else if ((parser.token & Token.IsMemberOrCallExpression) === Token.IsMemberOrCallExpression) {
|
|
3861
|
-
context = (context | Context.DisallowIn
|
|
3899
|
+
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
3862
3900
|
|
|
3863
3901
|
switch (parser.token) {
|
|
3864
3902
|
/* Property */
|
|
3865
3903
|
case Token.Period: {
|
|
3866
|
-
nextToken(parser, context | Context.AllowEscapedKeyword);
|
|
3904
|
+
nextToken(parser, (context | Context.AllowEscapedKeyword | Context.InGlobal) ^ Context.InGlobal);
|
|
3867
3905
|
|
|
3868
3906
|
parser.assignable = AssignmentKind.Assignable;
|
|
3869
3907
|
|
|
@@ -3939,7 +3977,7 @@ export function parseMemberOrUpdateExpression(
|
|
|
3939
3977
|
|
|
3940
3978
|
/* Optional chaining */
|
|
3941
3979
|
case Token.QuestionMarkPeriod: {
|
|
3942
|
-
nextToken(parser, context); // skips: '?.'
|
|
3980
|
+
nextToken(parser, (context | Context.AllowEscapedKeyword | Context.InGlobal) ^ Context.InGlobal); // skips: '?.'
|
|
3943
3981
|
parser.flags |= Flags.HasOptionalChaining;
|
|
3944
3982
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
3945
3983
|
expr = parseOptionalChain(parser, context, expr, start, line, column);
|
|
@@ -4028,7 +4066,7 @@ export function parseOptionalChain(
|
|
|
4028
4066
|
optional: true
|
|
4029
4067
|
});
|
|
4030
4068
|
} else {
|
|
4031
|
-
if ((parser.token & (Token.IsIdentifier | Token.Keyword))
|
|
4069
|
+
if ((parser.token & (Token.IsIdentifier | Token.Keyword)) === 0) report(parser, Errors.InvalidDotProperty);
|
|
4032
4070
|
const property = parseIdentifier(parser, context, 0);
|
|
4033
4071
|
parser.assignable = AssignmentKind.CannotAssign;
|
|
4034
4072
|
node = finishNode(parser, context, start, line, column, {
|
|
@@ -4053,7 +4091,7 @@ export function parseOptionalChain(
|
|
|
4053
4091
|
* @param context Context masks
|
|
4054
4092
|
*/
|
|
4055
4093
|
export function parsePropertyOrPrivatePropertyName(parser: ParserState, context: Context): any {
|
|
4056
|
-
if ((parser.token & (Token.IsIdentifier | Token.Keyword))
|
|
4094
|
+
if ((parser.token & (Token.IsIdentifier | Token.Keyword)) === 0 && parser.token !== Token.PrivateField) {
|
|
4057
4095
|
report(parser, Errors.InvalidDotProperty);
|
|
4058
4096
|
}
|
|
4059
4097
|
|
|
@@ -4788,12 +4826,12 @@ export function parseFunctionDeclaration(
|
|
|
4788
4826
|
let functionScope = scope ? createScope() : void 0;
|
|
4789
4827
|
|
|
4790
4828
|
if (parser.token === Token.LeftParen) {
|
|
4791
|
-
if ((flags & HoistedClassFlags.Hoisted)
|
|
4829
|
+
if ((flags & HoistedClassFlags.Hoisted) === 0) report(parser, Errors.DeclNoName, 'Function');
|
|
4792
4830
|
} else {
|
|
4793
4831
|
// In ES6, a function behaves as a lexical binding, except in
|
|
4794
4832
|
// a script scope, or the initial scope of eval or another function.
|
|
4795
4833
|
const kind =
|
|
4796
|
-
origin & Origin.TopLevel && ((context & Context.InGlobal)
|
|
4834
|
+
origin & Origin.TopLevel && ((context & Context.InGlobal) === 0 || (context & Context.Module) === 0)
|
|
4797
4835
|
? BindingKind.Variable
|
|
4798
4836
|
: BindingKind.FunctionLexical;
|
|
4799
4837
|
|
|
@@ -5130,7 +5168,7 @@ export function parseArrayExpressionOrPattern(
|
|
|
5130
5168
|
destructible |=
|
|
5131
5169
|
kind & BindingKind.ArgumentList
|
|
5132
5170
|
? DestructuringKind.Assignable
|
|
5133
|
-
: (kind & BindingKind.Empty)
|
|
5171
|
+
: (kind & BindingKind.Empty) === 0
|
|
5134
5172
|
? DestructuringKind.CannotDestruct
|
|
5135
5173
|
: 0;
|
|
5136
5174
|
|
|
@@ -5225,7 +5263,7 @@ export function parseArrayExpressionOrPattern(
|
|
|
5225
5263
|
|
|
5226
5264
|
if (parser.token !== Token.Comma && parser.token !== Token.RightBracket) {
|
|
5227
5265
|
left = parseAssignmentExpression(parser, context, inGroup, isPattern, tokenPos, linePos, colPos, left);
|
|
5228
|
-
if ((kind & (BindingKind.Empty | BindingKind.ArgumentList))
|
|
5266
|
+
if ((kind & (BindingKind.Empty | BindingKind.ArgumentList)) === 0 && token === Token.LeftParen)
|
|
5229
5267
|
destructible |= DestructuringKind.CannotDestruct;
|
|
5230
5268
|
} else if (parser.assignable & AssignmentKind.CannotAssign) {
|
|
5231
5269
|
destructible |= DestructuringKind.CannotDestruct;
|
|
@@ -5584,7 +5622,7 @@ export function parseMethodDefinition(
|
|
|
5584
5622
|
column: number
|
|
5585
5623
|
): ESTree.FunctionExpression {
|
|
5586
5624
|
const modifierFlags =
|
|
5587
|
-
(kind & PropertyKind.Constructor)
|
|
5625
|
+
(kind & PropertyKind.Constructor) === 0 ? 0b0000001111010000000_0000_00000000 : 0b0000000111000000000_0000_00000000;
|
|
5588
5626
|
|
|
5589
5627
|
context =
|
|
5590
5628
|
((context | modifierFlags) ^ modifierFlags) |
|
|
@@ -6587,7 +6625,7 @@ export function parseMethodFormals(
|
|
|
6587
6625
|
const { tokenPos, linePos, colPos } = parser;
|
|
6588
6626
|
|
|
6589
6627
|
if (parser.token & Token.IsIdentifier) {
|
|
6590
|
-
if ((context & Context.Strict)
|
|
6628
|
+
if ((context & Context.Strict) === 0) {
|
|
6591
6629
|
if ((parser.token & Token.FutureReserved) === Token.FutureReserved) {
|
|
6592
6630
|
parser.flags |= Flags.HasStrictReserved;
|
|
6593
6631
|
}
|
|
@@ -6749,7 +6787,7 @@ export function parseParenthesizedExpression(
|
|
|
6749
6787
|
|
|
6750
6788
|
const scope = context & Context.OptionsLexical ? addChildScope(createScope(), ScopeKind.ArrowParams) : void 0;
|
|
6751
6789
|
|
|
6752
|
-
context = (context | Context.DisallowIn
|
|
6790
|
+
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
6753
6791
|
|
|
6754
6792
|
if (consumeOpt(parser, context, Token.RightParen)) {
|
|
6755
6793
|
// Not valid expression syntax, but this is valid in an arrow function
|
|
@@ -7147,7 +7185,7 @@ export function parseArrowFunctionExpression(
|
|
|
7147
7185
|
|
|
7148
7186
|
switch (parser.token) {
|
|
7149
7187
|
case Token.LeftBracket:
|
|
7150
|
-
if ((parser.flags & Flags.NewLine)
|
|
7188
|
+
if ((parser.flags & Flags.NewLine) === 0) {
|
|
7151
7189
|
report(parser, Errors.InvalidInvokedBlockBodyArrow);
|
|
7152
7190
|
}
|
|
7153
7191
|
break;
|
|
@@ -7156,14 +7194,14 @@ export function parseArrowFunctionExpression(
|
|
|
7156
7194
|
case Token.QuestionMark:
|
|
7157
7195
|
report(parser, Errors.InvalidAccessedBlockBodyArrow);
|
|
7158
7196
|
case Token.LeftParen:
|
|
7159
|
-
if ((parser.flags & Flags.NewLine)
|
|
7197
|
+
if ((parser.flags & Flags.NewLine) === 0) {
|
|
7160
7198
|
report(parser, Errors.InvalidInvokedBlockBodyArrow);
|
|
7161
7199
|
}
|
|
7162
7200
|
parser.flags |= Flags.DisallowCall;
|
|
7163
7201
|
break;
|
|
7164
7202
|
default: // ignore
|
|
7165
7203
|
}
|
|
7166
|
-
if ((parser.token & Token.IsBinaryOp) === Token.IsBinaryOp && (parser.flags & Flags.NewLine)
|
|
7204
|
+
if ((parser.token & Token.IsBinaryOp) === Token.IsBinaryOp && (parser.flags & Flags.NewLine) === 0)
|
|
7167
7205
|
report(parser, Errors.UnexpectedToken, KeywordDescTable[parser.token & Token.Type]);
|
|
7168
7206
|
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp) report(parser, Errors.InvalidArrowPostfix);
|
|
7169
7207
|
}
|
|
@@ -7235,7 +7273,7 @@ export function parseFormalParametersOrFormalList(
|
|
|
7235
7273
|
const { tokenPos, linePos, colPos } = parser;
|
|
7236
7274
|
|
|
7237
7275
|
if (parser.token & Token.IsIdentifier) {
|
|
7238
|
-
if ((context & Context.Strict)
|
|
7276
|
+
if ((context & Context.Strict) === 0) {
|
|
7239
7277
|
if ((parser.token & Token.FutureReserved) === Token.FutureReserved) {
|
|
7240
7278
|
parser.flags |= Flags.HasStrictReserved;
|
|
7241
7279
|
}
|
|
@@ -7914,7 +7952,7 @@ export function parseClassDeclaration(
|
|
|
7914
7952
|
// ...
|
|
7915
7953
|
// [+Default] class ClassTail[?Yield]
|
|
7916
7954
|
//
|
|
7917
|
-
if ((flags & HoistedClassFlags.Hoisted)
|
|
7955
|
+
if ((flags & HoistedClassFlags.Hoisted) === 0) report(parser, Errors.DeclNoName, 'Class');
|
|
7918
7956
|
}
|
|
7919
7957
|
let inheritedContext = context;
|
|
7920
7958
|
|
|
@@ -8162,7 +8200,7 @@ export function parseClassBody(
|
|
|
8162
8200
|
context = (context | Context.DisallowIn) ^ Context.DisallowIn;
|
|
8163
8201
|
parser.flags = (parser.flags | Flags.HasConstructor) ^ Flags.HasConstructor;
|
|
8164
8202
|
|
|
8165
|
-
const body: (ESTree.MethodDefinition | ESTree.PropertyDefinition)[] = [];
|
|
8203
|
+
const body: (ESTree.MethodDefinition | ESTree.PropertyDefinition | ESTree.StaticBlock)[] = [];
|
|
8166
8204
|
let decorators: ESTree.Decorator[];
|
|
8167
8205
|
|
|
8168
8206
|
while (parser.token !== Token.RightBrace) {
|
|
@@ -8230,7 +8268,7 @@ function parseClassElementList(
|
|
|
8230
8268
|
start: number,
|
|
8231
8269
|
line: number,
|
|
8232
8270
|
column: number
|
|
8233
|
-
): ESTree.MethodDefinition | ESTree.PropertyDefinition {
|
|
8271
|
+
): ESTree.MethodDefinition | ESTree.PropertyDefinition | ESTree.StaticBlock {
|
|
8234
8272
|
let kind: PropertyKind = isStatic ? PropertyKind.Static : PropertyKind.None;
|
|
8235
8273
|
let key: ESTree.Expression | ESTree.PrivateIdentifier | null = null;
|
|
8236
8274
|
|
|
@@ -8259,7 +8297,7 @@ function parseClassElementList(
|
|
|
8259
8297
|
break;
|
|
8260
8298
|
|
|
8261
8299
|
case Token.AsyncKeyword:
|
|
8262
|
-
if (parser.token !== Token.LeftParen && (parser.flags & Flags.NewLine)
|
|
8300
|
+
if (parser.token !== Token.LeftParen && (parser.flags & Flags.NewLine) === 0) {
|
|
8263
8301
|
if (context & Context.OptionsNext && (parser.token & Token.IsClassField) === Token.IsClassField) {
|
|
8264
8302
|
return parsePropertyDefinition(parser, context, key, kind, decorators, tokenPos, linePos, colPos);
|
|
8265
8303
|
}
|
|
@@ -8298,11 +8336,11 @@ function parseClassElementList(
|
|
|
8298
8336
|
nextToken(parser, context); // skip: '*'
|
|
8299
8337
|
} else if (context & Context.OptionsNext && parser.token === Token.PrivateField) {
|
|
8300
8338
|
kind |= PropertyKind.PrivateField;
|
|
8301
|
-
key = parsePrivateIdentifier(parser, context, tokenPos, linePos, colPos);
|
|
8302
|
-
context = context | Context.InClass;
|
|
8339
|
+
key = parsePrivateIdentifier(parser, context | Context.InClass, tokenPos, linePos, colPos);
|
|
8303
8340
|
} else if (context & Context.OptionsNext && (parser.token & Token.IsClassField) === Token.IsClassField) {
|
|
8304
8341
|
kind |= PropertyKind.ClassField;
|
|
8305
|
-
|
|
8342
|
+
} else if (isStatic && token === Token.LeftBrace) {
|
|
8343
|
+
return parseStaticBlock(parser, context, scope, tokenPos, linePos, colPos);
|
|
8306
8344
|
} else if (token === Token.EscapedFutureReserved) {
|
|
8307
8345
|
key = parseIdentifier(parser, context, 0);
|
|
8308
8346
|
if (parser.token !== Token.LeftParen)
|
|
@@ -8327,14 +8365,14 @@ function parseClassElementList(
|
|
|
8327
8365
|
} else report(parser, Errors.InvalidKeyToken);
|
|
8328
8366
|
}
|
|
8329
8367
|
|
|
8330
|
-
if ((kind & PropertyKind.Computed)
|
|
8368
|
+
if ((kind & PropertyKind.Computed) === 0) {
|
|
8331
8369
|
if (parser.tokenValue === 'constructor') {
|
|
8332
8370
|
if ((parser.token & Token.IsClassField) === Token.IsClassField) {
|
|
8333
8371
|
report(parser, Errors.InvalidClassFieldConstructor);
|
|
8334
|
-
} else if ((kind & PropertyKind.Static)
|
|
8372
|
+
} else if ((kind & PropertyKind.Static) === 0 && parser.token === Token.LeftParen) {
|
|
8335
8373
|
if (kind & (PropertyKind.GetSet | PropertyKind.Async | PropertyKind.ClassField | PropertyKind.Generator)) {
|
|
8336
8374
|
report(parser, Errors.InvalidConstructor, 'accessor');
|
|
8337
|
-
} else if ((context & Context.SuperCall)
|
|
8375
|
+
} else if ((context & Context.SuperCall) === 0) {
|
|
8338
8376
|
if (parser.flags & Flags.HasConstructor) report(parser, Errors.DuplicateConstructor);
|
|
8339
8377
|
else parser.flags |= Flags.HasConstructor;
|
|
8340
8378
|
}
|
|
@@ -8342,7 +8380,7 @@ function parseClassElementList(
|
|
|
8342
8380
|
kind |= PropertyKind.Constructor;
|
|
8343
8381
|
} else if (
|
|
8344
8382
|
// Static Async Generator Private Methods can be named "#prototype" (class declaration)
|
|
8345
|
-
(kind & PropertyKind.PrivateField)
|
|
8383
|
+
(kind & PropertyKind.PrivateField) === 0 &&
|
|
8346
8384
|
kind & (PropertyKind.Static | PropertyKind.GetSet | PropertyKind.Generator | PropertyKind.Async) &&
|
|
8347
8385
|
parser.tokenValue === 'prototype'
|
|
8348
8386
|
) {
|
|
@@ -8366,7 +8404,7 @@ function parseClassElementList(
|
|
|
8366
8404
|
? {
|
|
8367
8405
|
type: 'MethodDefinition',
|
|
8368
8406
|
kind:
|
|
8369
|
-
(kind & PropertyKind.Static)
|
|
8407
|
+
(kind & PropertyKind.Static) === 0 && kind & PropertyKind.Constructor
|
|
8370
8408
|
? 'constructor'
|
|
8371
8409
|
: kind & PropertyKind.Getter
|
|
8372
8410
|
? 'get'
|
|
@@ -8382,7 +8420,7 @@ function parseClassElementList(
|
|
|
8382
8420
|
: {
|
|
8383
8421
|
type: 'MethodDefinition',
|
|
8384
8422
|
kind:
|
|
8385
|
-
(kind & PropertyKind.Static)
|
|
8423
|
+
(kind & PropertyKind.Static) === 0 && kind & PropertyKind.Constructor
|
|
8386
8424
|
? 'constructor'
|
|
8387
8425
|
: kind & PropertyKind.Getter
|
|
8388
8426
|
? 'get'
|
|
@@ -9060,7 +9098,7 @@ function parseJSXExpressionContainer(
|
|
|
9060
9098
|
line: number,
|
|
9061
9099
|
column: number
|
|
9062
9100
|
): ESTree.JSXExpressionContainer | ESTree.JSXSpreadChild {
|
|
9063
|
-
nextToken(parser, context);
|
|
9101
|
+
nextToken(parser, context | Context.AllowRegExp);
|
|
9064
9102
|
const { tokenPos, linePos, colPos } = parser;
|
|
9065
9103
|
if (parser.token === Token.Ellipsis) return parseJSXSpreadChild(parser, context, tokenPos, linePos, colPos);
|
|
9066
9104
|
|
package/src/token.ts
CHANGED
|
@@ -106,8 +106,8 @@ export const enum Token {
|
|
|
106
106
|
StrictNotEqual = 61 | IsBinaryOp | 7 << PrecStart, // !==
|
|
107
107
|
LooseEqual = 62 | IsBinaryOp | 7 << PrecStart, // ==
|
|
108
108
|
LooseNotEqual = 63 | IsBinaryOp | 7 << PrecStart, // !=
|
|
109
|
-
LessThanOrEqual = 64 | IsBinaryOp |
|
|
110
|
-
GreaterThanOrEqual = 65 | IsBinaryOp |
|
|
109
|
+
LessThanOrEqual = 64 | IsBinaryOp | 8 << PrecStart, // <=
|
|
110
|
+
GreaterThanOrEqual = 65 | IsBinaryOp | 8 << PrecStart, // >=
|
|
111
111
|
LessThan = 66 | IsBinaryOp | IsExpressionStart | 8 << PrecStart, // <
|
|
112
112
|
GreaterThan = 67 | IsBinaryOp | 8 << PrecStart, // >
|
|
113
113
|
ShiftLeft = 68 | IsBinaryOp | 9 << PrecStart, // <<
|