Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meriyah

Package Overview
Dependencies
Maintainers
1
Versions
917
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meriyah - npm Package Compare versions

Comparing version 0.1.12 to 0.1.13-dev.20190527

10

dist/common.d.ts

@@ -91,7 +91,2 @@ import { Token } from './token';

}
export declare const enum ParseFunctionFlag {
None = 0,
DisallowGenerator = 1,
RequireIdentifier = 2
}
export declare const enum FunctionStatement {

@@ -125,6 +120,7 @@ Disallow = 0,

export declare function reinterpretToPattern(state: ParserState, node: any): void;
export declare function validateIdentifier(parser: ParserState, context: Context, type: BindingType, token: Token): void;
export declare function validateBindingIdentifier(parser: ParserState, context: Context, type: BindingType, t: Token): void;
export declare function isStrictReservedWord(parser: ParserState, context: Context, t: Token): boolean;
export declare function validateArrowBlockBody(parser: ParserState): void;
export declare function isPropertyWithPrivateFieldKey(expr: any): boolean;
export declare function isValidLabel(parser: ParserState, labels: any, name: string, isIterationStatement: 0 | 1): 0 | 1;
export declare function validateAndDeclareLabel(parser: ParserState, labels: any, name: string): void;
//# sourceMappingURL=common.d.ts.map
interface _Node<T extends string> {
type: T;
loc?: SourceLocation | null;
start?: number;
end?: number;
leadingComments?: Comment[];
trailingComments?: Comment[];
loc?: SourceLocation | null;
range?: [number, number];
}

@@ -23,38 +22,3 @@ export interface T_Node extends T_Statement, T_Expression, T_Pattern, T_ModuleDeclaration, T_ModuleSpecifier {

VariableDeclarator: VariableDeclarator;
JSXIdentifier: JSXIdentifier;
JSXMemberExpression: JSXMemberExpression;
JSXNamespacedName: JSXNamespacedName;
JSXEmptyExpression: JSXEmptyExpression;
JSXExpressionContainer: JSXExpressionContainer;
JSXSpreadChild: JSXSpreadChild;
JSXText: JSXText;
JSXOpeningElement: JSXOpeningElement;
JSXClosingElement: JSXClosingElement;
JSXAttribute: JSXAttribute;
JSXSpreadAttribute: JSXSpreadAttribute;
}
export declare type Node = Program | SwitchCase | CatchClause | Statement | Expression | Property | AssignmentProperty | Super | SpreadElement | TemplateElement | ClassBody | FieldDefinition | PrivateName | Decorator | MethodDefinition | ModuleDeclaration | ModuleSpecifier | Pattern | VariableDeclarator | JSXIdentifier | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXExpressionContainer | JSXSpreadChild | JSXText | JSXOpeningElement | JSXClosingElement | JSXAttribute | JSXSpreadAttribute;
interface _Statement<T extends string> extends _Node<T> {
}
interface T_Statement extends T_Declaration {
ExpressionStatement: ExpressionStatement;
BlockStatement: BlockStatement;
EmptyStatement: EmptyStatement;
DebuggerStatement: DebuggerStatement;
WithStatement: WithStatement;
ReturnStatement: ReturnStatement;
LabeledStatement: LabeledStatement;
BreakStatement: BreakStatement;
ContinueStatement: ContinueStatement;
IfStatement: IfStatement;
SwitchStatement: SwitchStatement;
ThrowStatement: ThrowStatement;
TryStatement: TryStatement;
WhileStatement: WhileStatement;
DoWhileStatement: DoWhileStatement;
ForStatement: ForStatement;
ForInStatement: ForInStatement;
ForOfStatement: ForOfStatement;
}
export declare type Statement = ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
interface _Expression<T extends string> extends _Node<T> {

@@ -86,7 +50,15 @@ }

AwaitExpression: AwaitExpression;
JSXElement: JSXElement;
}
export declare type Expression = Identifier | Literal | RegExpLiteral | ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | LogicalExpression | MemberExpression | PrivateName | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | ArrowFunctionExpression | YieldExpression | TemplateLiteral | TaggedTemplateExpression | ClassExpression | MetaProperty | AwaitExpression | JSXElement;
interface _Pattern<T extends string> extends _Node<T> {
interface T_ModuleSpecifier {
ImportSpecifier: ImportSpecifier;
ImportDefaultSpecifier: ImportDefaultSpecifier;
ImportNamespaceSpecifier: ImportNamespaceSpecifier;
ExportSpecifier: ExportSpecifier;
}
interface T_ModuleDeclaration {
ImportDeclaration: ImportDeclaration;
ExportNamedDeclaration: ExportNamedDeclaration;
ExportDefaultDeclaration: ExportDefaultDeclaration;
ExportAllDeclaration: ExportAllDeclaration;
}
interface T_Pattern {

@@ -100,34 +72,13 @@ Identifier: Identifier;

}
export declare type PatternTop = Identifier | ObjectPattern | ArrayPattern | MemberExpression;
export declare type PatternNoRest = PatternTop | AssignmentPattern;
export declare type Pattern = PatternTop | AssignmentPattern | RestElement;
interface _Declaration<T extends string> extends _Statement<T> {
export declare type Node = Identifier | Literal | Program | Function | SwitchCase | CatchClause | VariableDeclarator | Statement | Expression | Property | AssignmentProperty | Super | TemplateElement | SpreadElement | Pattern | ClassBody | Decorator | MethodDefinition | ModuleDeclaration | ModuleSpecifier;
export declare type CommentType = 'Line' | 'Block' | 'HTMLOpen' | 'HTMLClose';
export interface Comment {
type: CommentType;
value: string;
start?: number;
end?: number;
loc?: SourceLocation | null;
}
interface T_Declaration {
FunctionDeclaration: FunctionDeclaration;
VariableDeclaration: VariableDeclaration;
ClassDeclaration: ClassDeclaration;
}
export declare type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
interface _ModuleDeclaration<T extends string> extends _Node<T> {
}
interface T_ModuleDeclaration {
ImportDeclaration: ImportDeclaration;
ExportNamedDeclaration: ExportNamedDeclaration;
ExportDefaultDeclaration: ExportDefaultDeclaration;
ExportAllDeclaration: ExportAllDeclaration;
}
export declare type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration;
interface _ModuleSpecifier<T extends string> extends _Node<T> {
local: Identifier;
}
interface T_ModuleSpecifier {
ImportSpecifier: ImportSpecifier;
ImportDefaultSpecifier: ImportDefaultSpecifier;
ImportNamespaceSpecifier: ImportNamespaceSpecifier;
ExportSpecifier: ExportSpecifier;
}
export declare type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
export interface SourceLocation {
source: string | null;
interface SourceLocation {
source?: string | null;
start: Position;

@@ -140,125 +91,70 @@ end: Position;

}
export declare type CommentType = 'SingleLineComment' | 'MultiLineComment';
export interface Comment {
type: CommentType;
value: string;
start?: number;
end?: number;
loc?: SourceLocation | null;
}
export interface Program extends _Node<'Program'> {
sourceType: 'script' | 'module';
body: (Statement | ModuleDeclaration)[];
body: Array<Statement | ModuleDeclaration>;
comments?: Array<Comment>;
}
export interface ArrayExpression extends _Expression<'ArrayExpression'> {
elements: (Expression | SpreadElement | null)[];
export declare type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
export declare type Statement = ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | Decorator | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
export declare type Expression = Identifier | Literal | RegExpLiteral | ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | LogicalExpression | MemberExpression | PrivateName | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | ArrowFunctionExpression | YieldExpression | TemplateLiteral | TaggedTemplateExpression | ClassExpression | MetaProperty | AwaitExpression;
export interface EmptyStatement extends _Node<'EmptyStatement'> {
}
export interface ArrayPattern extends _Pattern<'ArrayPattern'> {
elements: (Pattern | null)[];
export interface BlockStatement extends _Node<'BlockStatement'> {
body: Array<Statement>;
innerComments?: Array<Comment>;
}
export declare type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '**=';
export interface AssignmentExpression extends _Expression<'AssignmentExpression'> {
operator: AssignmentOperator;
left: Expression | PatternTop;
right: Expression;
export interface ExpressionStatement extends _Node<'ExpressionStatement'> {
expression: Expression;
directive?: string;
}
export interface AssignmentPattern extends _Pattern<'AssignmentPattern'> {
left: PatternTop;
right: Expression;
export interface IfStatement extends _Node<'IfStatement'> {
test: Expression;
consequent: Statement;
alternate?: Statement | null;
}
export interface ArrowFunctionExpression extends _Expression<'ArrowFunctionExpression'> {
id: Identifier | null;
params: Pattern[];
body: BlockStatement | Expression;
expression: boolean;
async: boolean;
export interface LabeledStatement extends _Node<'LabeledStatement'> {
label: Identifier;
body: Statement;
}
export interface AwaitExpression extends _Expression<'AwaitExpression'> {
argument: Expression;
export interface BreakStatement extends _Node<'BreakStatement'> {
label?: Identifier | null;
}
export declare type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '|' | '^' | '&' | 'in' | '**' | 'instanceof';
export interface BinaryExpression extends _Expression<'BinaryExpression'> {
operator: BinaryOperator;
left: Expression;
right: Expression;
export interface ContinueStatement extends _Node<'ContinueStatement'> {
label?: Identifier | null;
}
export interface BlockStatement extends _Statement<'BlockStatement'> {
body: Statement[];
}
export interface BreakStatement extends _Statement<'BreakStatement'> {
label: Identifier | null;
}
export interface CallExpression extends _Expression<'CallExpression'> {
callee: Expression | Import | Super;
arguments: (Expression | SpreadElement)[];
}
export interface CatchClause extends _Node<'CatchClause'> {
param: PatternTop;
body: BlockStatement;
}
export interface ClassBody extends _Node<'ClassBody'> {
body: (FieldDefinition | MethodDefinition)[];
}
export interface PrivateMemberExpression extends _Node<'MemberExpression'> {
export interface WithStatement extends _Node<'WithStatement'> {
object: Expression;
property: PrivateName;
body: Statement;
}
export interface FieldDefinition extends _Node<'FieldDefinition'> {
key: PrivateName | Expression;
value: any;
decorators?: Decorator[] | null;
computed: boolean;
static: boolean;
export interface SwitchStatement extends _Node<'SwitchStatement'> {
discriminant: Expression;
cases: Array<SwitchCase>;
}
export interface ClassDeclaration extends _Declaration<'ClassDeclaration'> {
id: Identifier | null;
superClass: Expression | null;
body: ClassBody;
export interface ReturnStatement extends _Node<'ReturnStatement'> {
argument?: Expression | null;
}
export interface ClassExpression extends _Expression<'ClassExpression'> {
id: Identifier | null;
superClass: Expression | null;
body: ClassBody;
export interface ThrowStatement extends _Node<'ThrowStatement'> {
argument: Expression;
}
export interface MemberExpression extends _Expression<'MemberExpression'> {
computed: boolean;
object: Expression | Super;
property: Expression;
export interface TryStatement extends _Node<'TryStatement'> {
block: BlockStatement;
handler?: CatchClause | null;
finalizer?: BlockStatement | null;
}
export interface ConditionalExpression extends _Expression<'ConditionalExpression'> {
export interface WhileStatement extends _Node<'WhileStatement'> {
test: Expression;
consequent: Expression;
alternate: Expression;
body: Statement;
}
export interface ContinueStatement extends _Statement<'ContinueStatement'> {
label: Identifier | null;
}
export interface DebuggerStatement extends _Statement<'DebuggerStatement'> {
}
export interface DoWhileStatement extends _Statement<'DoWhileStatement'> {
export interface DoWhileStatement extends _Node<'DoWhileStatement'> {
body: Statement;
test: Expression;
}
export interface EmptyStatement extends _Statement<'EmptyStatement'> {
export interface ForStatement extends _Node<'ForStatement'> {
init?: VariableDeclaration | Expression | null;
test?: Expression | null;
update?: Expression | null;
body: Statement;
}
export interface ExportAllDeclaration extends _ModuleDeclaration<'ExportAllDeclaration'> {
source: Literal;
}
export interface ExportDefaultDeclaration extends _ModuleDeclaration<'ExportDefaultDeclaration'> {
declaration: Declaration | Expression;
}
export interface ExportNamedDeclaration extends _ModuleDeclaration<'ExportNamedDeclaration'> {
declaration: Declaration | null;
specifiers: ExportSpecifier[];
source: Literal | null;
}
export interface ExportSpecifier extends _ModuleSpecifier<'ExportSpecifier'> {
exported: Identifier;
}
export interface ExpressionStatement extends _Statement<'ExpressionStatement'> {
expression: Expression;
directive?: string;
}
export interface ForInStatement extends _Statement<'ForInStatement'> {
left: VariableDeclaration | Expression | PatternNoRest;
left: VariableDeclaration | Pattern;
right: Expression;

@@ -268,3 +164,3 @@ body: Statement;

export interface ForOfStatement extends _Statement<'ForOfStatement'> {
left: VariableDeclaration | Expression | PatternNoRest;
left: VariableDeclaration | Pattern;
right: Expression;

@@ -275,7 +171,45 @@ body: Statement;

export interface ForStatement extends _Statement<'ForStatement'> {
init: VariableDeclaration | Expression | null;
test: Expression | null;
update: Expression | null;
init?: VariableDeclaration | Expression | null;
test?: Expression | null;
update?: Expression | null;
body: Statement;
}
interface _Statement<T extends string> extends _Node<T> {
}
interface T_Declaration {
FunctionDeclaration: FunctionDeclaration;
VariableDeclaration: VariableDeclaration;
ClassDeclaration: ClassDeclaration;
}
interface T_Statement extends T_Declaration {
ExpressionStatement: ExpressionStatement;
BlockStatement: BlockStatement;
EmptyStatement: EmptyStatement;
DebuggerStatement: DebuggerStatement;
WithStatement: WithStatement;
ReturnStatement: ReturnStatement;
LabeledStatement: LabeledStatement;
BreakStatement: BreakStatement;
ContinueStatement: ContinueStatement;
IfStatement: IfStatement;
SwitchStatement: SwitchStatement;
ThrowStatement: ThrowStatement;
TryStatement: TryStatement;
WhileStatement: WhileStatement;
DoWhileStatement: DoWhileStatement;
ForStatement: ForStatement;
ForInStatement: ForInStatement;
ForOfStatement: ForOfStatement;
Decorator: Decorator;
}
export interface ForInStatement extends _Statement<'ForInStatement'> {
left: Identifier | MemberExpression | ObjectPattern | ArrayPattern | AssignmentPattern | RestElement | VariableDeclaration;
right: Expression;
body: Statement;
}
export interface DebuggerStatement extends _Node<'DebuggerStatement'> {
}
export declare type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
interface _Declaration<T extends string> extends _Statement<T> {
}
export interface FunctionDeclaration extends _Declaration<'FunctionDeclaration'> {

@@ -287,49 +221,57 @@ id: Identifier | null;

async: boolean;
expression: false;
}
export interface FunctionExpression extends _Expression<'FunctionExpression'> {
id: Identifier | null;
params: Pattern[];
body: BlockStatement;
generator: boolean;
async: boolean;
expression: false;
export interface VariableDeclaration extends _Declaration<'VariableDeclaration'> {
declarations: VariableDeclarator[];
kind: 'var' | 'let' | 'const';
}
export interface Identifier extends _Expression<'Identifier'>, _Pattern<'Identifier'> {
name: string;
raw?: string;
export interface VariableDeclarator extends _Node<'VariableDeclarator'> {
id: Pattern;
init?: Expression | null;
}
export interface IfStatement extends _Statement<'IfStatement'> {
test: Expression;
consequent: Statement;
alternate: Statement | null;
declare type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | ArrowFunctionExpression | YieldExpression | Literal | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | LogicalExpression | MemberExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | TemplateLiteral | TaggedTemplateExpression | ClassExpression | MetaProperty | Identifier | AwaitExpression;
export interface ThisExpression extends _Expression<'ThisExpression'> {
}
export interface Import extends _Node<'Import'> {
export interface ArrayExpression extends _Expression<'ArrayExpression'> {
elements: Array<Expression | SpreadElement>;
}
export interface ImportDeclaration extends _ModuleDeclaration<'ImportDeclaration'> {
specifiers: (ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier)[];
source: Literal;
export interface ObjectExpression extends _Expression<'ObjectExpression'> {
properties: Array<Property>;
}
export interface ImportDefaultSpecifier extends _ModuleSpecifier<'ImportDefaultSpecifier'> {
export interface Property extends _Node<'Property'> {
key: Expression;
computed: boolean;
value: Expression | null;
kind: 'init' | 'get' | 'set';
method: boolean;
shorthand: boolean;
}
export interface ImportNamespaceSpecifier extends _ModuleSpecifier<'ImportNamespaceSpecifier'> {
export interface FunctionExpression extends _Expression<'FunctionExpression'> {
id?: Identifier | null;
body: BlockStatement;
params: Pattern[];
async: boolean;
generator: boolean;
}
export interface ImportSpecifier extends _ModuleSpecifier<'ImportSpecifier'> {
imported: Identifier;
export interface SequenceExpression extends _Expression<'SequenceExpression'> {
expressions: Array<Expression>;
}
export interface LabeledStatement extends _Statement<'LabeledStatement'> {
label: Identifier;
body: Statement;
export interface UnaryExpression extends _Expression<'UnaryExpression'> {
operator: UnaryOperator;
prefix: true;
argument: Expression;
}
export interface Literal extends _Expression<'Literal'> {
value: boolean | number | string | null;
raw?: string;
bigint?: string;
export interface BinaryExpression extends _Expression<'BinaryExpression'> {
operator: BinaryOperator;
left: Expression;
right: Expression;
}
export declare type LogicalOperator = '&&' | '||';
export interface Decorator extends _Node<'Decorator'> {
expression: Expression;
export interface AssignmentExpression extends _Expression<'AssignmentExpression'> {
operator: AssignmentOperator;
left: Pattern | MemberExpression;
right: Expression;
}
export interface PrivateName extends _Node<'PrivateName'> {
name: string;
export interface UpdateExpression extends _Expression<'UpdateExpression'> {
operator: UpdateOperator;
argument: Expression;
prefix: boolean;
}

@@ -341,12 +283,10 @@ export interface LogicalExpression extends _Expression<'LogicalExpression'> {

}
export interface MetaProperty extends _Expression<'MetaProperty'> {
meta: Identifier;
property: Identifier;
export interface ConditionalExpression extends _Expression<'ConditionalExpression'> {
test: Expression;
alternate: Expression;
consequent: Expression;
}
export interface MethodDefinition extends _Node<'MethodDefinition'> {
key: Expression | PrivateName;
value: FunctionExpression | null;
kind: 'constructor' | 'method' | 'get' | 'set';
computed: boolean;
static: boolean;
export interface CallExpression extends _Expression<'CallExpression'> {
callee: Expression | Super;
arguments: (Expression | SpreadElement)[];
}

@@ -357,24 +297,35 @@ export interface NewExpression extends _Expression<'NewExpression'> {

}
export interface Property extends _Node<'Property'> {
key: Expression;
export interface MemberExpression extends _Expression<'MemberExpression'> {
computed: boolean;
value: Expression | null;
kind: 'init' | 'get' | 'set';
method: boolean;
shorthand: boolean;
object: Expression | Super;
property: Expression | PrivateName;
}
export interface ObjectExpression extends _Expression<'ObjectExpression'> {
properties: (Property | SpreadElement)[];
export declare type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
export interface SwitchCase extends _Node<'SwitchCase'> {
test: Expression | null;
consequent: Statement[];
}
export interface AssignmentProperty extends _Node<'Property'> {
key: Expression;
value: PatternNoRest;
computed: boolean;
kind: 'init';
method: false;
shorthand: boolean;
export interface CatchClause extends _Node<'CatchClause'> {
param: Pattern;
body: BlockStatement;
}
export interface ObjectPattern extends _Pattern<'ObjectPattern'> {
properties: (AssignmentProperty | RestElement)[];
interface _Pattern<T extends string> extends _Node<T> {
}
interface T_Pattern {
Identifier: Identifier;
ObjectPattern: ObjectPattern;
ArrayPattern: ArrayPattern;
MemberExpression: MemberExpression;
AssignmentPattern: AssignmentPattern;
RestElement: RestElement;
}
export interface Identifier extends _Expression<'Identifier'>, _Pattern<'Identifier'> {
name: string;
raw?: string;
}
export interface Literal extends _Expression<'Literal'> {
value: boolean | number | string | null;
raw?: string;
bigint?: string;
}
export interface RegExpLiteral extends _Expression<'Literal'> {

@@ -388,23 +339,25 @@ value: RegExp | null;

}
export interface RestElement extends _Pattern<'RestElement'> {
argument: PatternTop;
export declare type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';
export declare type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '**' | '|' | '^' | '&' | 'in' | 'instanceof';
export declare type LogicalOperator = '||' | '&&';
export declare type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=';
export declare type UpdateOperator = '++' | '--';
export interface Super extends _Node<'Super'> {
}
export interface ReturnStatement extends _Statement<'ReturnStatement'> {
argument: Expression | null;
}
export interface SequenceExpression extends _Expression<'SequenceExpression'> {
expressions: Expression[];
}
export interface SpreadElement extends _Node<'SpreadElement'> {
argument: Expression;
}
export interface Super extends _Node<'Super'> {
export interface ArrowFunctionExpression extends _Expression<'ArrowFunctionExpression'> {
expression: boolean;
body: BlockStatement | Expression;
params: Pattern[];
async: boolean;
}
export interface SwitchCase extends _Node<'SwitchCase'> {
test: Expression | null;
consequent: Statement[];
export interface YieldExpression extends _Expression<'YieldExpression'> {
argument?: Expression | null;
delegate: boolean;
}
export interface SwitchStatement extends _Statement<'SwitchStatement'> {
discriminant: Expression;
cases: SwitchCase[];
export interface TemplateLiteral extends _Expression<'TemplateLiteral'> {
quasis: Array<TemplateElement>;
expressions: Array<Expression>;
}

@@ -422,93 +375,107 @@ export interface TaggedTemplateExpression extends _Expression<'TaggedTemplateExpression'> {

}
export interface TemplateLiteral extends _Expression<'TemplateLiteral'> {
quasis: TemplateElement[];
expressions: Expression[];
export interface AssignmentProperty extends _Node<'Property'> {
value: Pattern;
kind: 'init';
method: boolean;
}
export interface ThisExpression extends _Expression<'ThisExpression'> {
export interface ObjectPattern extends _Pattern<'ObjectPattern'> {
properties: Array<AssignmentProperty>;
}
export interface ThrowStatement extends _Statement<'ThrowStatement'> {
argument: Expression;
export interface ArrayPattern extends _Pattern<'ArrayPattern'> {
elements: Array<Pattern>;
}
export interface TryStatement extends _Statement<'TryStatement'> {
block: BlockStatement;
handler: CatchClause | null;
finalizer: BlockStatement | null;
export interface RestElement extends _Pattern<'RestElement'> {
argument: Pattern;
}
export declare type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';
export interface UnaryExpression extends _Expression<'UnaryExpression'> {
operator: UnaryOperator;
argument: Expression;
prefix: boolean;
export interface AssignmentPattern extends _Pattern<'AssignmentPattern'> {
left: Pattern;
right: Expression;
}
export declare type UpdateOperator = '++' | '--';
export interface UpdateExpression extends _Expression<'UpdateExpression'> {
operator: UpdateOperator;
argument: Expression;
prefix: boolean;
export interface ClassBody extends _Node<'ClassBody'> {
body: Array<MethodDefinition>;
decorators?: Decorator[] | null;
}
export interface VariableDeclaration extends _Declaration<'VariableDeclaration'> {
declarations: VariableDeclarator[];
kind: 'var' | 'let' | 'const';
export interface PrivateMemberExpression extends _Node<'FieldDefinition'> {
object: Expression;
property: PrivateName;
}
export interface VariableDeclarator extends _Node<'VariableDeclarator'> {
id: PatternTop;
init: Expression | null;
export interface Decorator extends _Node<'Decorator'> {
expression: Expression;
}
export interface WhileStatement extends _Statement<'WhileStatement'> {
test: Expression;
body: Statement;
export interface PrivateName extends _Node<'PrivateName'> {
name: string;
}
export interface WithStatement extends _Statement<'WithStatement'> {
object: Expression;
body: Statement;
export interface FieldDefinition extends _Node<'FieldDefinition'> {
key: PrivateName | Expression;
value: any;
decorators?: Decorator[] | null;
computed: boolean;
static: boolean;
}
export interface YieldExpression extends _Expression<'YieldExpression'> {
argument: Expression | null;
delegate: boolean;
export interface MethodDefinition extends _Node<'MethodDefinition'> {
key: Expression;
value: FunctionExpression;
kind: 'constructor' | 'method' | 'get' | 'set';
computed: boolean;
static: boolean;
decorators?: Decorator[] | null;
}
export interface JSXIdentifier extends _Node<'JSXIdentifier'> {
name: string;
export interface ClassDeclaration extends _Declaration<'ClassDeclaration'> {
id: Identifier | null;
superClass: Expression | null;
body: ClassBody;
decorators?: Decorator[] | null;
}
export interface JSXMemberExpression extends _Node<'JSXMemberExpression'> {
object: JSXMemberExpression | JSXIdentifier;
property: JSXIdentifier;
export interface ClassExpression extends _Expression<'ClassExpression'> {
id: Identifier | null;
superClass: Expression | null;
body: ClassBody;
decorators?: Decorator[] | null;
}
export interface JSXNamespacedName extends _Node<'JSXNamespacedName'> {
namespace: JSXIdentifier;
name: JSXIdentifier;
export interface MetaProperty extends _Expression<'MetaProperty'> {
meta: Identifier;
property: Identifier;
}
export interface JSXEmptyExpression extends _Node<'JSXEmptyExpression'> {
interface T_ModuleDeclaration {
ImportDeclaration: ImportDeclaration;
ExportNamedDeclaration: ExportNamedDeclaration;
ExportDefaultDeclaration: ExportDefaultDeclaration;
ExportAllDeclaration: ExportAllDeclaration;
}
export interface JSXExpressionContainer extends _Node<'JSXExpressionContainer'> {
expression: Expression | JSXEmptyExpression;
export declare type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration;
interface _ModuleSpecifier<T extends string> extends _Node<T> {
local: Identifier;
}
export interface JSXSpreadChild extends _Node<'JSXSpreadChild'> {
expression: Expression;
export declare type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
interface _ModuleDeclaration<T extends string> extends _Node<T> {
}
interface _JSXBoundaryElement<T extends string> extends _Node<T> {
name: JSXIdentifier | JSXMemberExpression | JSXNamespacedName;
export interface ImportDeclaration extends _ModuleDeclaration<'ImportDeclaration'> {
specifiers: (ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier)[];
source: Literal;
}
export interface JSXOpeningElement extends _JSXBoundaryElement<'JSXOpeningElement'> {
selfClosing: boolean;
attributes: (JSXAttribute | JSXSpreadAttribute)[];
export interface ImportSpecifier extends _ModuleSpecifier<'ImportSpecifier'> {
imported: Identifier;
}
export interface JSXText extends _Node<'JSXText'> {
value: string;
raw: string;
export interface ImportDefaultSpecifier extends _ModuleSpecifier<'ImportDefaultSpecifier'> {
}
export interface JSXClosingElement extends _JSXBoundaryElement<'JSXClosingElement'> {
export interface ImportNamespaceSpecifier extends _ModuleSpecifier<'ImportNamespaceSpecifier'> {
}
export interface JSXAttribute extends _Node<'JSXAttribute'> {
name: JSXIdentifier | JSXNamespacedName;
value: Literal | JSXElement | JSXSpreadAttribute | JSXExpressionContainer | null;
export interface ExportNamedDeclaration extends _ModuleDeclaration<'ExportNamedDeclaration'> {
declaration: Declaration | null;
specifiers: ExportSpecifier[];
source: Literal | null;
}
export interface JSXSpreadAttribute extends _Node<'JSXSpreadAttribute'> {
export interface ExportSpecifier extends _ModuleSpecifier<'ExportSpecifier'> {
exported: Identifier;
}
export interface ExportDefaultDeclaration extends _ModuleDeclaration<'ExportDefaultDeclaration'> {
declaration: Declaration | Expression;
}
export interface ExportAllDeclaration extends _ModuleDeclaration<'ExportAllDeclaration'> {
source: Literal;
}
export interface AwaitExpression extends _Expression<'AwaitExpression'> {
argument: Expression;
}
export interface JSXElement extends _Expression<'JSXElement'> {
openingElement: JSXOpeningElement;
children: (JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement)[];
closingElement: JSXClosingElement | null;
}
export {};
//# sourceMappingURL=estree.d.ts.map

@@ -22,3 +22,3 @@ export declare const enum CharFlags {

export declare function isIdentifierStart(code: number): number;
export declare function isIdentifierPart(code: number): number;
export declare function isIdentifierPart(code: number): any;
//# sourceMappingURL=charClassifier.d.ts.map
import { ParserState, Context } from '../common';
import { Token } from '../token';
export declare function scanIdentifier(parser: ParserState, context: Context): Token;
export declare function scanIdentifierSlowCase(parser: ParserState, context: Context, hasEscape: boolean, canBeKeyword: boolean): Token;
export declare function scanIdentifierSlowCase(parser: ParserState, context: Context, hasEscape: 0 | 1, canBeKeyword: number): Token;
export declare function scanPrivateName(parser: ParserState): Token;

@@ -6,0 +6,0 @@ export declare function scanIdentifierUnicodeEscape(parser: ParserState): any;

import { Token } from './token';
import * as ESTree from './estree';
import { Context, ParserState, PropertyKind, BindingOrigin, FunctionStatement, ParseFunctionFlag, BindingType } from './common';
import { Context, ParserState, PropertyKind, BindingOrigin, FunctionStatement, BindingType } from './common';
export declare function create(source: string): ParserState;

@@ -19,30 +19,30 @@ export interface Options {

export declare function parseStatementList(parser: ParserState, context: Context): ESTree.Statement[];
export declare function parseModuleItem(parser: ParserState, context: Context): any;
export declare function parseModuleItem(parser: ParserState, context: Context): (ReturnType<typeof parseDirective | typeof parseparseModuleItemList>)[];
export declare function parseparseModuleItemList(parser: ParserState, context: Context): any;
export declare function parseStatementListItem(parser: ParserState, context: Context): any;
export declare function parseStatement(parser: ParserState, context: Context, allowFuncDecl: FunctionStatement): ESTree.Statement;
export declare function parseExpressionOrLabelledStatement(parser: ParserState, context: Context, allowFuncDecl: FunctionStatement): ESTree.Statement;
export declare function parseBlock(parser: ParserState, context: Context): ESTree.BlockStatement;
export declare function parseStatementListItem(parser: ParserState, context: Context, labels: any): ESTree.Statement | ESTree.Decorator[];
export declare function parseStatement(parser: ParserState, context: Context, labels: any, allowFuncDecl: FunctionStatement): ESTree.Statement;
export declare function parseExpressionOrLabelledStatement(parser: ParserState, context: Context, labels: any, allowFuncDecl: FunctionStatement): ESTree.ExpressionStatement | ESTree.LabeledStatement;
export declare function parseBlock(parser: ParserState, context: Context, labels: any): ESTree.BlockStatement;
export declare function parseReturnStatement(parser: ParserState, context: Context): ESTree.ReturnStatement;
export declare function parseExpressionStatement(parser: ParserState, context: Context, expr: ESTree.Expression): ESTree.ExpressionStatement;
export declare function parseLabelledStatement(parser: ParserState, context: Context, expr: ESTree.Identifier, token: Token, allowFuncDecl: 0 | 1): ESTree.LabeledStatement;
export declare function parseAsyncArrowOrAsyncFunctionDeclaration(parser: ParserState, context: Context, allowFuncDecl: FunctionStatement): ESTree.ExpressionStatement | ESTree.LabeledStatement | ESTree.FunctionDeclaration;
export declare function parseLabelledStatement(parser: ParserState, context: Context, labels: any, label: string, expr: ESTree.Identifier, token: Token, allowFuncDecl: 0 | 1): ESTree.LabeledStatement;
export declare function parseAsyncArrowOrAsyncFunctionDeclaration(parser: ParserState, context: Context, labels: any, allowFuncDecl: FunctionStatement): ESTree.ExpressionStatement | ESTree.LabeledStatement | ESTree.FunctionDeclaration;
export declare function parseDirective(parser: ParserState, context: Context): ESTree.Statement | ESTree.ExpressionStatement;
export declare function parseEmptyStatement(parser: ParserState, context: Context): ESTree.EmptyStatement;
export declare function parseThrowStatement(parser: ParserState, context: Context): ESTree.ThrowStatement;
export declare function parseIfStatement(parser: ParserState, context: Context): ESTree.IfStatement;
export declare function parseConsequentOrAlternate(parser: ParserState, context: Context): ESTree.Statement | ESTree.FunctionDeclaration;
export declare function parseSwitchStatement(parser: ParserState, context: Context): ESTree.SwitchStatement;
export declare function parseWhileStatement(parser: ParserState, context: Context): ESTree.WhileStatement;
export declare function parseContinueStatement(parser: ParserState, context: Context): ESTree.ContinueStatement;
export declare function parseBreakStatement(parser: ParserState, context: Context): ESTree.BreakStatement;
export declare function parseWithStatement(parser: ParserState, context: Context): ESTree.WithStatement;
export declare function parseIfStatement(parser: ParserState, context: Context, labels: any): ESTree.IfStatement;
export declare function parseConsequentOrAlternate(parser: ParserState, context: Context, labels: any): ESTree.Statement | ESTree.FunctionDeclaration;
export declare function parseSwitchStatement(parser: ParserState, context: Context, labels: any): ESTree.SwitchStatement;
export declare function parseWhileStatement(parser: ParserState, context: Context, labels: any): ESTree.WhileStatement;
export declare function parseContinueStatement(parser: ParserState, context: Context, labels: any): ESTree.ContinueStatement;
export declare function parseBreakStatement(parser: ParserState, context: Context, labels: any): ESTree.BreakStatement;
export declare function parseWithStatement(parser: ParserState, context: Context, labels: any): ESTree.WithStatement;
export declare function parseDebuggerStatement(parser: ParserState, context: Context): ESTree.DebuggerStatement;
export declare function parseTryStatement(parser: ParserState, context: Context): ESTree.TryStatement;
export declare function parseCatchBlock(parser: ParserState, context: Context): ESTree.CatchClause;
export declare function parseDoWhileStatement(parser: ParserState, context: Context): ESTree.DoWhileStatement;
export declare function parseTryStatement(parser: ParserState, context: Context, labels: any): ESTree.TryStatement;
export declare function parseCatchBlock(parser: ParserState, context: Context, labels: any): ESTree.CatchClause;
export declare function parseDoWhileStatement(parser: ParserState, context: Context, labels: any): ESTree.DoWhileStatement;
export declare function parseLetIdentOrVarDeclarationStatement(parser: ParserState, context: Context): ESTree.VariableDeclaration | ESTree.LabeledStatement | ESTree.ExpressionStatement;
export declare function parseVariableStatement(parser: ParserState, context: Context, type: BindingType, origin: BindingOrigin): ESTree.VariableDeclaration;
export declare function parseVariableDeclarationList(parser: ParserState, context: Context, type: BindingType, origin: BindingOrigin): ESTree.VariableDeclarator[];
export declare function parseForStatement(parser: ParserState, context: Context): ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement;
export declare function parseForStatement(parser: ParserState, context: Context, labels: any): ESTree.ForStatement | ESTree.ForInStatement | ESTree.ForOfStatement;
export declare function parseExpression(parser: ParserState, context: Context, assignable: 0 | 1): ESTree.Expression;

@@ -65,3 +65,3 @@ export declare function parseSequenceExpression(parser: ParserState, context: Context, expr: ESTree.AssignmentExpression | ESTree.Expression): ESTree.SequenceExpression;

export declare function parseTemplateTail(parser: ParserState, context: Context): ESTree.TemplateElement;
export declare function parseTemplate(parser: ParserState, context: Context): any;
export declare function parseTemplate(parser: ParserState, context: Context): ESTree.TemplateLiteral;
export declare function parseTemplateSpans(parser: ParserState, tail: boolean): ESTree.TemplateElement;

@@ -73,7 +73,7 @@ export declare function parseArguments(parser: ParserState, context: Context): (ESTree.SpreadElement | ESTree.Expression)[];

export declare function parseThisExpression(parser: ParserState, context: Context): ESTree.ThisExpression;
export declare function parseFunctionDeclaration(parser: ParserState, context: Context, flags: ParseFunctionFlag, isAsync: 0 | 1): ESTree.FunctionDeclaration;
export declare function parseFunctionDeclaration(parser: ParserState, context: Context, allowGen: 0 | 1, isExportDefault: 0 | 1, isAsync: 0 | 1): ESTree.FunctionDeclaration;
export declare function parseFunctionExpression(parser: ParserState, context: Context, isAsync: 0 | 1): ESTree.FunctionExpression;
export declare function parseArrayExpressionOrPattern(parser: ParserState, context: Context, skipInitializer: 0 | 1, type: BindingType): ESTree.ArrayExpression | ESTree.ArrayPattern;
export declare function parseArrayExpressionOrPattern(parser: ParserState, context: Context, skipInitializer: 0 | 1, inGroup: 0 | 1, type: BindingType): ESTree.ArrayExpression | ESTree.ArrayPattern;
export declare function parseMethodDefinition(parser: ParserState, context: Context, kind: PropertyKind): ESTree.FunctionExpression;
export declare function parseObjectLiteralOrPattern(parser: ParserState, context: Context, skipInitializer: 0 | 1, type: BindingType): ESTree.ObjectExpression | ESTree.ObjectPattern | ESTree.AssignmentExpression;
export declare function parseObjectLiteralOrPattern(parser: ParserState, context: Context, skipInitializer: 0 | 1, inGroup: 0 | 1, type: BindingType): ESTree.ObjectExpression | ESTree.ObjectPattern | ESTree.AssignmentExpression;
export declare function parseMethodFormals(parser: ParserState, context: Context, kind: PropertyKind, type: BindingType): any[];

@@ -90,3 +90,3 @@ export declare function parseComputedPropertyName(parser: ParserState, context: Context): ESTree.Expression;

export declare function parseRegExpLiteral(parser: ParserState, context: Context): ESTree.RegExpLiteral;
export declare function parseClassDeclaration(parser: ParserState, context: Context, requireIdentifier: 0 | 1): ESTree.ClassDeclaration;
export declare function parseClassDeclaration(parser: ParserState, context: Context, isExportDefault: 0 | 1): ESTree.ClassDeclaration;
export declare function parseClassExpression(parser: ParserState, context: Context): ESTree.ClassExpression;

@@ -96,3 +96,3 @@ export declare function parseDecorators(parser: ParserState, context: Context): ESTree.Decorator[];

export declare function parseFieldDefinition(parser: ParserState, context: Context, key: ESTree.PrivateName | ESTree.Expression | null, state: PropertyKind, decorators: ESTree.Decorator[] | null): ESTree.FieldDefinition;
export declare function parseBindingPattern(parser: ParserState, context: Context, type: BindingType): any;
export declare function parseBindingPattern(parser: ParserState, context: Context, type: BindingType): ESTree.Pattern | ESTree.Identifier;
//# sourceMappingURL=parser.d.ts.map

@@ -0,0 +0,0 @@ ISC License

{
"name": "meriyah",
"version": "0.1.12",
"version": "0.1.13-dev.20190527",
"description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",

@@ -81,6 +81,6 @@ "main": "dist/meriyah.umd.js",

"test262-parser-tests": "0.0.5",
"ts-node": "^8.1.0",
"ts-node": "^8.1.1",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.16.0",
"tslint-microsoft-contrib": "^6.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.4.5",

@@ -95,2 +95,2 @@ "unexpected": "^11.6.0",

}
}
}

@@ -0,0 +0,0 @@ <p align="center">

@@ -87,3 +87,3 @@ import { Token, KeywordDescTable } from './token';

MustDestruct = 1 << 3,
CannotDestruct = 1 << 4,
CannotDestruct = 1 << 4,
// Only destructible if assignable

@@ -110,8 +110,2 @@ AssignableDestruct = 1 << 5,

export const enum ParseFunctionFlag {
None = 0,
DisallowGenerator = 1 << 0,
RequireIdentifier = 1 << 1,
}
export const enum FunctionStatement {

@@ -127,3 +121,2 @@ Disallow,

source: string;
flags: Flags;

@@ -206,3 +199,3 @@ index: number;

*
* @param {ParserState} parser
* @param parser Parser state
* @param {*} node

@@ -243,43 +236,66 @@ */

export function validateIdentifier(parser: ParserState, context: Context, type: BindingType, token: Token): void {
if ((token & Token.Keyword) !== Token.Keyword) return;
if (token === Token.StaticKeyword) {
if (context & Context.Strict) report(parser, Errors.InvalidStrictStatic);
/**
* Validates binding identifier
*
* @param parser Parser state
* @param context Context masks
* @param type Binding type
* @param token Token
*/
export function validateBindingIdentifier(
parser: ParserState,
context: Context,
type: BindingType,
t: Token
): void {
if ((t & Token.Keyword) !== Token.Keyword) return;
if (context & Context.Strict) {
if (t === Token.StaticKeyword) {
report(parser, Errors.InvalidStrictStatic);
}
if ((t & Token.FutureReserved) === Token.FutureReserved) {
report(parser, Errors.FutureReservedWordInStrictModeNotId);
}
if ((t & Token.IsEvalOrArguments) === Token.IsEvalOrArguments) {
report(parser, Errors.StrictEvalArguments);
}
if (t === Token.EscapedFutureReserved) {
report(parser, Errors.InvalidEscapedKeyword);
}
}
if ((token & Token.Reserved) === Token.Reserved) {
if ((t & Token.Reserved) === Token.Reserved) {
report(parser, Errors.KeywordNotId);
}
if ((token & Token.FutureReserved) === Token.FutureReserved) {
if (context & Context.Strict) report(parser, Errors.FutureReservedWordInStrictModeNotId);
if (type & (BindingType.Let | BindingType.Const) && t === Token.LetKeyword) {
report(parser, Errors.InvalidLetConstBinding);
}
if (token === Token.LetKeyword) {
if (type & (BindingType.Let | BindingType.Const)) report(parser, Errors.InvalidLetConstBinding);
}
if (token === Token.AwaitKeyword) {
if (context & (Context.InAwaitContext | Context.Module)) {
if (context & (Context.InAwaitContext | Context.Module) && t === Token.AwaitKeyword) {
report(parser, Errors.AwaitOutsideAsync);
}
}
if (token === Token.YieldKeyword) {
if (context & (Context.InYieldContext | Context.Strict)) {
if (context & (Context.InYieldContext | Context.Strict) && t === Token.YieldKeyword) {
report(parser, Errors.DisallowedInContext, 'yield');
}
}
if ((token & Token.IsEvalOrArguments) === Token.IsEvalOrArguments) {
if (context & Context.Strict) {
report(parser, Errors.UnexpectedToken, 'asdf');
}
}
if (context & Context.Strict && token === Token.EscapedFutureReserved) {
if (t === Token.EscapedReserved) {
report(parser, Errors.InvalidEscapedKeyword);
}
if (token === Token.EscapedReserved) {
report(parser, Errors.InvalidEscapedKeyword);
}
}
/**
* Validates binding identifier
*
* @param parser Parser state
* @param context Context masks
* @param t Token
*/
export function isStrictReservedWord(parser: ParserState, context: Context, t: Token): boolean {

@@ -300,16 +316,2 @@ if (t === Token.AwaitKeyword) {

export function validateArrowBlockBody(parser: ParserState): void {
switch (parser.token) {
case Token.Period:
case Token.LeftBracket:
case Token.TemplateTail:
report(parser, Errors.InvalidAccessedBlockBodyArrow);
case Token.LeftParen:
report(parser, Errors.InvalidInvokedBlockBodyArrow);
default: // ignore
}
if ((parser.token & Token.IsBinaryOp) === Token.IsBinaryOp && (parser.flags & Flags.NewLine) === 0 ) report(parser, Errors.InvalidArrowPostfix);
if ((parser.token & Token.IsUpdateOp) === Token.IsUpdateOp) report(parser, Errors.InvalidArrowPostfix);
}
/**

@@ -324,1 +326,42 @@ * Checks if the property has any private field key

}
/**
* Checks if a label in `LabelledStatement` are valid or not
*
* @param parser Parser state
* @param labels Object holding the labels
* @param name Current label
* @param isIterationStatement
*/
export function isValidLabel(parser: ParserState, labels: any, name: string, isIterationStatement: 0 | 1): 0 | 1 {
do {
if (labels['€' + name]) {
if (isIterationStatement) report(parser, Errors.InvalidNestedStatement);
return 1;
}
if (isIterationStatement && labels.loop) isIterationStatement = 0;
labels = labels['€'];
} while (labels);
return 0;
}
/**
* Checks if current label already have been declrared, and if not
* declare it
*
* @param parser Parser state
* @param labels Object holding the labels
* @param name Current label
*/
export function validateAndDeclareLabel(parser: ParserState, labels: any, name: string): void {
let set = labels;
do {
if (set['€' + name]) report(parser, Errors.LabelRedeclaration, name);
set = set['€'];
} while (set);
labels['€' + name] = 1;
}

@@ -149,3 +149,11 @@ import { ParserState } from './common';

InvalidClassFieldConstructor,
InvalidClassFieldArgEval
InvalidClassFieldArgEval,
InvalidGeneratorFunction,
AsyncRestrictedProd,
UnexpectedCharAfterObjLit,
InvalidObjLitKey,
InvalidKeyToken,
LabelRedeclaration,
InvalidNestedStatement,
UnknownLabel
}

@@ -205,2 +213,3 @@

[Errors.InvalidComputedPropName]: 'A computed property name must be followed by a colon or paren',
[Errors.InvalidObjLitKey]: 'Object literal keys that are strings or numbers must be a method or have a colon',
[Errors.InvalidAsyncGetter]: 'Found `* async x(){}` but this should be `async * x(){}`',

@@ -311,3 +320,10 @@ [Errors.InvalidGetSetGenerator]: 'Getters and setters can not be generators',

[Errors.InvalidStaticClassFieldConstructor]: 'Classes may not have a private element named constructor',
[Errors.InvalidClassFieldArgEval]: 'A class field initializer may not contain arguments'
[Errors.InvalidClassFieldArgEval]: 'A class field initializer may not contain arguments',
[Errors.InvalidGeneratorFunction]: 'Generators can only be declared at the top level or inside a block',
[Errors.AsyncRestrictedProd]: 'Async methods are a restricted production and cannot have a newline following it',
[Errors.UnexpectedCharAfterObjLit]: 'Unexpected character after object literal property name',
[Errors.InvalidKeyToken]: 'Invalid key token',
[Errors.LabelRedeclaration]: "Label '%0' has already been declared",
[Errors.InvalidNestedStatement]: 'continue statement must be nested within an iteration statement',
[Errors.UnknownLabel]: "Undefined label '%0'"
};

@@ -314,0 +330,0 @@

import { unicodeLookup } from '../unicode';
import { Chars } from '../chars';

@@ -171,3 +172,3 @@ export const enum CharFlags {

export function isIdentifierPart(code: number): number {
export function isIdentifierPart(code: number): any {
/*

@@ -185,3 +186,3 @@ * ES2020 11.6 IdentifierPart

? CharTypes[code] & CharFlags.IdentifierPart
: (unicodeLookup[(code >>> 5) + 0] >>> code) & 31 & 1;
: (unicodeLookup[(code >>> 5) + 0] >>> code) & 31 & 1 || (code === Chars.ZeroWidthJoiner || code === Chars.ZeroWidthNonJoiner);
}

@@ -22,3 +22,3 @@ import { nextCodePoint, CharTypes, CharFlags } from './';

} else {
report(parser, Errors.UnterminatedComment);
report(parser, Errors.IllegalCaracter, '#');
}

@@ -25,0 +25,0 @@ }

@@ -10,4 +10,4 @@ import { ParserState, Context } from '../common';

export function scanIdentifier(parser: ParserState, context: Context): Token {
let hasEscape = false;
let canBeKeyword = (CharTypes[parser.currentCodePoint] & CharFlags.KeywordCandidate) !== 0;
let hasEscape: 0 | 1 = 0;
let canBeKeyword: number = CharTypes[parser.currentCodePoint] & CharFlags.KeywordCandidate;
parser.tokenValue = '';

@@ -24,6 +24,6 @@ if (parser.currentCodePoint <= 0x7e) {

} else {
hasEscape = true;
hasEscape = 1;
const code = scanIdentifierUnicodeEscape(parser);
if (!isIdentifierPart(code)) report(parser, Errors.InvalidUnicodeEscapeSequence);
canBeKeyword = (CharTypes[code] & CharFlags.KeywordCandidate) !== 0;
canBeKeyword = CharTypes[code] & CharFlags.KeywordCandidate;
parser.tokenValue += fromCodePoint(code);

@@ -39,13 +39,13 @@ }

context: Context,
hasEscape: boolean,
canBeKeyword: boolean
hasEscape: 0 | 1,
canBeKeyword: number
): Token {
let start = parser.index;
while (parser.index < parser.length) {
if ((parser.currentCodePoint & 8) === 8 && parser.currentCodePoint === Chars.Backslash) {
if (CharTypes[parser.currentCodePoint] & CharFlags.BackSlash) {
parser.tokenValue += parser.source.slice(start, parser.index);
hasEscape = true;
hasEscape = 1;
const code = scanIdentifierUnicodeEscape(parser);
if (!isIdentifierPart(code)) report(parser, Errors.InvalidUnicodeEscapeSequence);
canBeKeyword = canBeKeyword && (CharTypes[code] & CharFlags.KeywordCandidate) !== 0;
canBeKeyword = canBeKeyword && CharTypes[code] & CharFlags.KeywordCandidate;
parser.tokenValue += fromCodePoint(code);

@@ -71,11 +71,12 @@ start = parser.index;

const keyword: Token | undefined = descKeywordTable[parser.tokenValue as string];
if (keyword === undefined) return Token.Identifier;
if (keyword === Token.YieldKeyword) return keyword;
if ((keyword & Token.FutureReserved) === Token.FutureReserved) {
return context & Context.Strict && hasEscape ? Token.EscapedFutureReserved : keyword;
}
return context & Context.Strict && (keyword === Token.LetKeyword || keyword === Token.StaticKeyword)
return keyword === void 0
? Token.Identifier
: keyword === Token.YieldKeyword
? keyword
: (keyword & Token.FutureReserved) === Token.FutureReserved
? context & Context.Strict && hasEscape
? Token.EscapedFutureReserved
: keyword
: context & Context.Strict && (keyword === Token.LetKeyword || keyword === Token.StaticKeyword)
? Token.EscapedFutureReserved

@@ -82,0 +83,0 @@ : Token.EscapedReserved;

@@ -0,0 +0,0 @@ import { Context } from './common';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc