meriyah 6.1.3 → 7.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.
@@ -1,38 +1,27 @@
1
- import { Token } from './token';
2
- import { Errors } from './errors';
3
- import type * as ESTree from './estree';
4
1
  import { type Parser } from './parser/parser';
2
+ import { Token } from './token';
5
3
  export declare const enum Context {
6
4
  None = 0,
7
- OptionsNext = 1,
8
- OptionsRanges = 2,
9
- OptionsLoc = 4,
10
- OptionsJSX = 8,
11
- OptionsLexical = 16,
12
- OptionsPreserveParens = 32,
13
- OptionsWebCompat = 64,
14
- OptionsRaw = 128,
15
- Strict = 256,
16
- Module = 512,
17
- InSwitch = 1024,
18
- InGlobal = 2048,
19
- InClass = 4096,
20
- AllowRegExp = 8192,
21
- TaggedTemplate = 16384,
22
- InIteration = 32768,
23
- SuperProperty = 65536,
24
- SuperCall = 131072,
25
- InYieldContext = 262144,
26
- InAwaitContext = 524288,
27
- InReturnContext = 1048576,
28
- InArgumentList = 2097152,
29
- InConstructor = 4194304,
30
- InMethodOrFunction = 8388608,
31
- AllowNewTarget = 16777216,
32
- DisallowIn = 33554432,
33
- AllowEscapedKeyword = 67108864,
34
- OptionsUniqueKeyInPattern = 134217728,
35
- InStaticBlock = 268435456
5
+ Strict = 1,
6
+ Module = 2,
7
+ InSwitch = 4,
8
+ InGlobal = 8,
9
+ InClass = 16,
10
+ AllowRegExp = 32,
11
+ TaggedTemplate = 64,
12
+ InIteration = 128,
13
+ SuperProperty = 256,
14
+ SuperCall = 512,
15
+ InYieldContext = 1024,
16
+ InAwaitContext = 2048,
17
+ InReturnContext = 4096,
18
+ InArgumentList = 8192,
19
+ InConstructor = 16384,
20
+ InMethodOrFunction = 32768,
21
+ AllowNewTarget = 65536,
22
+ DisallowIn = 131072,
23
+ AllowEscapedKeyword = 262144,
24
+ InStaticBlock = 524288
36
25
  }
37
26
  export declare const enum PropertyKind {
38
27
  None = 0,
@@ -119,74 +108,22 @@ export declare const enum HoistedFunctionFlags {
119
108
  Hoisted = 1,
120
109
  Export = 2
121
110
  }
122
- export declare const enum ScopeKind {
123
- None = 0,
124
- ForStatement = 1,
125
- Block = 2,
126
- CatchStatement = 4,
127
- SwitchStatement = 8,
128
- ArgList = 16,
129
- TryStatement = 32,
130
- CatchBlock = 64,
131
- FunctionBody = 128,
132
- FunctionRoot = 256,
133
- FunctionParams = 512,
134
- ArrowParams = 1024,
135
- CatchIdentifier = 2048
136
- }
137
- export type OnComment = (type: ESTree.CommentType, value: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
138
- export type OnInsertedSemicolon = (pos: number) => any;
139
- export type OnToken = (token: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
140
- export interface ScopeState {
141
- parent: ScopeState | undefined;
142
- type: ScopeKind;
143
- scopeError?: ScopeError | null;
144
- }
145
- export interface PrivateScopeState {
146
- parent: PrivateScopeState | undefined;
147
- refs: {
148
- [name: string]: {
149
- index: number;
150
- line: number;
151
- column: number;
152
- }[];
153
- };
154
- }
155
- export interface ScopeError {
156
- type: Errors;
157
- params: string[];
158
- start: Location;
159
- end: Location;
160
- }
161
111
  export declare function matchOrInsertSemicolon(parser: Parser, context: Context): void;
162
112
  export declare function isValidStrictMode(parser: Parser, index: number, tokenIndex: number, tokenValue: string): 0 | 1;
163
113
  export declare function optionalBit(parser: Parser, context: Context, t: Token): 0 | 1;
164
114
  export declare function consumeOpt(parser: Parser, context: Context, t: Token): boolean;
165
115
  export declare function consume(parser: Parser, context: Context, t: Token): void;
166
- export declare function reinterpretToPattern(state: Parser, node: any): void;
116
+ export declare function reinterpretToPattern(parser: Parser, node: any): void;
167
117
  export declare function validateBindingIdentifier(parser: Parser, context: Context, kind: BindingKind, t: Token, skipEvalArgCheck: 0 | 1): void;
168
118
  export declare function validateFunctionName(parser: Parser, context: Context, t: Token): void;
169
119
  export declare function isStrictReservedWord(parser: Parser, context: Context, t: Token): boolean;
170
120
  export declare function isPropertyWithPrivateFieldKey(expr: any): boolean;
171
121
  export declare function isValidLabel(parser: Parser, labels: any, name: string, isIterationStatement: 0 | 1): 0 | 1;
172
122
  export declare function validateAndDeclareLabel(parser: Parser, labels: any, name: string): void;
173
- export declare function createArrowHeadParsingScope(parser: Parser, context: Context, value: string): ScopeState;
174
- export declare function recordScopeError(parser: Parser, type: Errors, ...params: string[]): ScopeError;
175
- export declare function createScope(): ScopeState;
176
- export declare function addChildScope(parent: ScopeState | undefined, type: ScopeKind): ScopeState;
177
- export declare function addChildPrivateScope(parent: PrivateScopeState | undefined): PrivateScopeState;
178
- export declare function addVarOrBlock(parser: Parser, context: Context, scope: ScopeState, name: string, kind: BindingKind, origin: Origin): void;
179
- export declare function addBlockName(parser: Parser, context: Context, scope: any, name: string, kind: BindingKind, origin: Origin): void;
180
- export declare function addVarName(parser: Parser, context: Context, scope: ScopeState, name: string, kind: BindingKind): void;
181
- export declare function addPrivateIdentifier(parser: Parser, scope: PrivateScopeState, name: string, kind: PropertyKind): void;
182
- export declare function addPrivateIdentifierRef(parser: Parser, scope: PrivateScopeState, name: string): void;
183
- export declare function validatePrivateIdentifierRefs(scope: PrivateScopeState): void;
184
- export declare function declareUnboundVariable(parser: Parser, name: string): void;
185
- export declare function addBindingToExports(parser: Parser, name: string): void;
186
123
  export declare function isValidIdentifier(context: Context, t: Token): boolean;
187
124
  export declare function classifyIdentifier(parser: Parser, context: Context, t: Token): any;
188
125
  export type Location = {
189
- index: number;
190
- line: number;
191
- column: number;
126
+ readonly index: number;
127
+ readonly line: number;
128
+ readonly column: number;
192
129
  };
@@ -1,6 +1,5 @@
1
+ import { type Location } from './common';
1
2
  import { type _Node, type SourceLocation } from './estree';
2
- import { type ScopeError, type Location } from './common';
3
- import { type Parser } from './parser/parser';
4
3
  export declare const enum Errors {
5
4
  Unexpected = 0,
6
5
  StrictOctalEscape = 1,
@@ -181,9 +180,6 @@ export declare const enum Errors {
181
180
  InvalidAwaitAsIdentifier = 176,
182
181
  InvalidAwaitInStaticBlock = 177
183
182
  }
184
- export declare const errorMessages: {
185
- [key: string]: string;
186
- };
187
183
  export declare class ParseError extends SyntaxError implements _Node {
188
184
  start: number;
189
185
  end: number;
@@ -192,7 +188,3 @@ export declare class ParseError extends SyntaxError implements _Node {
192
188
  description: string;
193
189
  constructor(start: Location, end: Location, type: Errors, ...params: string[]);
194
190
  }
195
- export declare function report(parser: Parser, type: Errors, ...params: string[]): never;
196
- export declare function reportScopeError(scope: ScopeError): never;
197
- export declare function reportMessageAt(start: Location, end: Location, type: Errors, ...params: string[]): never;
198
- export declare function reportScannerError(start: Location, end: Location, type: Errors): never;
@@ -21,7 +21,7 @@ export interface Comment extends _Node {
21
21
  type: CommentType;
22
22
  value: string;
23
23
  }
24
- export type Node = ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BigIntLiteral | BinaryExpression | BlockStatement | BreakStatement | CallExpression | ChainExpression | ImportExpression | CatchClause | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | PropertyDefinition | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | Import | ImportDeclaration | ImportDefaultSpecifier | ImportAttribute | ImportNamespaceSpecifier | ImportSpecifier | JSXNamespacedName | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXMemberExpression | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | ParenthesizedExpression | PrivateIdentifier | Program | Property | RegExpLiteral | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | UpdateExpression | UnaryExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
24
+ export type Node = AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BinaryExpression | BlockStatement | BreakStatement | CallExpression | ChainExpression | ImportExpression | CatchClause | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | PropertyDefinition | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportDeclaration | ImportDefaultSpecifier | ImportAttribute | ImportNamespaceSpecifier | ImportSpecifier | JSXNamespacedName | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXMemberExpression | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | ParenthesizedExpression | PrivateIdentifier | Program | Property | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | UpdateExpression | UnaryExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
25
25
  export type BindingPattern = ArrayPattern | ObjectPattern | Identifier;
26
26
  export type ClassElement = FunctionExpression | MethodDefinition;
27
27
  export type DeclarationStatement = ClassDeclaration | ClassExpression | ExportDefaultDeclaration | ExportAllDeclaration | ExportNamedDeclaration | FunctionDeclaration;
@@ -29,7 +29,6 @@ export type EntityName = Identifier;
29
29
  export type ExportDeclaration = ClassDeclaration | ClassExpression | FunctionDeclaration | VariableDeclaration;
30
30
  export type Expression = ArrowFunctionExpression | AssignmentExpression | BinaryExpression | ConditionalExpression | MetaProperty | ChainExpression | JSXClosingElement | JSXClosingFragment | JSXExpressionContainer | JSXOpeningElement | JSXOpeningFragment | JSXSpreadChild | LogicalExpression | NewExpression | RestElement | SequenceExpression | SpreadElement | AwaitExpression | LeftHandSideExpression | UnaryExpression | UpdateExpression | YieldExpression;
31
31
  export type ForInitializer = Expression | VariableDeclaration;
32
- export { ForInitializer as ForInitialiser };
33
32
  export type ImportClause = ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier;
34
33
  export type IterationStatement = DoWhileStatement | ForInStatement | ForOfStatement | ForStatement | WhileStatement;
35
34
  export type JSXChild = JSXElement | JSXExpression | JSXFragment | JSXText;
@@ -39,8 +38,8 @@ export type LeftHandSideExpression = CallExpression | ChainExpression | ImportEx
39
38
  export type LiteralExpression = Literal | TemplateLiteral;
40
39
  export type ObjectLiteralElementLike = MethodDefinition | Property | RestElement | SpreadElement;
41
40
  export type Parameter = AssignmentPattern | RestElement | ArrayPattern | ObjectPattern | Identifier;
42
- export type PrimaryExpression = ArrayExpression | ArrayPattern | ClassExpression | FunctionExpression | Identifier | Import | JSXElement | JSXFragment | JSXOpeningElement | Literal | LiteralExpression | MetaProperty | ObjectExpression | ObjectPattern | Super | TemplateLiteral | ThisExpression;
43
- export type PrimaryExpressionExtended = ArrayExpression | ArrowFunctionExpression | ArrayPattern | AwaitExpression | Expression | ClassExpression | FunctionExpression | Identifier | Import | JSXElement | JSXFragment | JSXOpeningElement | Literal | LiteralExpression | MetaProperty | ObjectExpression | ObjectPattern | PrivateIdentifier | NewExpression | Super | TemplateLiteral | ThisExpression | UnaryExpression | UpdateExpression;
41
+ export type PrimaryExpression = ArrayExpression | ArrayPattern | ClassExpression | FunctionExpression | Identifier | JSXElement | JSXFragment | JSXOpeningElement | Literal | LiteralExpression | MetaProperty | ObjectExpression | ObjectPattern | Super | TemplateLiteral | ThisExpression;
42
+ export type PrimaryExpressionExtended = ArrayExpression | ArrowFunctionExpression | ArrayPattern | AwaitExpression | Expression | ClassExpression | FunctionExpression | Identifier | JSXElement | JSXFragment | JSXOpeningElement | Literal | LiteralExpression | MetaProperty | ObjectExpression | ObjectPattern | PrivateIdentifier | NewExpression | Super | TemplateLiteral | ThisExpression | UnaryExpression | UpdateExpression;
44
43
  export type PropertyName = Identifier | Literal;
45
44
  export type Statement = BlockStatement | BreakStatement | ContinueStatement | DebuggerStatement | DeclarationStatement | EmptyStatement | ExpressionStatement | IfStatement | IterationStatement | ImportDeclaration | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | VariableDeclaration | WithStatement;
46
45
  interface ClassDeclarationBase extends _Node {
@@ -90,9 +89,6 @@ export interface AwaitExpression extends _Node {
90
89
  type: 'AwaitExpression';
91
90
  argument: Expression;
92
91
  }
93
- export interface BigIntLiteral extends Literal {
94
- bigint: string;
95
- }
96
92
  export interface BinaryExpression extends _Node {
97
93
  type: 'BinaryExpression';
98
94
  operator: string;
@@ -186,8 +182,8 @@ export interface EmptyStatement extends _Node {
186
182
  }
187
183
  export interface ExportAllDeclaration extends _Node {
188
184
  type: 'ExportAllDeclaration';
189
- source: Literal;
190
- exported: Identifier | Literal | null;
185
+ source: StringLiteral;
186
+ exported: Identifier | StringLiteral | null;
191
187
  attributes: ImportAttribute[];
192
188
  }
193
189
  export interface ExportDefaultDeclaration extends _Node {
@@ -198,13 +194,13 @@ export interface ExportNamedDeclaration extends _Node {
198
194
  type: 'ExportNamedDeclaration';
199
195
  declaration: ExportDeclaration | null;
200
196
  specifiers: ExportSpecifier[];
201
- source: Literal | null;
197
+ source: StringLiteral | null;
202
198
  attributes: ImportAttribute[];
203
199
  }
204
200
  export interface ExportSpecifier extends _Node {
205
201
  type: 'ExportSpecifier';
206
- local: Identifier | Literal;
207
- exported: Identifier | Literal;
202
+ local: Identifier | StringLiteral;
203
+ exported: Identifier | StringLiteral;
208
204
  }
209
205
  export interface ExpressionStatement extends _Node {
210
206
  type: 'ExpressionStatement';
@@ -247,19 +243,16 @@ export interface IfStatement extends _Node {
247
243
  consequent: Statement;
248
244
  alternate: Statement | null;
249
245
  }
250
- export interface Import extends _Node {
251
- type: 'Import';
252
- }
253
246
  export interface ImportDeclaration extends _Node {
254
247
  type: 'ImportDeclaration';
255
- source: Literal;
248
+ source: StringLiteral;
256
249
  specifiers: ImportClause[];
257
250
  attributes: ImportAttribute[];
258
251
  }
259
252
  export interface ImportAttribute extends _Node {
260
253
  type: 'ImportAttribute';
261
- key: Identifier | Literal;
262
- value: Literal;
254
+ key: Identifier | StringLiteral;
255
+ value: StringLiteral;
263
256
  }
264
257
  export interface ImportDefaultSpecifier extends _Node {
265
258
  type: 'ImportDefaultSpecifier';
@@ -272,7 +265,7 @@ export interface ImportNamespaceSpecifier extends _Node {
272
265
  export interface ImportSpecifier extends _Node {
273
266
  type: 'ImportSpecifier';
274
267
  local: Identifier;
275
- imported: Identifier | Literal;
268
+ imported: Identifier | StringLiteral;
276
269
  }
277
270
  export interface JSXNamespacedName extends _Node {
278
271
  type: 'JSXNamespacedName';
@@ -347,11 +340,34 @@ export interface LabeledStatement extends _Node {
347
340
  label: Identifier;
348
341
  body: Statement;
349
342
  }
350
- export interface Literal extends _Node {
343
+ export type Literal = StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | BigIntLiteral | RegExpLiteral;
344
+ export interface _LiteralBase extends _Node {
351
345
  type: 'Literal';
352
- value: boolean | number | string | null | RegExp | bigint;
353
346
  raw?: string;
354
347
  }
348
+ export interface StringLiteral extends _LiteralBase {
349
+ value: string;
350
+ }
351
+ export interface NumericLiteral extends _LiteralBase {
352
+ value: number;
353
+ }
354
+ export interface BooleanLiteral extends _LiteralBase {
355
+ value: boolean;
356
+ }
357
+ export interface NullLiteral extends _LiteralBase {
358
+ value: null;
359
+ }
360
+ export interface BigIntLiteral extends _LiteralBase {
361
+ value: bigint;
362
+ bigint: string;
363
+ }
364
+ export interface RegExpLiteral extends _LiteralBase {
365
+ value: RegExp | null;
366
+ regex: {
367
+ pattern: string;
368
+ flags: string;
369
+ };
370
+ }
355
371
  export interface LogicalExpression extends _Node {
356
372
  type: 'LogicalExpression';
357
373
  operator: string;
@@ -411,12 +427,6 @@ export interface Property extends _Node {
411
427
  shorthand: boolean;
412
428
  kind: 'init' | 'get' | 'set';
413
429
  }
414
- export interface RegExpLiteral extends Literal {
415
- regex: {
416
- pattern: string;
417
- flags: string;
418
- };
419
- }
420
430
  export interface RestElement extends _Node {
421
431
  type: 'RestElement';
422
432
  argument: BindingPattern | Identifier | Expression | PropertyName;
@@ -519,3 +529,4 @@ export interface YieldExpression extends _Node {
519
529
  delegate: boolean;
520
530
  argument?: Expression | null;
521
531
  }
532
+ export {};
@@ -18,7 +18,6 @@ export declare const enum CharFlags {
18
18
  Hyphen = 32768
19
19
  }
20
20
  export declare const CharTypes: number[];
21
- export declare const isIdStart: number[];
22
21
  export declare const isIdPart: number[];
23
22
  export declare function isIdentifierStart(code: number): boolean;
24
23
  export declare function isIdentifierPart(code: number): boolean;
@@ -1,7 +1,6 @@
1
- import { LexerState } from './common';
2
- import { Context } from '../common';
1
+ import { Context, type Location } from '../common';
3
2
  import { type Parser } from '../parser/parser';
4
- import type * as ESTree from '../estree';
3
+ import { LexerState } from './common';
5
4
  export declare const enum CommentType {
6
5
  Single = 0,
7
6
  Multi = 1,
@@ -9,8 +8,7 @@ export declare const enum CommentType {
9
8
  HTMLClose = 3,
10
9
  HashBang = 4
11
10
  }
12
- export declare const CommentTypes: ESTree.CommentType[];
13
11
  export declare function skipHashBang(parser: Parser): void;
14
- export declare function skipSingleHTMLComment(parser: Parser, source: string, state: LexerState, context: Context, type: CommentType, start: number, line: number, column: number): LexerState;
15
- export declare function skipSingleLineComment(parser: Parser, source: string, state: LexerState, type: CommentType, start: number, line: number, column: number): LexerState;
12
+ export declare function skipSingleHTMLComment(parser: Parser, source: string, state: LexerState, context: Context, type: CommentType, start: Location): LexerState;
13
+ export declare function skipSingleLineComment(parser: Parser, source: string, state: LexerState, type: CommentType, start: Location): LexerState;
16
14
  export declare function skipMultiLineComment(parser: Parser, source: string, state: LexerState): LexerState | void;
@@ -1,5 +1,5 @@
1
- import { Token } from '../token';
2
1
  import { type Parser } from '../parser/parser';
2
+ import { Token } from '../token';
3
3
  export declare const enum LexerState {
4
4
  None = 0,
5
5
  NewLine = 1,
@@ -1,9 +1,7 @@
1
1
  import { Context } from '../common';
2
2
  import { type Parser } from '../parser/parser';
3
- import { Token } from '../token';
3
+ import { Token } from './../token';
4
4
  export declare function scanIdentifier(parser: Parser, context: Context, isValidAsKeyword: 0 | 1): Token;
5
5
  export declare function scanUnicodeIdentifier(parser: Parser, context: Context): Token;
6
6
  export declare function scanIdentifierSlowCase(parser: Parser, context: Context, hasEscape: 0 | 1, isValidAsKeyword: number): Token;
7
7
  export declare function scanPrivateIdentifier(parser: Parser): Token;
8
- export declare function scanIdentifierUnicodeEscape(parser: Parser): number;
9
- export declare function scanUnicodeEscape(parser: Parser): number;
@@ -1,9 +1,3 @@
1
- export { scanSingleToken, nextToken, TokenLookup } from './scan';
2
- export { skipMultiLineComment, skipSingleLineComment, skipHashBang, skipSingleHTMLComment, CommentType, } from './comments';
3
- export { advanceChar, consumePossibleSurrogatePair, isExoticECMAScriptWhitespace, toHex, consumeLineFeed, scanNewLine, LexerState, NumberKind, convertTokenType, } from './common';
4
- export { CharTypes, CharFlags, isIdentifierStart, isIdentifierPart } from './charClassifier';
5
- export { scanIdentifier, scanIdentifierSlowCase, scanUnicodeIdentifier, scanPrivateIdentifier, scanUnicodeEscape, } from './identifier';
6
- export { scanString } from './string';
7
- export { scanNumber } from './numeric';
8
- export { scanTemplate, scanTemplateTail } from './template';
9
- export { scanRegularExpression } from './regexp';
1
+ export { scanSingleToken, nextToken } from './scan';
2
+ export { skipHashBang } from './comments';
3
+ export { advanceChar, consumeLineFeed, scanNewLine, LexerState, convertTokenType } from './common';
@@ -1,7 +1,6 @@
1
- import { Token } from '../token';
2
- import { Context } from '../common';
1
+ import { type Context } from '../common';
3
2
  import { type Parser } from '../parser/parser';
3
+ import { Token } from '../token';
4
4
  export declare function scanJSXAttributeValue(parser: Parser, context: Context): Token;
5
- export declare function scanJSXString(parser: Parser, context: Context): Token;
6
- export declare function nextJSXToken(parser: Parser, context: Context): void;
5
+ export declare function nextJSXToken(parser: Parser): void;
7
6
  export declare function rescanJSXIdentifier(parser: Parser): Token;
@@ -3,4 +3,3 @@ import { type Parser } from '../parser/parser';
3
3
  import { Token } from '../token';
4
4
  import { NumberKind } from './common';
5
5
  export declare function scanNumber(parser: Parser, context: Context, kind: NumberKind): Token;
6
- export declare function scanDecimalDigitsOrSeparator(parser: Parser, char: number): string;
@@ -1,4 +1,3 @@
1
- import { Context } from '../common';
2
1
  import { type Parser } from '../parser/parser';
3
2
  import { Token } from '../token';
4
- export declare function scanRegularExpression(parser: Parser, context: Context): Token;
3
+ export declare function scanRegularExpression(parser: Parser): Token;
@@ -1,7 +1,6 @@
1
- import { Token } from '../token';
2
1
  import { Context } from '../common';
3
2
  import { type Parser } from '../parser/parser';
3
+ import { Token } from '../token';
4
4
  import { LexerState } from './common';
5
- export declare const TokenLookup: Token[];
6
5
  export declare function nextToken(parser: Parser, context: Context): void;
7
6
  export declare function scanSingleToken(parser: Parser, context: Context, state: LexerState): Token;
@@ -10,4 +10,4 @@ export declare const enum Escape {
10
10
  }
11
11
  export declare function scanString(parser: Parser, context: Context, quote: number): Token;
12
12
  export declare function parseEscape(parser: Parser, context: Context, first: number, isTemplate?: 0 | 1): number;
13
- export declare function handleStringError(state: Parser, code: Escape, isTemplate: 0 | 1): void;
13
+ export declare function handleStringError(parser: Parser, code: Escape, isTemplate: 0 | 1): void;
@@ -1,8 +1,8 @@
1
- import { Options } from './parser';
2
1
  import { type Program } from './estree';
2
+ import { type Options } from './options';
3
3
  declare const version: string;
4
- export declare function parseScript(source: string, options?: Options): Program;
5
- export declare function parseModule(source: string, options?: Options): Program;
4
+ export declare function parseScript(source: string, options?: Omit<Options, 'sourceType'>): Program;
5
+ export declare function parseModule(source: string, options?: Omit<Options, 'sourceType'>): Program;
6
6
  export declare function parse(source: string, options?: Options): Program;
7
- export { Options, version };
7
+ export { type Options, version };
8
8
  export type * as ESTree from './estree';
@@ -0,0 +1,32 @@
1
+ import type * as ESTree from './estree';
2
+ import { type Token } from './token';
3
+ type OnInsertedSemicolon = (pos: number) => any;
4
+ type SourceType = 'script' | 'module' | 'commonjs';
5
+ export type OnToken = (token: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
6
+ export type OnComment = (type: ESTree.CommentType, value: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
7
+ export interface Options {
8
+ sourceType?: SourceType;
9
+ next?: boolean;
10
+ ranges?: boolean;
11
+ webcompat?: boolean;
12
+ loc?: boolean;
13
+ raw?: boolean;
14
+ impliedStrict?: boolean;
15
+ preserveParens?: boolean;
16
+ lexical?: boolean;
17
+ source?: string;
18
+ jsx?: boolean;
19
+ onComment?: ESTree.Comment[] | OnComment;
20
+ onInsertedSemicolon?: OnInsertedSemicolon;
21
+ onToken?: Token[] | OnToken;
22
+ validateRegex?: boolean;
23
+ module?: boolean;
24
+ globalReturn?: boolean;
25
+ }
26
+ export type NormalizedOptions = Omit<Options, 'validateRegex' | 'onComment' | 'onToken'> & {
27
+ validateRegex: boolean;
28
+ onComment?: OnComment;
29
+ onToken?: OnToken;
30
+ };
31
+ export declare function normalizeOptions(rawOptions: Options): NormalizedOptions;
32
+ export {};
@@ -1,18 +1,14 @@
1
- import { Token } from '../token';
1
+ import { type AssignmentKind, type DestructuringKind, Flags, type Location } from '../common';
2
+ import { Errors } from '../errors';
2
3
  import type * as ESTree from '../estree';
3
- import { type Location, Flags, type OnComment, type OnInsertedSemicolon, type OnToken, type AssignmentKind, type DestructuringKind } from '../common';
4
- export type ParserOptions = {
5
- shouldAddLoc?: boolean;
6
- shouldAddRanges?: boolean;
7
- sourceFile?: string;
8
- onComment?: OnComment;
9
- onInsertedSemicolon?: OnInsertedSemicolon;
10
- onToken?: OnToken;
11
- };
4
+ import { type NormalizedOptions, type Options } from '../options';
5
+ import { Token } from '../token';
6
+ import { PrivateScope } from './private-scope';
7
+ import { Scope, type ScopeKind } from './scope';
12
8
  export declare class Parser {
13
9
  readonly source: string;
14
- readonly options: ParserOptions;
15
10
  private lastOnToken;
11
+ options: NormalizedOptions;
16
12
  token: Token;
17
13
  flags: Flags;
18
14
  index: number;
@@ -32,20 +28,27 @@ export declare class Parser {
32
28
  flags: string;
33
29
  };
34
30
  currentChar: number;
35
- exportedNames: Record<string, number>;
36
- exportedBindings: Record<string, number>;
31
+ exportedNames: Set<string>;
32
+ exportedBindings: Set<string>;
37
33
  assignable: AssignmentKind | DestructuringKind;
38
34
  destructible: AssignmentKind | DestructuringKind;
39
35
  leadingDecorators: {
40
36
  start?: Location;
41
37
  decorators: ESTree.Decorator[];
42
38
  };
43
- constructor(source: string, options?: ParserOptions);
39
+ constructor(source: string, rawOptions?: Options);
44
40
  getToken(): Token;
45
41
  setToken(value: Token, replaceLast?: boolean): Token;
46
42
  get tokenStart(): Location;
47
43
  get currentLocation(): Location;
48
44
  finishNode<T extends ESTree.Node>(node: T, start: Location, end: Location | void): T;
45
+ addBindingToExports(name: string): void;
46
+ declareUnboundVariable(name: string): void;
47
+ report(type: Errors, ...params: string[]): never;
48
+ createScopeIfLexical(type?: ScopeKind, parent?: Scope): Scope | undefined;
49
+ createScope(type?: ScopeKind, parent?: Scope): Scope;
50
+ createPrivateScopeIfLexical(parent?: PrivateScope): PrivateScope | undefined;
51
+ cloneIdentifier(original: ESTree.Identifier): ESTree.Identifier;
52
+ cloneStringLiteral(original: ESTree.StringLiteral): ESTree.StringLiteral;
53
+ private cloneLocationInformation;
49
54
  }
50
- export declare function pushComment(comments: ESTree.Comment[], options: ParserOptions): OnComment;
51
- export declare function pushToken(tokens: any[], options: ParserOptions): OnToken;
@@ -0,0 +1,16 @@
1
+ import { type Location, PropertyKind } from '../common';
2
+ import { type Parser } from './parser';
3
+ export declare class PrivateScope {
4
+ readonly parser: Parser;
5
+ readonly parent?: PrivateScope | undefined;
6
+ refs: {
7
+ [name: string]: Location[];
8
+ };
9
+ privateIdentifiers: Map<string, PropertyKind>;
10
+ constructor(parser: Parser, parent?: PrivateScope | undefined);
11
+ addPrivateIdentifier(name: string, kind: PropertyKind): void;
12
+ addPrivateIdentifierRef(name: string): void;
13
+ isPrivateIdentifierDefined(name: string): boolean;
14
+ validatePrivateIdentifierRefs(): void;
15
+ hasPrivateIdentifier(name: string): boolean;
16
+ }
@@ -0,0 +1,38 @@
1
+ import { BindingKind, Context, type Location, Origin } from '../common';
2
+ import { Errors } from '../errors';
3
+ import { type Parser } from './parser';
4
+ export declare const enum ScopeKind {
5
+ ForStatement = 1,
6
+ Block = 2,
7
+ CatchStatement = 4,
8
+ SwitchStatement = 8,
9
+ TryStatement = 16,
10
+ CatchBlock = 32,
11
+ FunctionBody = 64,
12
+ FunctionRoot = 128,
13
+ FunctionParams = 256,
14
+ ArrowParams = 512
15
+ }
16
+ interface ScopeError {
17
+ type: Errors;
18
+ params: string[];
19
+ start: Location;
20
+ end: Location;
21
+ }
22
+ export declare class Scope {
23
+ readonly parser: Parser;
24
+ readonly type: ScopeKind;
25
+ readonly parent?: Scope | undefined;
26
+ scopeError?: ScopeError;
27
+ variableBindings: Map<string, BindingKind>;
28
+ constructor(parser: Parser, type?: ScopeKind, parent?: Scope | undefined);
29
+ createChildScope(type?: ScopeKind): Scope;
30
+ addVarOrBlock(context: Context, name: string, kind: BindingKind, origin: Origin): void;
31
+ addVarName(context: Context, name: string, kind: BindingKind): void;
32
+ hasVariable(name: string): boolean;
33
+ addBlockName(context: Context, name: string, kind: BindingKind, origin: Origin): void;
34
+ recordScopeError(type: Errors, ...params: string[]): void;
35
+ reportScopeError(): void;
36
+ }
37
+ export declare function createArrowHeadParsingScope(parser: Parser, context: Context, value: string): Scope;
38
+ export {};