meriyah 4.5.0 → 6.0.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 +415 -445
- package/README.md +52 -34
- package/dist/meriyah.cjs +9203 -8807
- package/dist/meriyah.min.mjs +1 -0
- package/dist/{meriyah.esm.js → meriyah.mjs} +9203 -8807
- package/dist/meriyah.umd.js +9203 -8807
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/src/chars.d.ts +135 -135
- package/dist/src/common.d.ts +225 -200
- package/dist/src/common.d.ts.map +1 -1
- package/dist/src/errors.d.ts +197 -187
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/estree.d.ts +524 -507
- package/dist/src/estree.d.ts.map +1 -1
- package/dist/src/lexer/charClassifier.d.ts +24 -24
- package/dist/src/lexer/charClassifier.d.ts.map +1 -1
- package/dist/src/lexer/comments.d.ts +14 -14
- package/dist/src/lexer/common.d.ts +25 -26
- package/dist/src/lexer/common.d.ts.map +1 -1
- package/dist/src/lexer/decodeHTML.d.ts +1 -1
- package/dist/src/lexer/decodeHTML.d.ts.map +1 -1
- package/dist/src/lexer/identifier.d.ts +8 -8
- package/dist/src/lexer/identifier.d.ts.map +1 -1
- package/dist/src/lexer/index.d.ts +9 -9
- package/dist/src/lexer/index.d.ts.map +1 -1
- package/dist/src/lexer/jsx.d.ts +6 -6
- package/dist/src/lexer/jsx.d.ts.map +1 -1
- package/dist/src/lexer/numeric.d.ts +5 -5
- package/dist/src/lexer/numeric.d.ts.map +1 -1
- package/dist/src/lexer/regexp.d.ts +3 -3
- package/dist/src/lexer/regexp.d.ts.map +1 -1
- package/dist/src/lexer/scan.d.ts +6 -6
- package/dist/src/lexer/scan.d.ts.map +1 -1
- package/dist/src/lexer/string.d.ts +12 -12
- package/dist/src/lexer/string.d.ts.map +1 -1
- package/dist/src/lexer/template.d.ts +4 -4
- package/dist/src/lexer/template.d.ts.map +1 -1
- package/dist/src/meriyah.d.ts +7 -7
- package/dist/src/meriyah.d.ts.map +1 -1
- package/dist/src/parser.d.ts +119 -118
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/token.d.ts +167 -167
- package/dist/src/token.d.ts.map +1 -1
- package/dist/src/unicode.d.ts +5 -5
- package/package.json +44 -48
- package/dist/meriyah.amd.js +0 -8854
- package/dist/meriyah.amd.min.js +0 -1
- package/dist/meriyah.cjs.js +0 -8852
- package/dist/meriyah.cjs.min.js +0 -1
- package/dist/meriyah.esm.min.js +0 -1
- package/dist/meriyah.esm.min.mjs +0 -1
- package/dist/meriyah.esm.mjs +0 -8846
- package/dist/meriyah.iife.js +0 -8857
- package/dist/meriyah.iife.min.js +0 -1
- package/dist/meriyah.min.cjs +0 -1
- package/dist/meriyah.system.js +0 -8860
- package/dist/meriyah.system.min.js +0 -1
- package/dist/meriyah.umd.cjs +0 -8858
- package/dist/meriyah.umd.es5.js +0 -8927
- package/dist/meriyah.umd.es5.min.js +0 -1
- package/dist/meriyah.umd.min.cjs +0 -1
- package/src/chars.ts +0 -155
- package/src/common.ts +0 -841
- package/src/errors.ts +0 -419
- package/src/estree.ts +0 -817
- package/src/lexer/charClassifier.ts +0 -449
- package/src/lexer/comments.ts +0 -178
- package/src/lexer/common.ts +0 -140
- package/src/lexer/decodeHTML.ts +0 -2186
- package/src/lexer/identifier.ts +0 -196
- package/src/lexer/index.ts +0 -32
- package/src/lexer/jsx.ts +0 -126
- package/src/lexer/numeric.ts +0 -259
- package/src/lexer/regexp.ts +0 -156
- package/src/lexer/scan.ts +0 -655
- package/src/lexer/string.ts +0 -242
- package/src/lexer/template.ts +0 -108
- package/src/meriyah.ts +0 -29
- package/src/parser.ts +0 -9210
- package/src/token.ts +0 -307
- package/src/unicode.ts +0 -36
package/src/errors.ts
DELETED
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
import { ParserState } from './common';
|
|
2
|
-
|
|
3
|
-
export const enum Errors {
|
|
4
|
-
Unexpected,
|
|
5
|
-
StrictOctalEscape,
|
|
6
|
-
TemplateOctalLiteral,
|
|
7
|
-
InvalidPrivateIdentifier,
|
|
8
|
-
InvalidUnicodeEscapeSequence,
|
|
9
|
-
InvalidCodePoint,
|
|
10
|
-
InvalidHexEscapeSequence,
|
|
11
|
-
StrictDecimalWithLeadingZero,
|
|
12
|
-
StrictOctalLiteral,
|
|
13
|
-
ExpectedNumberInRadix,
|
|
14
|
-
MissingExponent,
|
|
15
|
-
InvalidBigInt,
|
|
16
|
-
IDStartAfterNumber,
|
|
17
|
-
InvalidEightAndNine,
|
|
18
|
-
UnterminatedString,
|
|
19
|
-
UnterminatedTemplate,
|
|
20
|
-
UnterminatedComment,
|
|
21
|
-
InvalidDynamicUnicode,
|
|
22
|
-
IllegalCharacter,
|
|
23
|
-
MissingHexDigits,
|
|
24
|
-
InvalidImplicitOctals,
|
|
25
|
-
InvalidStringLT,
|
|
26
|
-
InvalidEscapeIdentifier,
|
|
27
|
-
ExpectedToken,
|
|
28
|
-
CantAssignTo,
|
|
29
|
-
InvalidLHSAsyncArrow,
|
|
30
|
-
SuperNoConstructor,
|
|
31
|
-
InvalidSuperProperty,
|
|
32
|
-
UnexpectedToken,
|
|
33
|
-
AwaitInParameter,
|
|
34
|
-
YieldInParameter,
|
|
35
|
-
InvalidExponentiationLHS,
|
|
36
|
-
UnterminatedRegExp,
|
|
37
|
-
UnexpectedTokenRegExpFlag,
|
|
38
|
-
DuplicateRegExpFlag,
|
|
39
|
-
AccessorWrongArgs,
|
|
40
|
-
BadSetterRestParameter,
|
|
41
|
-
DeclNoName,
|
|
42
|
-
StrictFunctionName,
|
|
43
|
-
RestMissingArg,
|
|
44
|
-
InvalidGeneratorGetter,
|
|
45
|
-
InvalidGeneratorSetter,
|
|
46
|
-
InvalidComputedPropName,
|
|
47
|
-
InvalidGetSetGenerator,
|
|
48
|
-
InvalidAsyncGetter,
|
|
49
|
-
InvalidGenMethodShorthand,
|
|
50
|
-
InvalidLineBreak,
|
|
51
|
-
InvalidArrowDestructLHS,
|
|
52
|
-
InvalidBindingDestruct,
|
|
53
|
-
InvalidAsyncArrow,
|
|
54
|
-
StaticPrototype,
|
|
55
|
-
InvalidConstructor,
|
|
56
|
-
DuplicateConstructor,
|
|
57
|
-
InvalidIncDecTarget,
|
|
58
|
-
InvalidIncDecNew,
|
|
59
|
-
InvalidAssignmentTarget,
|
|
60
|
-
InvalidRestTrailing,
|
|
61
|
-
DeclarationMissingInitializer,
|
|
62
|
-
ForInOfLoopInitializer,
|
|
63
|
-
ForInOfLoopMultiBindings,
|
|
64
|
-
InvalidShorthandPropInit,
|
|
65
|
-
DuplicateProto,
|
|
66
|
-
InvalidLetBoundName,
|
|
67
|
-
InvalidNewUnary,
|
|
68
|
-
IllegalUseStrict,
|
|
69
|
-
DisallowedLetInStrict,
|
|
70
|
-
IllegalContinue,
|
|
71
|
-
IllegalBreak,
|
|
72
|
-
InvalidLetBracket,
|
|
73
|
-
InvalidDestructuringTarget,
|
|
74
|
-
RestDefaultInitializer,
|
|
75
|
-
InvalidRestNotLast,
|
|
76
|
-
InvalidRestArg,
|
|
77
|
-
InvalidRestDefault,
|
|
78
|
-
StrictFunction,
|
|
79
|
-
SloppyFunction,
|
|
80
|
-
WebCompatFunction,
|
|
81
|
-
ClassForbiddenAsStatement,
|
|
82
|
-
CantAssignToInOfForLoop,
|
|
83
|
-
InvalidAssignmentInOfForLoop,
|
|
84
|
-
InvalidForAwait,
|
|
85
|
-
InvalidTemplateContinuation,
|
|
86
|
-
RestrictedLetProduction,
|
|
87
|
-
UnexpectedLetStrictReserved,
|
|
88
|
-
InvalidCatchParams,
|
|
89
|
-
InvalidCatchParamDefault,
|
|
90
|
-
NoCatchOrFinally,
|
|
91
|
-
MultipleDefaultsInSwitch,
|
|
92
|
-
NewlineAfterThrow,
|
|
93
|
-
StrictWith,
|
|
94
|
-
IllegalReturn,
|
|
95
|
-
InvalidForLHSBinding,
|
|
96
|
-
InvalidNewTarget,
|
|
97
|
-
InvalidEscapedKeyword,
|
|
98
|
-
MissingPrivateIdentifier,
|
|
99
|
-
DisallowedInContext,
|
|
100
|
-
AwaitOutsideAsync,
|
|
101
|
-
InvalidStrictLet,
|
|
102
|
-
InvalidLetConstBinding,
|
|
103
|
-
InvalidLetClassName,
|
|
104
|
-
KeywordNotId,
|
|
105
|
-
InvalidImportExportSloppy,
|
|
106
|
-
UnicodeOverflow,
|
|
107
|
-
InvalidExportImportSource,
|
|
108
|
-
InvalidKeywordAsAlias,
|
|
109
|
-
InvalidDefaultImport,
|
|
110
|
-
TrailingDecorators,
|
|
111
|
-
GeneratorConstructor,
|
|
112
|
-
AwaitOrYieldIdentInModule,
|
|
113
|
-
HtmlCommentInWebCompat,
|
|
114
|
-
StrictInvalidLetInExprPos,
|
|
115
|
-
NotAssignableLetArgs,
|
|
116
|
-
ForOfLet,
|
|
117
|
-
InvalidInvokedBlockBodyArrow,
|
|
118
|
-
InvalidAccessedBlockBodyArrow,
|
|
119
|
-
UnexpectedStrictReserved,
|
|
120
|
-
StrictEvalArguments,
|
|
121
|
-
InvalidDecoratorSemicolon,
|
|
122
|
-
StrictDelete,
|
|
123
|
-
InvalidPatternTail,
|
|
124
|
-
AsyncFunctionInSingleStatementContext,
|
|
125
|
-
InvalidTernaryYield,
|
|
126
|
-
InvalidArrowPostfix,
|
|
127
|
-
InvalidObjLitKeyStar,
|
|
128
|
-
DeletePrivateField,
|
|
129
|
-
InvalidStaticClassFieldConstructor,
|
|
130
|
-
InvalidClassFieldConstructor,
|
|
131
|
-
InvalidClassFieldArgEval,
|
|
132
|
-
InvalidGeneratorFunction,
|
|
133
|
-
AsyncRestrictedProd,
|
|
134
|
-
UnexpectedCharAfterObjLit,
|
|
135
|
-
InvalidObjLitKey,
|
|
136
|
-
InvalidKeyToken,
|
|
137
|
-
LabelRedeclaration,
|
|
138
|
-
InvalidNestedStatement,
|
|
139
|
-
UnknownLabel,
|
|
140
|
-
InvalidImportTail,
|
|
141
|
-
ImportNotOneArg,
|
|
142
|
-
InvalidImportNew,
|
|
143
|
-
InvalidSpreadInImport,
|
|
144
|
-
UncompleteArrow,
|
|
145
|
-
DuplicateBinding,
|
|
146
|
-
DuplicateExportBinding,
|
|
147
|
-
UndeclaredExportedBinding,
|
|
148
|
-
UnexpectedPrivateField,
|
|
149
|
-
DuplicateLetConstBinding,
|
|
150
|
-
CantAssignToValidRHS,
|
|
151
|
-
ContinuousNumericSeparator,
|
|
152
|
-
TrailingNumericSeparator,
|
|
153
|
-
InvalidJSXAttributeValue,
|
|
154
|
-
ExpectedJSXClosingTag,
|
|
155
|
-
AdjacentJSXElements,
|
|
156
|
-
InvalidNonEmptyJSXExpr,
|
|
157
|
-
DuplicateIdentifier,
|
|
158
|
-
ShadowedCatchClause,
|
|
159
|
-
InvalidDotProperty,
|
|
160
|
-
UnclosedSpreadElement,
|
|
161
|
-
CatchWithoutTry,
|
|
162
|
-
FinallyWithoutTry,
|
|
163
|
-
UnCorrespondingFragmentTag,
|
|
164
|
-
InvalidCoalescing,
|
|
165
|
-
OptionalChainingNoTemplate,
|
|
166
|
-
OptionalChainingNoSuper,
|
|
167
|
-
OptionalChainingNoNew,
|
|
168
|
-
ImportMetaOutsideModule,
|
|
169
|
-
InvalidLeadingDecorator
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export const errorMessages: {
|
|
173
|
-
[key: string]: string;
|
|
174
|
-
} = {
|
|
175
|
-
[Errors.Unexpected]: 'Unexpected token',
|
|
176
|
-
[Errors.UnexpectedToken]: "Unexpected token: '%0'",
|
|
177
|
-
[Errors.StrictOctalEscape]: 'Octal escape sequences are not allowed in strict mode',
|
|
178
|
-
[Errors.TemplateOctalLiteral]: 'Octal escape sequences are not allowed in template strings',
|
|
179
|
-
[Errors.InvalidPrivateIdentifier]: 'Unexpected token `#`',
|
|
180
|
-
[Errors.InvalidUnicodeEscapeSequence]: 'Illegal Unicode escape sequence',
|
|
181
|
-
[Errors.InvalidCodePoint]: 'Invalid code point %0',
|
|
182
|
-
[Errors.InvalidHexEscapeSequence]: 'Invalid hexadecimal escape sequence',
|
|
183
|
-
[Errors.StrictOctalLiteral]: 'Octal literals are not allowed in strict mode',
|
|
184
|
-
[Errors.StrictDecimalWithLeadingZero]: 'Decimal integer literals with a leading zero are forbidden in strict mode',
|
|
185
|
-
[Errors.ExpectedNumberInRadix]: 'Expected number in radix %0',
|
|
186
|
-
[Errors.CantAssignToValidRHS]: 'Invalid left-hand side assignment to a destructible right-hand side',
|
|
187
|
-
[Errors.MissingExponent]: 'Non-number found after exponent indicator',
|
|
188
|
-
[Errors.InvalidBigInt]: 'Invalid BigIntLiteral',
|
|
189
|
-
[Errors.IDStartAfterNumber]: 'No identifiers allowed directly after numeric literal',
|
|
190
|
-
[Errors.InvalidEightAndNine]: 'Escapes \\8 or \\9 are not syntactically valid escapes',
|
|
191
|
-
[Errors.UnterminatedString]: 'Unterminated string literal',
|
|
192
|
-
[Errors.UnterminatedTemplate]: 'Unterminated template literal',
|
|
193
|
-
[Errors.UnterminatedComment]: 'Multiline comment was not closed properly',
|
|
194
|
-
[Errors.InvalidDynamicUnicode]: 'The identifier contained dynamic unicode escape that was not closed',
|
|
195
|
-
[Errors.IllegalCharacter]: "Illegal character '%0'",
|
|
196
|
-
[Errors.MissingHexDigits]: 'Missing hexadecimal digits',
|
|
197
|
-
[Errors.InvalidImplicitOctals]: 'Invalid implicit octal',
|
|
198
|
-
[Errors.InvalidStringLT]: 'Invalid line break in string literal',
|
|
199
|
-
[Errors.InvalidEscapeIdentifier]: 'Only unicode escapes are legal in identifier names',
|
|
200
|
-
[Errors.ExpectedToken]: "Expected '%0'",
|
|
201
|
-
[Errors.CantAssignTo]: 'Invalid left-hand side in assignment',
|
|
202
|
-
[Errors.InvalidLHSAsyncArrow]: 'Invalid left-hand side in async arrow',
|
|
203
|
-
[Errors.SuperNoConstructor]:
|
|
204
|
-
'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass',
|
|
205
|
-
[Errors.InvalidSuperProperty]: 'Member access on super must be in a method',
|
|
206
|
-
[Errors.AwaitInParameter]: 'Await expression not allowed in formal parameter',
|
|
207
|
-
[Errors.YieldInParameter]: 'Yield expression not allowed in formal parameter',
|
|
208
|
-
[Errors.InvalidEscapedKeyword]: "Unexpected token: 'escaped keyword'",
|
|
209
|
-
[Errors.InvalidExponentiationLHS]:
|
|
210
|
-
'Unary expressions as the left operand of an exponentiation expression must be disambiguated with parentheses',
|
|
211
|
-
[Errors.AsyncFunctionInSingleStatementContext]:
|
|
212
|
-
'Async functions can only be declared at the top level or inside a block',
|
|
213
|
-
[Errors.UnterminatedRegExp]: 'Unterminated regular expression',
|
|
214
|
-
[Errors.UnexpectedTokenRegExpFlag]: 'Unexpected regular expression flag',
|
|
215
|
-
[Errors.DuplicateRegExpFlag]: "Duplicate regular expression flag '%0'",
|
|
216
|
-
[Errors.AccessorWrongArgs]: '%0 functions must have exactly %1 argument%2',
|
|
217
|
-
[Errors.BadSetterRestParameter]: 'Setter function argument must not be a rest parameter',
|
|
218
|
-
[Errors.DeclNoName]: '%0 declaration must have a name in this context',
|
|
219
|
-
[Errors.StrictFunctionName]:
|
|
220
|
-
'Function name may not contain any reserved words or be eval or arguments in strict mode',
|
|
221
|
-
[Errors.RestMissingArg]: 'The rest operator is missing an argument',
|
|
222
|
-
[Errors.InvalidGeneratorGetter]: 'A getter cannot be a generator',
|
|
223
|
-
[Errors.InvalidGeneratorSetter]: 'A setter cannot be a generator',
|
|
224
|
-
[Errors.InvalidComputedPropName]: 'A computed property name must be followed by a colon or paren',
|
|
225
|
-
[Errors.InvalidObjLitKey]: 'Object literal keys that are strings or numbers must be a method or have a colon',
|
|
226
|
-
[Errors.InvalidAsyncGetter]: 'Found `* async x(){}` but this should be `async * x(){}`',
|
|
227
|
-
[Errors.InvalidGetSetGenerator]: 'Getters and setters can not be generators',
|
|
228
|
-
[Errors.InvalidGenMethodShorthand]: "'%0' can not be generator method",
|
|
229
|
-
[Errors.InvalidLineBreak]: "No line break is allowed after '=>'",
|
|
230
|
-
[Errors.InvalidArrowDestructLHS]: 'The left-hand side of the arrow can only be destructed through assignment',
|
|
231
|
-
[Errors.InvalidBindingDestruct]: 'The binding declaration is not destructible',
|
|
232
|
-
[Errors.InvalidAsyncArrow]: 'Async arrow can not be followed by new expression',
|
|
233
|
-
[Errors.StaticPrototype]: "Classes may not have a static property named 'prototype'",
|
|
234
|
-
[Errors.InvalidConstructor]: 'Class constructor may not be a %0',
|
|
235
|
-
[Errors.DuplicateConstructor]: 'Duplicate constructor method in class',
|
|
236
|
-
[Errors.InvalidIncDecTarget]: 'Invalid increment/decrement operand',
|
|
237
|
-
[Errors.InvalidIncDecNew]: 'Invalid use of `new` keyword on an increment/decrement expression',
|
|
238
|
-
[Errors.InvalidAssignmentTarget]: '`=>` is an invalid assignment target',
|
|
239
|
-
[Errors.InvalidRestTrailing]: 'Rest element may not have a trailing comma',
|
|
240
|
-
[Errors.DeclarationMissingInitializer]: 'Missing initializer in %0 declaration',
|
|
241
|
-
[Errors.ForInOfLoopInitializer]: "'for-%0' loop head declarations can not have an initializer",
|
|
242
|
-
[Errors.ForInOfLoopMultiBindings]: 'Invalid left-hand side in for-%0 loop: Must have a single binding',
|
|
243
|
-
[Errors.InvalidShorthandPropInit]: 'Invalid shorthand property initializer',
|
|
244
|
-
[Errors.DuplicateProto]: 'Property name __proto__ appears more than once in object literal',
|
|
245
|
-
[Errors.InvalidLetBoundName]: 'Let is disallowed as a lexically bound name',
|
|
246
|
-
[Errors.InvalidNewUnary]: "Invalid use of '%0' inside new expression",
|
|
247
|
-
[Errors.IllegalUseStrict]: "Illegal 'use strict' directive in function with non-simple parameter list",
|
|
248
|
-
[Errors.DisallowedLetInStrict]: 'Identifier "let" disallowed as left-hand side expression in strict mode',
|
|
249
|
-
[Errors.IllegalContinue]: 'Illegal continue statement',
|
|
250
|
-
[Errors.IllegalBreak]: 'Illegal break statement',
|
|
251
|
-
[Errors.InvalidLetBracket]: 'Cannot have `let[...]` as a var name in strict mode',
|
|
252
|
-
[Errors.InvalidDestructuringTarget]: 'Invalid destructuring assignment target',
|
|
253
|
-
[Errors.RestDefaultInitializer]: 'Rest parameter may not have a default initializer',
|
|
254
|
-
[Errors.InvalidRestNotLast]: 'The rest argument must the be last parameter',
|
|
255
|
-
[Errors.InvalidRestArg]: 'Invalid rest argument',
|
|
256
|
-
[Errors.StrictFunction]: 'In strict mode code, functions can only be declared at top level or inside a block',
|
|
257
|
-
[Errors.SloppyFunction]:
|
|
258
|
-
'In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement',
|
|
259
|
-
[Errors.WebCompatFunction]:
|
|
260
|
-
'Without web compatibility enabled functions can not be declared at top level, inside a block, or as the body of an if statement',
|
|
261
|
-
[Errors.ClassForbiddenAsStatement]: "Class declaration can't appear in single-statement context",
|
|
262
|
-
[Errors.CantAssignToInOfForLoop]: 'Invalid left-hand side in for-%0',
|
|
263
|
-
[Errors.InvalidAssignmentInOfForLoop]: 'Invalid assignment in for-%0',
|
|
264
|
-
[Errors.InvalidForAwait]: 'for await (... of ...) is only valid in async functions and async generators',
|
|
265
|
-
[Errors.InvalidTemplateContinuation]:
|
|
266
|
-
'The first token after the template expression should be a continuation of the template',
|
|
267
|
-
[Errors.UnexpectedLetStrictReserved]:
|
|
268
|
-
'`let` declaration not allowed here and `let` cannot be a regular var name in strict mode',
|
|
269
|
-
[Errors.RestrictedLetProduction]: '`let \n [` is a restricted production at the start of a statement',
|
|
270
|
-
[Errors.InvalidCatchParams]: 'Catch clause requires exactly one parameter, not more (and no trailing comma)',
|
|
271
|
-
[Errors.InvalidCatchParamDefault]: 'Catch clause parameter does not support default values',
|
|
272
|
-
[Errors.NoCatchOrFinally]: 'Missing catch or finally after try',
|
|
273
|
-
[Errors.MultipleDefaultsInSwitch]: 'More than one default clause in switch statement',
|
|
274
|
-
[Errors.NewlineAfterThrow]: 'Illegal newline after throw',
|
|
275
|
-
[Errors.StrictWith]: 'Strict mode code may not include a with statement',
|
|
276
|
-
[Errors.IllegalReturn]: 'Illegal return statement',
|
|
277
|
-
[Errors.InvalidForLHSBinding]: 'The left hand side of the for-header binding declaration is not destructible',
|
|
278
|
-
[Errors.InvalidNewTarget]: 'new.target only allowed within functions',
|
|
279
|
-
[Errors.MissingPrivateIdentifier]: "'#' not followed by identifier",
|
|
280
|
-
[Errors.KeywordNotId]: 'Invalid keyword',
|
|
281
|
-
[Errors.InvalidLetClassName]: "Can not use 'let' as a class name",
|
|
282
|
-
[Errors.InvalidLetConstBinding]: "'A lexical declaration can't define a 'let' binding",
|
|
283
|
-
[Errors.InvalidStrictLet]: 'Can not use `let` as variable name in strict mode',
|
|
284
|
-
[Errors.DisallowedInContext]: "'%0' may not be used as an identifier in this context",
|
|
285
|
-
[Errors.AwaitOutsideAsync]: 'Await is only valid in async functions',
|
|
286
|
-
[Errors.InvalidImportExportSloppy]: 'The %0 keyword can only be used with the module goal',
|
|
287
|
-
[Errors.UnicodeOverflow]: 'Unicode codepoint must not be greater than 0x10FFFF',
|
|
288
|
-
[Errors.InvalidExportImportSource]: '%0 source must be string',
|
|
289
|
-
[Errors.InvalidKeywordAsAlias]: 'Only a identifier can be used to indicate alias',
|
|
290
|
-
[Errors.InvalidDefaultImport]: "Only '*' or '{...}' can be imported after default",
|
|
291
|
-
[Errors.TrailingDecorators]: 'Trailing decorator may be followed by method',
|
|
292
|
-
[Errors.GeneratorConstructor]: "Decorators can't be used with a constructor",
|
|
293
|
-
[Errors.HtmlCommentInWebCompat]: 'HTML comments are only allowed with web compatibility (Annex B)',
|
|
294
|
-
[Errors.StrictInvalidLetInExprPos]: "The identifier 'let' must not be in expression position in strict mode",
|
|
295
|
-
[Errors.NotAssignableLetArgs]: 'Cannot assign to `eval` and `arguments` in strict mode',
|
|
296
|
-
[Errors.ForOfLet]: "The left-hand side of a for-of loop may not start with 'let'",
|
|
297
|
-
[Errors.InvalidInvokedBlockBodyArrow]: 'Block body arrows can not be immediately invoked without a group',
|
|
298
|
-
[Errors.InvalidAccessedBlockBodyArrow]: 'Block body arrows can not be immediately accessed without a group',
|
|
299
|
-
[Errors.UnexpectedStrictReserved]: 'Unexpected strict mode reserved word',
|
|
300
|
-
[Errors.StrictEvalArguments]: 'Unexpected eval or arguments in strict mode',
|
|
301
|
-
[Errors.InvalidDecoratorSemicolon]: 'Decorators must not be followed by a semicolon',
|
|
302
|
-
[Errors.StrictDelete]: 'Calling delete on expression not allowed in strict mode',
|
|
303
|
-
[Errors.InvalidPatternTail]: 'Pattern can not have a tail',
|
|
304
|
-
[Errors.InvalidTernaryYield]: 'Can not have a `yield` expression on the left side of a ternary',
|
|
305
|
-
[Errors.InvalidArrowPostfix]: 'An arrow function can not have a postfix update operator',
|
|
306
|
-
[Errors.InvalidObjLitKeyStar]: 'Invalid object literal key character after generator star',
|
|
307
|
-
[Errors.DeletePrivateField]: 'Private fields can not be deleted',
|
|
308
|
-
[Errors.InvalidClassFieldConstructor]: 'Classes may not have a field called constructor',
|
|
309
|
-
[Errors.InvalidStaticClassFieldConstructor]: 'Classes may not have a private element named constructor',
|
|
310
|
-
[Errors.InvalidClassFieldArgEval]: 'A class field initializer may not contain arguments',
|
|
311
|
-
[Errors.InvalidGeneratorFunction]: 'Generators can only be declared at the top level or inside a block',
|
|
312
|
-
[Errors.AsyncRestrictedProd]: 'Async methods are a restricted production and cannot have a newline following it',
|
|
313
|
-
[Errors.UnexpectedCharAfterObjLit]: 'Unexpected character after object literal property name',
|
|
314
|
-
[Errors.InvalidKeyToken]: 'Invalid key token',
|
|
315
|
-
[Errors.LabelRedeclaration]: "Label '%0' has already been declared",
|
|
316
|
-
[Errors.InvalidNestedStatement]: 'continue statement must be nested within an iteration statement',
|
|
317
|
-
[Errors.UnknownLabel]: "Undefined label '%0'",
|
|
318
|
-
[Errors.InvalidImportTail]: 'Trailing comma is disallowed inside import(...) arguments',
|
|
319
|
-
[Errors.ImportNotOneArg]: 'import() requires exactly one argument',
|
|
320
|
-
[Errors.InvalidImportNew]: 'Cannot use new with import(...)',
|
|
321
|
-
[Errors.InvalidSpreadInImport]: '... is not allowed in import()',
|
|
322
|
-
[Errors.UncompleteArrow]: "Expected '=>'",
|
|
323
|
-
[Errors.DuplicateBinding]: "Duplicate binding '%0'",
|
|
324
|
-
[Errors.DuplicateExportBinding]: "Cannot export a duplicate name '%0'",
|
|
325
|
-
[Errors.DuplicateLetConstBinding]: 'Duplicate %0 for-binding',
|
|
326
|
-
[Errors.UndeclaredExportedBinding]: "Exported binding '%0' needs to refer to a top-level declared variable",
|
|
327
|
-
[Errors.UnexpectedPrivateField]: 'Unexpected private field',
|
|
328
|
-
[Errors.TrailingNumericSeparator]: 'Numeric separators are not allowed at the end of numeric literals',
|
|
329
|
-
[Errors.ContinuousNumericSeparator]: 'Only one underscore is allowed as numeric separator',
|
|
330
|
-
[Errors.InvalidJSXAttributeValue]: 'JSX value should be either an expression or a quoted JSX text',
|
|
331
|
-
[Errors.ExpectedJSXClosingTag]: 'Expected corresponding JSX closing tag for %0',
|
|
332
|
-
[Errors.AdjacentJSXElements]: 'Adjacent JSX elements must be wrapped in an enclosing tag',
|
|
333
|
-
[Errors.InvalidNonEmptyJSXExpr]: "JSX attributes must only be assigned a non-empty 'expression'",
|
|
334
|
-
[Errors.DuplicateIdentifier]: "'%0' has already been declared",
|
|
335
|
-
[Errors.ShadowedCatchClause]: "'%0' shadowed a catch clause binding",
|
|
336
|
-
[Errors.InvalidDotProperty]: 'Dot property must be an identifier',
|
|
337
|
-
[Errors.UnclosedSpreadElement]: 'Encountered invalid input after spread/rest argument',
|
|
338
|
-
[Errors.CatchWithoutTry]: 'Catch without try',
|
|
339
|
-
[Errors.FinallyWithoutTry]: 'Finally without try',
|
|
340
|
-
[Errors.UnCorrespondingFragmentTag]: 'Expected corresponding closing tag for JSX fragment',
|
|
341
|
-
[Errors.InvalidCoalescing]:
|
|
342
|
-
'Coalescing and logical operators used together in the same expression must be disambiguated with parentheses',
|
|
343
|
-
[Errors.OptionalChainingNoTemplate]: 'Invalid tagged template on optional chain',
|
|
344
|
-
[Errors.OptionalChainingNoSuper]: 'Invalid optional chain from super property',
|
|
345
|
-
[Errors.OptionalChainingNoNew]: 'Invalid optional chain from new expression',
|
|
346
|
-
[Errors.ImportMetaOutsideModule]: 'Cannot use "import.meta" outside a module',
|
|
347
|
-
[Errors.InvalidLeadingDecorator]: 'Leading decorators must be attached to a class declaration'
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
export class ParseError extends SyntaxError {
|
|
351
|
-
public loc: {
|
|
352
|
-
line: ParseError['line'];
|
|
353
|
-
column: ParseError['column'];
|
|
354
|
-
};
|
|
355
|
-
public index: number;
|
|
356
|
-
public line: number;
|
|
357
|
-
public column: number;
|
|
358
|
-
public description: string;
|
|
359
|
-
/*eslint-disable*/
|
|
360
|
-
constructor(startindex: number, line: number, column: number, type: Errors, ...params: string[]) {
|
|
361
|
-
const message =
|
|
362
|
-
'[' + line + ':' + column + ']: ' + errorMessages[type].replace(/%(\d+)/g, (_: string, i: number) => params[i]);
|
|
363
|
-
super(`${message}`);
|
|
364
|
-
this.index = startindex;
|
|
365
|
-
this.line = line;
|
|
366
|
-
this.column = column;
|
|
367
|
-
this.description = message;
|
|
368
|
-
/* Acorn compat */
|
|
369
|
-
this.loc = {
|
|
370
|
-
line,
|
|
371
|
-
column
|
|
372
|
-
} as any;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Throws an error
|
|
377
|
-
*
|
|
378
|
-
* @export
|
|
379
|
-
* @param {ParserState} state
|
|
380
|
-
* @param {Errors} type
|
|
381
|
-
* @param {...string[]} params
|
|
382
|
-
* @returns {never}
|
|
383
|
-
*/
|
|
384
|
-
export function report(parser: ParserState, type: Errors, ...params: string[]): never {
|
|
385
|
-
throw new ParseError(parser.index, parser.line, parser.column, type, ...params);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export function reportScopeError(scope: any): never {
|
|
389
|
-
throw new ParseError(scope.index, scope.line, scope.column, scope.type, scope.params);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Throws an error at a given position
|
|
394
|
-
*
|
|
395
|
-
* @export
|
|
396
|
-
* @param {ParserState} state
|
|
397
|
-
* @param {number} index
|
|
398
|
-
* @param {number} line
|
|
399
|
-
* @param {number} column
|
|
400
|
-
* @param {Errors} type
|
|
401
|
-
* @param {...string[]} params
|
|
402
|
-
*/
|
|
403
|
-
export function reportMessageAt(index: number, line: number, column: number, type: Errors, ...params: string[]): never {
|
|
404
|
-
throw new ParseError(index, line, column, type, ...params);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Throws an error at a given position
|
|
409
|
-
*
|
|
410
|
-
* @export
|
|
411
|
-
* @param {ParserState} state
|
|
412
|
-
* @param {number} index
|
|
413
|
-
* @param {number} line
|
|
414
|
-
* @param {number} column
|
|
415
|
-
* @param {Errors} type
|
|
416
|
-
*/
|
|
417
|
-
export function reportScannerError(index: number, line: number, column: number, type: Errors): never {
|
|
418
|
-
throw new ParseError(index, line, column, type);
|
|
419
|
-
}
|