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

shift-parser

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shift-parser - npm Package Compare versions

Comparing version 5.0.2 to 5.0.3

dist/unicode.js

102

dist/early-error-state.js

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -24,5 +24,5 @@ Object.defineProperty(exports, "__esModule", {

require("es6-map/implement");
require('es6-map/implement');
var _multimap = require("multimap");
var _multimap = require('multimap');

@@ -103,3 +103,3 @@ var _multimap2 = _interopRequireDefault(_multimap);

_createClass(EarlyErrorState, [{
key: "addFreeBreakStatement",
key: 'addFreeBreakStatement',
value: function addFreeBreakStatement(s) {

@@ -110,3 +110,3 @@ this.freeBreakStatements.push(s);

}, {
key: "addFreeLabeledBreakStatement",
key: 'addFreeLabeledBreakStatement',
value: function addFreeLabeledBreakStatement(s) {

@@ -117,3 +117,3 @@ this.freeLabeledBreakStatements.push(s);

}, {
key: "clearFreeBreakStatements",
key: 'clearFreeBreakStatements',
value: function clearFreeBreakStatements() {

@@ -124,3 +124,3 @@ this.freeBreakStatements = [];

}, {
key: "addFreeContinueStatement",
key: 'addFreeContinueStatement',
value: function addFreeContinueStatement(s) {

@@ -131,3 +131,3 @@ this.freeContinueStatements.push(s);

}, {
key: "addFreeLabeledContinueStatement",
key: 'addFreeLabeledContinueStatement',
value: function addFreeLabeledContinueStatement(s) {

@@ -138,3 +138,3 @@ this.freeLabeledContinueStatements.push(s);

}, {
key: "clearFreeContinueStatements",
key: 'clearFreeContinueStatements',
value: function clearFreeContinueStatements() {

@@ -145,3 +145,3 @@ this.freeContinueStatements = [];

}, {
key: "enforceFreeBreakStatementErrors",
key: 'enforceFreeBreakStatementErrors',
value: function enforceFreeBreakStatementErrors(createError) {

@@ -153,3 +153,3 @@ [].push.apply(this.errors, this.freeBreakStatements.map(createError));

}, {
key: "enforceFreeLabeledBreakStatementErrors",
key: 'enforceFreeLabeledBreakStatementErrors',
value: function enforceFreeLabeledBreakStatementErrors(createError) {

@@ -161,3 +161,3 @@ [].push.apply(this.errors, this.freeLabeledBreakStatements.map(createError));

}, {
key: "enforceFreeContinueStatementErrors",
key: 'enforceFreeContinueStatementErrors',
value: function enforceFreeContinueStatementErrors(createError) {

@@ -169,3 +169,3 @@ [].push.apply(this.errors, this.freeContinueStatements.map(createError));

}, {
key: "enforceFreeLabeledContinueStatementErrors",
key: 'enforceFreeLabeledContinueStatementErrors',
value: function enforceFreeLabeledContinueStatementErrors(createError) {

@@ -177,3 +177,3 @@ [].push.apply(this.errors, this.freeLabeledContinueStatements.map(createError));

}, {
key: "observeIterationLabel",
key: 'observeIterationLabel',
value: function observeIterationLabel(label) {

@@ -190,3 +190,3 @@ this.usedLabelNames.push(label);

}, {
key: "observeNonIterationLabel",
key: 'observeNonIterationLabel',
value: function observeNonIterationLabel(label) {

@@ -200,3 +200,3 @@ this.usedLabelNames.push(label);

}, {
key: "clearUsedLabelNames",
key: 'clearUsedLabelNames',
value: function clearUsedLabelNames() {

@@ -207,3 +207,3 @@ this.usedLabelNames = [];

}, {
key: "observeSuperCallExpression",
key: 'observeSuperCallExpression',
value: function observeSuperCallExpression(node) {

@@ -214,3 +214,3 @@ this.superCallExpressions.push(node);

}, {
key: "observeConstructorMethod",
key: 'observeConstructorMethod',
value: function observeConstructorMethod() {

@@ -222,3 +222,3 @@ this.superCallExpressionsInConstructorMethod = this.superCallExpressions;

}, {
key: "clearSuperCallExpressionsInConstructorMethod",
key: 'clearSuperCallExpressionsInConstructorMethod',
value: function clearSuperCallExpressionsInConstructorMethod() {

@@ -229,3 +229,3 @@ this.superCallExpressionsInConstructorMethod = [];

}, {
key: "enforceSuperCallExpressions",
key: 'enforceSuperCallExpressions',
value: function enforceSuperCallExpressions(createError) {

@@ -239,3 +239,3 @@ [].push.apply(this.errors, this.superCallExpressions.map(createError));

}, {
key: "enforceSuperCallExpressionsInConstructorMethod",
key: 'enforceSuperCallExpressionsInConstructorMethod',
value: function enforceSuperCallExpressionsInConstructorMethod(createError) {

@@ -247,3 +247,3 @@ [].push.apply(this.errors, this.superCallExpressionsInConstructorMethod.map(createError));

}, {
key: "observeSuperPropertyExpression",
key: 'observeSuperPropertyExpression',
value: function observeSuperPropertyExpression(node) {

@@ -254,3 +254,3 @@ this.superPropertyExpressions.push(node);

}, {
key: "clearSuperPropertyExpressions",
key: 'clearSuperPropertyExpressions',
value: function clearSuperPropertyExpressions() {

@@ -261,3 +261,3 @@ this.superPropertyExpressions = [];

}, {
key: "enforceSuperPropertyExpressions",
key: 'enforceSuperPropertyExpressions',
value: function enforceSuperPropertyExpressions(createError) {

@@ -269,3 +269,3 @@ [].push.apply(this.errors, this.superPropertyExpressions.map(createError));

}, {
key: "observeNewTargetExpression",
key: 'observeNewTargetExpression',
value: function observeNewTargetExpression(node) {

@@ -276,3 +276,3 @@ this.newTargetExpressions.push(node);

}, {
key: "clearNewTargetExpressions",
key: 'clearNewTargetExpressions',
value: function clearNewTargetExpressions() {

@@ -283,3 +283,3 @@ this.newTargetExpressions = [];

}, {
key: "bindName",
key: 'bindName',
value: function bindName(name, node) {

@@ -290,3 +290,3 @@ this.boundNames.set(name, node);

}, {
key: "clearBoundNames",
key: 'clearBoundNames',
value: function clearBoundNames() {

@@ -297,3 +297,3 @@ this.boundNames = new _multimap2.default();

}, {
key: "observeLexicalDeclaration",
key: 'observeLexicalDeclaration',
value: function observeLexicalDeclaration() {

@@ -305,3 +305,3 @@ this.lexicallyDeclaredNames.addEach(this.boundNames);

}, {
key: "observeLexicalBoundary",
key: 'observeLexicalBoundary',
value: function observeLexicalBoundary() {

@@ -314,7 +314,7 @@ this.previousLexicallyDeclaredNames = this.lexicallyDeclaredNames;

}, {
key: "enforceDuplicateLexicallyDeclaredNames",
key: 'enforceDuplicateLexicallyDeclaredNames',
value: function enforceDuplicateLexicallyDeclaredNames(createError) {
var _this2 = this;
this.lexicallyDeclaredNames.forEachEntry(function (nodes /*, bindingName*/) {
this.lexicallyDeclaredNames.forEachEntry(function (nodes /* , bindingName*/) {
if (nodes.length > 1) {

@@ -329,3 +329,3 @@ nodes.slice(1).forEach(function (dupeNode) {

}, {
key: "enforceConflictingLexicallyDeclaredNames",
key: 'enforceConflictingLexicallyDeclaredNames',
value: function enforceConflictingLexicallyDeclaredNames(otherNames, createError) {

@@ -344,3 +344,3 @@ var _this3 = this;

}, {
key: "observeFunctionDeclaration",
key: 'observeFunctionDeclaration',
value: function observeFunctionDeclaration() {

@@ -353,3 +353,3 @@ this.observeVarBoundary();

}, {
key: "functionDeclarationNamesAreLexical",
key: 'functionDeclarationNamesAreLexical',
value: function functionDeclarationNamesAreLexical() {

@@ -361,3 +361,3 @@ this.lexicallyDeclaredNames.addEach(this.functionDeclarationNames);

}, {
key: "observeVarDeclaration",
key: 'observeVarDeclaration',
value: function observeVarDeclaration() {

@@ -369,3 +369,3 @@ this.varDeclaredNames.addEach(this.boundNames);

}, {
key: "recordForOfVars",
key: 'recordForOfVars',
value: function recordForOfVars() {

@@ -380,3 +380,3 @@ var _this4 = this;

}, {
key: "observeVarBoundary",
key: 'observeVarBoundary',
value: function observeVarBoundary() {

@@ -390,3 +390,3 @@ this.lexicallyDeclaredNames = new _multimap2.default();

}, {
key: "exportName",
key: 'exportName',
value: function exportName(name, node) {

@@ -397,3 +397,3 @@ this.exportedNames.set(name, node);

}, {
key: "exportDeclaredNames",
key: 'exportDeclaredNames',
value: function exportDeclaredNames() {

@@ -405,3 +405,3 @@ this.exportedNames.addEach(this.lexicallyDeclaredNames).addEach(this.varDeclaredNames);

}, {
key: "exportBinding",
key: 'exportBinding',
value: function exportBinding(name, node) {

@@ -412,3 +412,3 @@ this.exportedBindings.set(name, node);

}, {
key: "clearExportedBindings",
key: 'clearExportedBindings',
value: function clearExportedBindings() {

@@ -419,3 +419,3 @@ this.exportedBindings = new _multimap2.default();

}, {
key: "observeYieldExpression",
key: 'observeYieldExpression',
value: function observeYieldExpression(node) {

@@ -426,3 +426,3 @@ this.yieldExpressions.push(node);

}, {
key: "clearYieldExpressions",
key: 'clearYieldExpressions',
value: function clearYieldExpressions() {

@@ -433,3 +433,3 @@ this.yieldExpressions = [];

}, {
key: "addError",
key: 'addError',
value: function addError(e) {

@@ -440,3 +440,3 @@ this.errors.push(e);

}, {
key: "addStrictError",
key: 'addStrictError',
value: function addStrictError(e) {

@@ -447,3 +447,3 @@ this.strictErrors.push(e);

}, {
key: "enforceStrictErrors",
key: 'enforceStrictErrors',
value: function enforceStrictErrors() {

@@ -458,3 +458,3 @@ [].push.apply(this.errors, this.strictErrors);

}, {
key: "concat",
key: 'concat',
value: function concat(s) {

@@ -485,3 +485,3 @@ if (this === identity) return s;

}], [{
key: "empty",
key: 'empty',
value: function empty() {

@@ -497,3 +497,3 @@ return identity;

Object.getOwnPropertyNames(EarlyErrorState.prototype).forEach(function (methodName) {
if (methodName === "constructor") return;
if (methodName === 'constructor') return;
Object.defineProperty(identity, methodName, {

@@ -515,3 +515,3 @@ value: function value() {

var _this5 = _possibleConstructorReturn(this, Object.getPrototypeOf(EarlyError).call(this, message));
var _this5 = _possibleConstructorReturn(this, (EarlyError.__proto__ || Object.getPrototypeOf(EarlyError)).call(this, message));

@@ -518,0 +518,0 @@ _this5.node = node;

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -12,12 +12,10 @@ Object.defineProperty(exports, "__esModule", {

var _shiftReducer = require("shift-reducer");
var _shiftReducer = require('shift-reducer');
var _shiftReducer2 = _interopRequireDefault(_shiftReducer);
var _utils = require("./utils");
var _utils = require('./utils');
var _earlyErrorState = require("./early-error-state");
var _earlyErrorState = require('./early-error-state');
var _patternAcceptor = require("./pattern-acceptor");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -49,20 +47,8 @@

return directives.some(function (directive) {
return directive.rawValue === "use strict";
return directive.rawValue === 'use strict';
});
}
function containsDuplicates(list) {
var uniqs = [];
for (var i = 0, l = list.length; i < l; ++i) {
var item = list[i];
if (uniqs.indexOf(item) >= 0) {
return true;
}
uniqs.push(item);
}
return false;
}
function isLabelledFunction(node) {
return node.type === "LabeledStatement" && (node.body.type === "FunctionDeclaration" || isLabelledFunction(node.body));
return node.type === 'LabeledStatement' && (node.body.type === 'FunctionDeclaration' || isLabelledFunction(node.body));
}

@@ -72,9 +58,9 @@

switch (node.type) {
case "LabeledStatement":
case 'LabeledStatement':
return isIterationStatement(node.body);
case "DoWhileStatement":
case "ForInStatement":
case "ForOfStatement":
case "ForStatement":
case "WhileStatement":
case 'DoWhileStatement':
case 'ForInStatement':
case 'ForOfStatement':
case 'ForStatement':
case 'WhileStatement':
return true;

@@ -86,14 +72,14 @@ }

function isSpecialMethod(methodDefinition) {
if (methodDefinition.name.type !== "StaticPropertyName" || methodDefinition.name.value !== "constructor") {
if (methodDefinition.name.type !== 'StaticPropertyName' || methodDefinition.name.value !== 'constructor') {
return false;
}
switch (methodDefinition.type) {
case "Getter":
case "Setter":
case 'Getter':
case 'Setter':
return true;
case "Method":
case 'Method':
return methodDefinition.isGenerator;
}
/* istanbul ignore next */
throw new Error("not reached");
throw new Error('not reached');
}

@@ -103,7 +89,7 @@

var ctors = node.elements.filter(function (e) {
return !e.isStatic && e.method.type === "Method" && !e.method.isGenerator && e.method.name.type === "StaticPropertyName" && e.method.name.value === "constructor";
return !e.isStatic && e.method.type === 'Method' && !e.method.isGenerator && e.method.name.type === 'StaticPropertyName' && e.method.name.value === 'constructor';
});
if (ctors.length > 1) {
ctors.slice(1).forEach(function (ctor) {
s = s.addError(new _earlyErrorState.EarlyError(ctor, "Duplicate constructor method in class"));
s = s.addError(new _earlyErrorState.EarlyError(ctor, 'Duplicate constructor method in class'));
});

@@ -115,21 +101,21 @@ }

var SUPERCALL_ERROR = function SUPERCALL_ERROR(node) {
return new _earlyErrorState.EarlyError(node, "Calls to super must be in the \"constructor\" method of a class expression or class declaration that has a superclass");
return new _earlyErrorState.EarlyError(node, 'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass');
};
var SUPERPROPERTY_ERROR = function SUPERPROPERTY_ERROR(node) {
return new _earlyErrorState.EarlyError(node, "Member access on super must be in a method");
return new _earlyErrorState.EarlyError(node, 'Member access on super must be in a method');
};
var DUPLICATE_BINDING = function DUPLICATE_BINDING(node) {
return new _earlyErrorState.EarlyError(node, "Duplicate binding " + JSON.stringify(node.name));
return new _earlyErrorState.EarlyError(node, 'Duplicate binding ' + JSON.stringify(node.name));
};
var FREE_CONTINUE = function FREE_CONTINUE(node) {
return new _earlyErrorState.EarlyError(node, "Continue statement must be nested within an iteration statement");
return new _earlyErrorState.EarlyError(node, 'Continue statement must be nested within an iteration statement');
};
var UNBOUND_CONTINUE = function UNBOUND_CONTINUE(node) {
return new _earlyErrorState.EarlyError(node, "Continue statement must be nested within an iteration statement with label " + JSON.stringify(node.label));
return new _earlyErrorState.EarlyError(node, 'Continue statement must be nested within an iteration statement with label ' + JSON.stringify(node.label));
};
var FREE_BREAK = function FREE_BREAK(node) {
return new _earlyErrorState.EarlyError(node, "Break statement must be nested within an iteration statement or a switch statement");
return new _earlyErrorState.EarlyError(node, 'Break statement must be nested within an iteration statement or a switch statement');
};
var UNBOUND_BREAK = function UNBOUND_BREAK(node) {
return new _earlyErrorState.EarlyError(node, "Break statement must be nested within a statement with label " + JSON.stringify(node.label));
return new _earlyErrorState.EarlyError(node, 'Break statement must be nested within a statement with label ' + JSON.stringify(node.label));
};

@@ -143,16 +129,16 @@

return _possibleConstructorReturn(this, Object.getPrototypeOf(EarlyErrorChecker).call(this, _earlyErrorState.EarlyErrorState));
return _possibleConstructorReturn(this, (EarlyErrorChecker.__proto__ || Object.getPrototypeOf(EarlyErrorChecker)).call(this, _earlyErrorState.EarlyErrorState));
}
_createClass(EarlyErrorChecker, [{
key: "reduceAssignmentExpression",
key: 'reduceAssignmentExpression',
value: function reduceAssignmentExpression() {
return _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceAssignmentExpression", this).apply(this, arguments).clearBoundNames();
return _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceAssignmentExpression', this).apply(this, arguments).clearBoundNames();
}
}, {
key: "reduceAssignmentTargetIdentifier",
key: 'reduceAssignmentTargetIdentifier',
value: function reduceAssignmentTargetIdentifier(node) {
var s = this.identity;
if ((0, _utils.isRestrictedWord)(node.name) || (0, _utils.isStrictModeReservedWord)(node.name)) {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "The identifier " + JSON.stringify(node.name) + " must not be in binding position in strict mode"));
if (node.name === 'eval' || node.name === 'arguments' || (0, _utils.isStrictModeReservedWord)(node.name)) {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'The identifier ' + JSON.stringify(node.name) + ' must not be in binding position in strict mode'));
}

@@ -162,12 +148,12 @@ return s;

}, {
key: "reduceArrowExpression",
key: 'reduceArrowExpression',
value: function reduceArrowExpression(node, _ref2) {
var params = _ref2.params;
var body = _ref2.body;
var params = _ref2.params,
body = _ref2.body;
var isSimpleParameterList = node.params.rest == null && node.params.items.every(function (i) {
return i.type === "BindingIdentifier";
return i.type === 'BindingIdentifier';
});
params = params.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);
if (node.body.type === "FunctionBody") {
if (node.body.type === 'FunctionBody') {
body = body.enforceConflictingLexicallyDeclaredNames(params.lexicallyDeclaredNames, DUPLICATE_BINDING);

@@ -179,11 +165,8 @@ if (isStrictFunctionBody(node.body)) {

}
body.yieldExpressions.forEach(function (node) {
body = body.addError(new _earlyErrorState.EarlyError(node, "Concise arrow bodies must not contain yield expressions"));
});
params.yieldExpressions.forEach(function (node) {
params = params.addError(new _earlyErrorState.EarlyError(node, "Arrow parameters must not contain yield expressions"));
params = params.addError(new _earlyErrorState.EarlyError(node, 'Arrow parameters must not contain yield expressions'));
});
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceArrowExpression", this).call(this, node, { params: params, body: body });
if (!isSimpleParameterList && node.body.type === "FunctionBody" && isStrictFunctionBody(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Functions with non-simple parameter lists may not contain a \"use strict\" directive"));
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceArrowExpression', this).call(this, node, { params: params, body: body });
if (!isSimpleParameterList && node.body.type === 'FunctionBody' && isStrictFunctionBody(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive'));
}

@@ -195,7 +178,7 @@ s = s.clearYieldExpressions();

}, {
key: "reduceBindingIdentifier",
key: 'reduceBindingIdentifier',
value: function reduceBindingIdentifier(node) {
var s = this.identity;
if ((0, _utils.isRestrictedWord)(node.name) || (0, _utils.isStrictModeReservedWord)(node.name)) {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "The identifier " + JSON.stringify(node.name) + " must not be in binding position in strict mode"));
if (node.name === 'eval' || node.name === 'arguments' || (0, _utils.isStrictModeReservedWord)(node.name)) {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'The identifier ' + JSON.stringify(node.name) + ' must not be in binding position in strict mode'));
}

@@ -206,5 +189,5 @@ s = s.bindName(node.name, node);

}, {
key: "reduceBlock",
key: 'reduceBlock',
value: function reduceBlock() {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceBlock", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceBlock', this).apply(this, arguments);
s = s.functionDeclarationNamesAreLexical();

@@ -217,5 +200,5 @@ s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);

}, {
key: "reduceBreakStatement",
key: 'reduceBreakStatement',
value: function reduceBreakStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceBreakStatement", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceBreakStatement', this).apply(this, arguments);
s = node.label == null ? s.addFreeBreakStatement(node) : s.addFreeLabeledBreakStatement(node);

@@ -225,6 +208,6 @@ return s;

}, {
key: "reduceCallExpression",
key: 'reduceCallExpression',
value: function reduceCallExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceCallExpression", this).apply(this, arguments);
if (node.callee.type === "Super") {
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceCallExpression', this).apply(this, arguments);
if (node.callee.type === 'Super') {
s = s.observeSuperCallExpression(node);

@@ -235,6 +218,6 @@ }

}, {
key: "reduceCatchClause",
key: 'reduceCatchClause',
value: function reduceCatchClause(node, _ref3) {
var binding = _ref3.binding;
var body = _ref3.body;
var binding = _ref3.binding,
body = _ref3.body;

@@ -253,3 +236,3 @@ binding = binding.observeLexicalDeclaration();

});
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceCatchClause", this).call(this, node, { binding: binding, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceCatchClause', this).call(this, node, { binding: binding, body: body });
s = s.observeLexicalBoundary();

@@ -259,7 +242,7 @@ return s;

}, {
key: "reduceClassDeclaration",
key: 'reduceClassDeclaration',
value: function reduceClassDeclaration(node, _ref4) {
var name = _ref4.name;
var _super = _ref4.super;
var elements = _ref4.elements;
var name = _ref4.name,
_super = _ref4.super,
elements = _ref4.elements;

@@ -282,10 +265,10 @@ var s = name;

}, {
key: "reduceClassElement",
key: 'reduceClassElement',
value: function reduceClassElement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceClassElement", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceClassElement', this).apply(this, arguments);
if (!node.isStatic && isSpecialMethod(node.method)) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Constructors cannot be generators, getters or setters"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'Constructors cannot be generators, getters or setters'));
}
if (node.isStatic && node.method.name.type === "StaticPropertyName" && node.method.name.value === "prototype") {
s = s.addError(new _earlyErrorState.EarlyError(node, "Static class methods cannot be named \"prototype\""));
if (node.isStatic && node.method.name.type === 'StaticPropertyName' && node.method.name.value === 'prototype') {
s = s.addError(new _earlyErrorState.EarlyError(node, 'Static class methods cannot be named "prototype"'));
}

@@ -295,7 +278,7 @@ return s;

}, {
key: "reduceClassExpression",
key: 'reduceClassExpression',
value: function reduceClassExpression(node, _ref5) {
var name = _ref5.name;
var _super = _ref5.super;
var elements = _ref5.elements;
var name = _ref5.name,
_super = _ref5.super,
elements = _ref5.elements;

@@ -318,11 +301,11 @@ var s = node.name == null ? this.identity : name;

}, {
key: "reduceCompoundAssignmentExpression",
key: 'reduceCompoundAssignmentExpression',
value: function reduceCompoundAssignmentExpression() {
return _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceCompoundAssignmentExpression", this).apply(this, arguments).clearBoundNames();
return _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceCompoundAssignmentExpression', this).apply(this, arguments).clearBoundNames();
}
}, {
key: "reduceComputedMemberExpression",
key: 'reduceComputedMemberExpression',
value: function reduceComputedMemberExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceComputedMemberExpression", this).apply(this, arguments);
if (node.object.type === "Super") {
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceComputedMemberExpression', this).apply(this, arguments);
if (node.object.type === 'Super') {
s = s.observeSuperPropertyExpression(node);

@@ -333,5 +316,5 @@ }

}, {
key: "reduceContinueStatement",
key: 'reduceContinueStatement',
value: function reduceContinueStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceContinueStatement", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceContinueStatement', this).apply(this, arguments);
s = node.label == null ? s.addFreeContinueStatement(node) : s.addFreeLabeledContinueStatement(node);

@@ -341,7 +324,7 @@ return s;

}, {
key: "reduceDoWhileStatement",
key: 'reduceDoWhileStatement',
value: function reduceDoWhileStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceDoWhileStatement", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceDoWhileStatement', this).apply(this, arguments);
if (isLabelledFunction(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node.body, "The body of a do-while statement must not be a labeled function declaration"));
s = s.addError(new _earlyErrorState.EarlyError(node.body, 'The body of a do-while statement must not be a labeled function declaration'));
}

@@ -353,5 +336,5 @@ s = s.clearFreeContinueStatements();

}, {
key: "reduceExport",
key: 'reduceExport',
value: function reduceExport() {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceExport", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceExport', this).apply(this, arguments);
s = s.functionDeclarationNamesAreLexical();

@@ -362,5 +345,5 @@ s = s.exportDeclaredNames();

}, {
key: "reduceExportFrom",
key: 'reduceExportFrom',
value: function reduceExportFrom(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceExportFrom", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceExportFrom', this).apply(this, arguments);
s = s.clearExportedBindings();

@@ -370,5 +353,5 @@ return s;

}, {
key: "reduceExportFromSpecifier",
key: 'reduceExportFromSpecifier',
value: function reduceExportFromSpecifier(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceExportFromSpecifier", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceExportFromSpecifier', this).apply(this, arguments);
s = s.exportName(node.exportedName || node.name, node);

@@ -379,5 +362,5 @@ s = s.exportBinding(node.name, node);

}, {
key: "reduceExportLocalSpecifier",
key: 'reduceExportLocalSpecifier',
value: function reduceExportLocalSpecifier(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceExportLocalSpecifier", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceExportLocalSpecifier', this).apply(this, arguments);
s = s.exportName(node.exportedName || node.name.name, node);

@@ -388,13 +371,13 @@ s = s.exportBinding(node.name.name, node);

}, {
key: "reduceExportDefault",
key: 'reduceExportDefault',
value: function reduceExportDefault(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceExportDefault", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceExportDefault', this).apply(this, arguments);
s = s.functionDeclarationNamesAreLexical();
s = s.exportName("default", node);
s = s.exportName('default', node);
return s;
}
}, {
key: "reduceFormalParameters",
key: 'reduceFormalParameters',
value: function reduceFormalParameters() {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceFormalParameters", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceFormalParameters', this).apply(this, arguments);
s = s.observeLexicalDeclaration();

@@ -404,8 +387,8 @@ return s;

}, {
key: "reduceForStatement",
key: 'reduceForStatement',
value: function reduceForStatement(node, _ref6) {
var init = _ref6.init;
var test = _ref6.test;
var update = _ref6.update;
var body = _ref6.body;
var init = _ref6.init,
test = _ref6.test,
update = _ref6.update,
body = _ref6.body;

@@ -416,7 +399,7 @@ if (init != null) {

}
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceForStatement", this).call(this, node, { init: init, test: test, update: update, body: body });
if (node.init != null && node.init.type === "VariableDeclaration" && node.init.kind === "const") {
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceForStatement', this).call(this, node, { init: init, test: test, update: update, body: body });
if (node.init != null && node.init.type === 'VariableDeclaration' && node.init.kind === 'const') {
node.init.declarators.forEach(function (declarator) {
if (declarator.init == null) {
s = s.addError(new _earlyErrorState.EarlyError(declarator, "Constant lexical declarations must have an initialiser"));
s = s.addError(new _earlyErrorState.EarlyError(declarator, 'Constant lexical declarations must have an initialiser'));
}

@@ -426,3 +409,3 @@ });

if (isLabelledFunction(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node.body, "The body of a for statement must not be a labeled function declaration"));
s = s.addError(new _earlyErrorState.EarlyError(node.body, 'The body of a for statement must not be a labeled function declaration'));
}

@@ -435,13 +418,13 @@ s = s.clearFreeContinueStatements();

}, {
key: "reduceForInStatement",
key: 'reduceForInStatement',
value: function reduceForInStatement(node, _ref7) {
var left = _ref7.left;
var right = _ref7.right;
var body = _ref7.body;
var left = _ref7.left,
right = _ref7.right,
body = _ref7.body;
left = left.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);
left = left.enforceConflictingLexicallyDeclaredNames(body.varDeclaredNames, DUPLICATE_BINDING);
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceForInStatement", this).call(this, node, { left: left, right: right, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceForInStatement', this).call(this, node, { left: left, right: right, body: body });
if (isLabelledFunction(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node.body, "The body of a for-in statement must not be a labeled function declaration"));
s = s.addError(new _earlyErrorState.EarlyError(node.body, 'The body of a for-in statement must not be a labeled function declaration'));
}

@@ -454,7 +437,7 @@ s = s.clearFreeContinueStatements();

}, {
key: "reduceForOfStatement",
key: 'reduceForOfStatement',
value: function reduceForOfStatement(node, _ref8) {
var left = _ref8.left;
var right = _ref8.right;
var body = _ref8.body;
var left = _ref8.left,
right = _ref8.right,
body = _ref8.body;

@@ -464,5 +447,5 @@ left = left.recordForOfVars();

left = left.enforceConflictingLexicallyDeclaredNames(body.varDeclaredNames, DUPLICATE_BINDING);
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceForOfStatement", this).call(this, node, { left: left, right: right, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceForOfStatement', this).call(this, node, { left: left, right: right, body: body });
if (isLabelledFunction(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node.body, "The body of a for-of statement must not be a labeled function declaration"));
s = s.addError(new _earlyErrorState.EarlyError(node.body, 'The body of a for-of statement must not be a labeled function declaration'));
}

@@ -475,5 +458,5 @@ s = s.clearFreeContinueStatements();

}, {
key: "reduceFunctionBody",
key: 'reduceFunctionBody',
value: function reduceFunctionBody(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceFunctionBody", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceFunctionBody', this).apply(this, arguments);
s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);

@@ -493,13 +476,13 @@ s = s.enforceConflictingLexicallyDeclaredNames(s.varDeclaredNames, DUPLICATE_BINDING);

}, {
key: "reduceFunctionDeclaration",
key: 'reduceFunctionDeclaration',
value: function reduceFunctionDeclaration(node, _ref9) {
var name = _ref9.name;
var params = _ref9.params;
var body = _ref9.body;
var name = _ref9.name,
params = _ref9.params,
body = _ref9.body;
var isSimpleParameterList = node.params.rest == null && node.params.items.every(function (i) {
return i.type === "BindingIdentifier";
return i.type === 'BindingIdentifier';
});
var addError = !isSimpleParameterList || node.isGenerator ? "addError" : "addStrictError";
params.lexicallyDeclaredNames.forEachEntry(function (nodes /*, bindingName*/) {
var addError = !isSimpleParameterList || node.isGenerator ? 'addError' : 'addStrictError';
params.lexicallyDeclaredNames.forEachEntry(function (nodes /* , bindingName*/) {
if (nodes.length > 1) {

@@ -518,3 +501,3 @@ nodes.slice(1).forEach(function (dupeNode) {

params.yieldExpressions.forEach(function (node) {
params = params.addError(new _earlyErrorState.EarlyError(node, "Generator parameters must not contain yield expressions"));
params = params.addError(new _earlyErrorState.EarlyError(node, 'Generator parameters must not contain yield expressions'));
});

@@ -528,5 +511,5 @@ }

}
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceFunctionDeclaration", this).call(this, node, { name: name, params: params, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceFunctionDeclaration', this).call(this, node, { name: name, params: params, body: body });
if (!isSimpleParameterList && isStrictFunctionBody(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Functions with non-simple parameter lists may not contain a \"use strict\" directive"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive'));
}

@@ -538,16 +521,16 @@ s = s.clearYieldExpressions();

}, {
key: "reduceFunctionExpression",
key: 'reduceFunctionExpression',
value: function reduceFunctionExpression(node, _ref10) {
var name = _ref10.name;
var params = _ref10.params;
var body = _ref10.body;
var name = _ref10.name,
params = _ref10.params,
body = _ref10.body;
var isSimpleParameterList = node.params.rest == null && node.params.items.every(function (i) {
return i.type === "BindingIdentifier";
return i.type === 'BindingIdentifier';
});
var addError = !isSimpleParameterList || node.isGenerator ? "addError" : "addStrictError";
var addError = !isSimpleParameterList || node.isGenerator ? 'addError' : 'addStrictError';
params.lexicallyDeclaredNames.forEachEntry(function (nodes, bindingName) {
if (nodes.length > 1) {
nodes.slice(1).forEach(function (dupeNode) {
params = params[addError](new _earlyErrorState.EarlyError(dupeNode, "Duplicate binding " + JSON.stringify(bindingName)));
params = params[addError](new _earlyErrorState.EarlyError(dupeNode, 'Duplicate binding ' + JSON.stringify(bindingName)));
});

@@ -563,3 +546,3 @@ }

params.yieldExpressions.forEach(function (node) {
params = params.addError(new _earlyErrorState.EarlyError(node, "Generator parameters must not contain yield expressions"));
params = params.addError(new _earlyErrorState.EarlyError(node, 'Generator parameters must not contain yield expressions'));
});

@@ -573,5 +556,5 @@ }

}
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceFunctionExpression", this).call(this, node, { name: name, params: params, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceFunctionExpression', this).call(this, node, { name: name, params: params, body: body });
if (!isSimpleParameterList && isStrictFunctionBody(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Functions with non-simple parameter lists may not contain a \"use strict\" directive"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive'));
}

@@ -584,6 +567,6 @@ s = s.clearBoundNames();

}, {
key: "reduceGetter",
key: 'reduceGetter',
value: function reduceGetter(node, _ref11) {
var name = _ref11.name;
var body = _ref11.body;
var name = _ref11.name,
body = _ref11.body;

@@ -596,3 +579,3 @@ body = body.enforceSuperCallExpressions(SUPERCALL_ERROR);

}
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceGetter", this).call(this, node, { name: name, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceGetter', this).call(this, node, { name: name, body: body });
s = s.observeVarBoundary();

@@ -602,7 +585,7 @@ return s;

}, {
key: "reduceIdentifierExpression",
key: 'reduceIdentifierExpression',
value: function reduceIdentifierExpression(node) {
var s = this.identity;
if ((0, _utils.isStrictModeReservedWord)(node.name)) {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "The identifier " + JSON.stringify(node.name) + " must not be in expression position in strict mode"));
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'The identifier ' + JSON.stringify(node.name) + ' must not be in expression position in strict mode'));
}

@@ -612,28 +595,28 @@ return s;

}, {
key: "reduceIfStatement",
key: 'reduceIfStatement',
value: function reduceIfStatement(node, _ref12) {
var test = _ref12.test;
var consequent = _ref12.consequent;
var alternate = _ref12.alternate;
var test = _ref12.test,
consequent = _ref12.consequent,
alternate = _ref12.alternate;
if (isLabelledFunction(node.consequent)) {
consequent = consequent.addError(new _earlyErrorState.EarlyError(node.consequent, "The consequent of an if statement must not be a labeled function declaration"));
consequent = consequent.addError(new _earlyErrorState.EarlyError(node.consequent, 'The consequent of an if statement must not be a labeled function declaration'));
}
if (node.alternate != null && isLabelledFunction(node.alternate)) {
alternate = alternate.addError(new _earlyErrorState.EarlyError(node.alternate, "The alternate of an if statement must not be a labeled function declaration"));
alternate = alternate.addError(new _earlyErrorState.EarlyError(node.alternate, 'The alternate of an if statement must not be a labeled function declaration'));
}
if (node.consequent.type === "FunctionDeclaration") {
consequent = consequent.addStrictError(new _earlyErrorState.EarlyError(node.consequent, "FunctionDeclarations in IfStatements are disallowed in strict mode"));
if (node.consequent.type === 'FunctionDeclaration') {
consequent = consequent.addStrictError(new _earlyErrorState.EarlyError(node.consequent, 'FunctionDeclarations in IfStatements are disallowed in strict mode'));
consequent = consequent.observeLexicalBoundary();
}
if (node.alternate != null && node.alternate.type === "FunctionDeclaration") {
alternate = alternate.addStrictError(new _earlyErrorState.EarlyError(node.alternate, "FunctionDeclarations in IfStatements are disallowed in strict mode"));
if (node.alternate != null && node.alternate.type === 'FunctionDeclaration') {
alternate = alternate.addStrictError(new _earlyErrorState.EarlyError(node.alternate, 'FunctionDeclarations in IfStatements are disallowed in strict mode'));
alternate = alternate.observeLexicalBoundary();
}
return _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceIfStatement", this).call(this, node, { test: test, consequent: consequent, alternate: alternate });
return _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceIfStatement', this).call(this, node, { test: test, consequent: consequent, alternate: alternate });
}
}, {
key: "reduceImport",
key: 'reduceImport',
value: function reduceImport() {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceImport", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceImport', this).apply(this, arguments);
s = s.observeLexicalDeclaration();

@@ -643,5 +626,5 @@ return s;

}, {
key: "reduceImportNamespace",
key: 'reduceImportNamespace',
value: function reduceImportNamespace() {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceImportNamespace", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceImportNamespace', this).apply(this, arguments);
s = s.observeLexicalDeclaration();

@@ -651,13 +634,13 @@ return s;

}, {
key: "reduceLabeledStatement",
key: 'reduceLabeledStatement',
value: function reduceLabeledStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceLabeledStatement", this).apply(this, arguments);
if (node.label === "yield") {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "The identifier " + JSON.stringify(node.label) + " must not be in label position in strict mode"));
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceLabeledStatement', this).apply(this, arguments);
if (node.label === 'yield' || (0, _utils.isStrictModeReservedWord)(node.label)) {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'The identifier ' + JSON.stringify(node.label) + ' must not be in label position in strict mode'));
}
if (s.usedLabelNames.indexOf(node.label) >= 0) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Label " + JSON.stringify(node.label) + " has already been declared"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'Label ' + JSON.stringify(node.label) + ' has already been declared'));
}
if (node.body.type === "FunctionDeclaration") {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "Labeled FunctionDeclarations are disallowed in strict mode"));
if (node.body.type === 'FunctionDeclaration') {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'Labeled FunctionDeclarations are disallowed in strict mode'));
}

@@ -668,24 +651,24 @@ s = isIterationStatement(node.body) ? s.observeIterationLabel(node.label) : s.observeNonIterationLabel(node.label);

}, {
key: "reduceLiteralRegExpExpression",
key: 'reduceLiteralRegExpExpression',
value: function reduceLiteralRegExpExpression(node) {
var s = this.identity;
// NOTE: the RegExp pattern acceptor is disabled until we have more confidence in its correctness (more tests)
//if (!PatternAcceptor.test(node.pattern, node.flags.indexOf("u") >= 0)) {
// if (!PatternAcceptor.test(node.pattern, node.flags.indexOf("u") >= 0)) {
// s = s.addError(new EarlyError(node, "Invalid regular expression pattern"));
//}
// }
return s;
}
}, {
key: "reduceMethod",
key: 'reduceMethod',
value: function reduceMethod(node, _ref13) {
var name = _ref13.name;
var params = _ref13.params;
var body = _ref13.body;
var name = _ref13.name,
params = _ref13.params,
body = _ref13.body;
var isSimpleParameterList = node.params.rest == null && node.params.items.every(function (i) {
return i.type === "BindingIdentifier";
return i.type === 'BindingIdentifier';
});
params = params.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);
body = body.enforceConflictingLexicallyDeclaredNames(params.lexicallyDeclaredNames, DUPLICATE_BINDING);
if (node.name.type === "StaticPropertyName" && node.name.value === "constructor") {
if (node.name.type === 'StaticPropertyName' && node.name.value === 'constructor') {
body = body.observeConstructorMethod();

@@ -699,3 +682,3 @@ params = params.observeConstructorMethod();

params.yieldExpressions.forEach(function (node) {
params = params.addError(new _earlyErrorState.EarlyError(node, "Generator parameters must not contain yield expressions"));
params = params.addError(new _earlyErrorState.EarlyError(node, 'Generator parameters must not contain yield expressions'));
});

@@ -711,5 +694,5 @@ }

}
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceMethod", this).call(this, node, { name: name, params: params, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceMethod', this).call(this, node, { name: name, params: params, body: body });
if (!isSimpleParameterList && isStrictFunctionBody(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Functions with non-simple parameter lists may not contain a \"use strict\" directive"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive'));
}

@@ -721,5 +704,5 @@ s = s.clearYieldExpressions();

}, {
key: "reduceModule",
key: 'reduceModule',
value: function reduceModule() {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceModule", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceModule', this).apply(this, arguments);
s = s.functionDeclarationNamesAreLexical();

@@ -731,3 +714,3 @@ s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);

nodes.slice(1).forEach(function (dupeNode) {
s = s.addError(new _earlyErrorState.EarlyError(dupeNode, "Duplicate export " + JSON.stringify(bindingName)));
s = s.addError(new _earlyErrorState.EarlyError(dupeNode, 'Duplicate export ' + JSON.stringify(bindingName)));
});

@@ -739,3 +722,3 @@ }

nodes.forEach(function (undeclaredNode) {
s = s.addError(new _earlyErrorState.EarlyError(undeclaredNode, "Exported binding " + JSON.stringify(bindingName) + " is not declared"));
s = s.addError(new _earlyErrorState.EarlyError(undeclaredNode, 'Exported binding ' + JSON.stringify(bindingName) + ' is not declared'));
});

@@ -745,3 +728,3 @@ }

s.newTargetExpressions.forEach(function (node) {
s = s.addError(new _earlyErrorState.EarlyError(node, "new.target must be within function (but not arrow expression) code"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'new.target must be within function (but not arrow expression) code'));
});

@@ -758,3 +741,3 @@ s = s.enforceFreeContinueStatementErrors(FREE_CONTINUE);

}, {
key: "reduceNewTargetExpression",
key: 'reduceNewTargetExpression',
value: function reduceNewTargetExpression(node) {

@@ -764,11 +747,11 @@ return this.identity.observeNewTargetExpression(node);

}, {
key: "reduceObjectExpression",
key: 'reduceObjectExpression',
value: function reduceObjectExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceObjectExpression", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceObjectExpression', this).apply(this, arguments);
s = s.enforceSuperCallExpressionsInConstructorMethod(SUPERCALL_ERROR);
var protos = node.properties.filter(function (p) {
return p.type === "DataProperty" && p.name.type === "StaticPropertyName" && p.name.value === "__proto__";
return p.type === 'DataProperty' && p.name.type === 'StaticPropertyName' && p.name.value === '__proto__';
});
protos.slice(1).forEach(function (n) {
s = s.addError(new _earlyErrorState.EarlyError(n, "Duplicate __proto__ property in object literal not allowed"));
s = s.addError(new _earlyErrorState.EarlyError(n, 'Duplicate __proto__ property in object literal not allowed'));
});

@@ -778,5 +761,5 @@ return s;

}, {
key: "reduceUpdateExpression",
key: 'reduceUpdateExpression',
value: function reduceUpdateExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceUpdateExpression", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceUpdateExpression', this).apply(this, arguments);
s = s.clearBoundNames();

@@ -786,7 +769,7 @@ return s;

}, {
key: "reduceUnaryExpression",
key: 'reduceUnaryExpression',
value: function reduceUnaryExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceUnaryExpression", this).apply(this, arguments);
if (node.operator === "delete" && node.operand.type === "IdentifierExpression") {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "Identifier expressions must not be deleted in strict mode"));
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceUnaryExpression', this).apply(this, arguments);
if (node.operator === 'delete' && node.operand.type === 'IdentifierExpression') {
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'Identifier expressions must not be deleted in strict mode'));
}

@@ -796,9 +779,9 @@ return s;

}, {
key: "reduceScript",
key: 'reduceScript',
value: function reduceScript(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceScript", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceScript', this).apply(this, arguments);
s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);
s = s.enforceConflictingLexicallyDeclaredNames(s.varDeclaredNames, DUPLICATE_BINDING);
s.newTargetExpressions.forEach(function (node) {
s = s.addError(new _earlyErrorState.EarlyError(node, "new.target must be within function (but not arrow expression) code"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'new.target must be within function (but not arrow expression) code'));
});

@@ -817,9 +800,9 @@ s = s.enforceFreeContinueStatementErrors(FREE_CONTINUE);

}, {
key: "reduceSetter",
key: 'reduceSetter',
value: function reduceSetter(node, _ref14) {
var name = _ref14.name;
var param = _ref14.param;
var body = _ref14.body;
var name = _ref14.name,
param = _ref14.param,
body = _ref14.body;
var isSimpleParameterList = node.param.type === "BindingIdentifier";
var isSimpleParameterList = node.param.type === 'BindingIdentifier';
param = param.observeLexicalDeclaration();

@@ -838,5 +821,5 @@ param = param.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING);

}
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceSetter", this).call(this, node, { name: name, param: param, body: body });
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceSetter', this).call(this, node, { name: name, param: param, body: body });
if (!isSimpleParameterList && isStrictFunctionBody(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node, "Functions with non-simple parameter lists may not contain a \"use strict\" directive"));
s = s.addError(new _earlyErrorState.EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive'));
}

@@ -847,6 +830,6 @@ s = s.observeVarBoundary();

}, {
key: "reduceStaticMemberExpression",
key: 'reduceStaticMemberExpression',
value: function reduceStaticMemberExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceStaticMemberExpression", this).apply(this, arguments);
if (node.object.type === "Super") {
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceStaticMemberExpression', this).apply(this, arguments);
if (node.object.type === 'Super') {
s = s.observeSuperPropertyExpression(node);

@@ -857,6 +840,6 @@ }

}, {
key: "reduceSwitchStatement",
key: 'reduceSwitchStatement',
value: function reduceSwitchStatement(node, _ref15) {
var discriminant = _ref15.discriminant;
var cases = _ref15.cases;
var discriminant = _ref15.discriminant,
cases = _ref15.cases;

@@ -873,8 +856,8 @@ var sCases = this.fold(cases);

}, {
key: "reduceSwitchStatementWithDefault",
key: 'reduceSwitchStatementWithDefault',
value: function reduceSwitchStatementWithDefault(node, _ref16) {
var discriminant = _ref16.discriminant;
var preDefaultCases = _ref16.preDefaultCases;
var defaultCase = _ref16.defaultCase;
var postDefaultCases = _ref16.postDefaultCases;
var discriminant = _ref16.discriminant,
preDefaultCases = _ref16.preDefaultCases,
defaultCase = _ref16.defaultCase,
postDefaultCases = _ref16.postDefaultCases;

@@ -891,13 +874,13 @@ var sCases = this.append(defaultCase, this.append(this.fold(preDefaultCases), this.fold(postDefaultCases)));

}, {
key: "reduceVariableDeclaration",
key: 'reduceVariableDeclaration',
value: function reduceVariableDeclaration(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceVariableDeclaration", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceVariableDeclaration', this).apply(this, arguments);
switch (node.kind) {
case "const":
case "let":
case 'const':
case 'let':
{
s = s.observeLexicalDeclaration();
if (s.lexicallyDeclaredNames.has("let")) {
s.lexicallyDeclaredNames.get("let").forEach(function (n) {
s = s.addError(new _earlyErrorState.EarlyError(n, "Lexical declarations must not have a binding named \"let\""));
if (s.lexicallyDeclaredNames.has('let')) {
s.lexicallyDeclaredNames.get('let').forEach(function (n) {
s = s.addError(new _earlyErrorState.EarlyError(n, 'Lexical declarations must not have a binding named "let"'));
});

@@ -907,3 +890,3 @@ }

}
case "var":
case 'var':
s = s.observeVarDeclaration();

@@ -915,9 +898,9 @@ break;

}, {
key: "reduceVariableDeclarationStatement",
key: 'reduceVariableDeclarationStatement',
value: function reduceVariableDeclarationStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceVariableDeclarationStatement", this).apply(this, arguments);
if (node.declaration.kind === "const") {
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceVariableDeclarationStatement', this).apply(this, arguments);
if (node.declaration.kind === 'const') {
node.declaration.declarators.forEach(function (declarator) {
if (declarator.init == null) {
s = s.addError(new _earlyErrorState.EarlyError(declarator, "Constant lexical declarations must have an initialiser"));
s = s.addError(new _earlyErrorState.EarlyError(declarator, 'Constant lexical declarations must have an initialiser'));
}

@@ -929,7 +912,7 @@ });

}, {
key: "reduceWhileStatement",
key: 'reduceWhileStatement',
value: function reduceWhileStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceWhileStatement", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceWhileStatement', this).apply(this, arguments);
if (isLabelledFunction(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node.body, "The body of a while statement must not be a labeled function declaration"));
s = s.addError(new _earlyErrorState.EarlyError(node.body, 'The body of a while statement must not be a labeled function declaration'));
}

@@ -940,15 +923,15 @@ s = s.clearFreeContinueStatements().clearFreeBreakStatements();

}, {
key: "reduceWithStatement",
key: 'reduceWithStatement',
value: function reduceWithStatement(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceWithStatement", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceWithStatement', this).apply(this, arguments);
if (isLabelledFunction(node.body)) {
s = s.addError(new _earlyErrorState.EarlyError(node.body, "The body of a with statement must not be a labeled function declaration"));
s = s.addError(new _earlyErrorState.EarlyError(node.body, 'The body of a with statement must not be a labeled function declaration'));
}
s = s.addStrictError(new _earlyErrorState.EarlyError(node, "Strict mode code must not include a with statement"));
s = s.addStrictError(new _earlyErrorState.EarlyError(node, 'Strict mode code must not include a with statement'));
return s;
}
}, {
key: "reduceYieldExpression",
key: 'reduceYieldExpression',
value: function reduceYieldExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceYieldExpression", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceYieldExpression', this).apply(this, arguments);
s = s.observeYieldExpression(node);

@@ -958,5 +941,5 @@ return s;

}, {
key: "reduceYieldGeneratorExpression",
key: 'reduceYieldGeneratorExpression',
value: function reduceYieldGeneratorExpression(node) {
var s = _get(Object.getPrototypeOf(EarlyErrorChecker.prototype), "reduceYieldGeneratorExpression", this).apply(this, arguments);
var s = _get(EarlyErrorChecker.prototype.__proto__ || Object.getPrototypeOf(EarlyErrorChecker.prototype), 'reduceYieldGeneratorExpression', this).apply(this, arguments);
s = s.observeYieldExpression(node);

@@ -966,3 +949,3 @@ return s;

}], [{
key: "check",
key: 'check',
value: function check(node) {

@@ -969,0 +952,0 @@ return (0, _shiftReducer2.default)(new EarlyErrorChecker(), node).errors;

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -23,27 +23,96 @@ Object.defineProperty(exports, "__esModule", {

var ErrorMessages = exports.ErrorMessages = {
UNEXPECTED_TOKEN: "Unexpected token {0}",
UNEXPECTED_ILLEGAL_TOKEN: "Unexpected {0}",
UNEXPECTED_NUMBER: "Unexpected number",
UNEXPECTED_STRING: "Unexpected string",
UNEXPECTED_IDENTIFIER: "Unexpected identifier",
UNEXPECTED_RESERVED_WORD: "Unexpected reserved word",
UNEXPECTED_TEMPLATE: "Unexpected template",
UNEXPECTED_EOS: "Unexpected end of input",
UNEXPECTED_LINE_TERMINATOR: "Unexpected line terminator",
UNEXPECTED_COMMA_AFTER_REST: "Unexpected comma after rest",
NEWLINE_AFTER_THROW: "Illegal newline after throw",
UNTERMINATED_REGEXP: "Invalid regular expression: missing /",
INVALID_REGEXP_FLAGS: "Invalid regular expression flags",
INVALID_LHS_IN_ASSIGNMENT: "Invalid left-hand side in assignment",
INVALID_LHS_IN_BINDING: "Invalid left-hand side in binding", // todo collapse messages?
INVALID_LHS_IN_FOR_IN: "Invalid left-hand side in for-in",
INVALID_LHS_IN_FOR_OF: "Invalid left-hand side in for-of",
INVALID_UPDATE_OPERAND: "Increment/decrement target must be an identifier or member expression",
MULTIPLE_DEFAULTS_IN_SWITCH: "More than one default clause in switch statement",
NO_CATCH_OR_FINALLY: "Missing catch or finally after try",
ILLEGAL_RETURN: "Illegal return statement",
ILLEGAL_ARROW_FUNCTION_PARAMS: "Illegal arrow function parameter list",
INVALID_VAR_INIT_FOR_IN: "Invalid variable declaration in for-in statement",
INVALID_VAR_INIT_FOR_OF: "Invalid variable declaration in for-of statement",
ILLEGAL_PROPERTY: "Illegal property initializer"
UNEXPECTED_TOKEN: function UNEXPECTED_TOKEN(id) {
return 'Unexpected token ' + JSON.stringify(id);
},
UNEXPECTED_ILLEGAL_TOKEN: function UNEXPECTED_ILLEGAL_TOKEN(id) {
return 'Unexpected ' + JSON.stringify(id);
},
UNEXPECTED_ESCAPED_KEYWORD: 'Unexpected escaped keyword',
UNEXPECTED_NUMBER: 'Unexpected number',
UNEXPECTED_STRING: 'Unexpected string',
UNEXPECTED_IDENTIFIER: 'Unexpected identifier',
UNEXPECTED_RESERVED_WORD: 'Unexpected reserved word',
UNEXPECTED_TEMPLATE: 'Unexpected template',
UNEXPECTED_EOS: 'Unexpected end of input',
UNEXPECTED_LINE_TERMINATOR: 'Unexpected line terminator',
UNEXPECTED_COMMA_AFTER_REST: 'Unexpected comma after rest',
NEWLINE_AFTER_THROW: 'Illegal newline after throw',
UNTERMINATED_REGEXP: 'Invalid regular expression: missing /',
INVALID_REGEXP_FLAGS: 'Invalid regular expression flags',
INVALID_LHS_IN_ASSIGNMENT: 'Invalid left-hand side in assignment',
INVALID_LHS_IN_BINDING: 'Invalid left-hand side in binding', // todo collapse messages?
INVALID_LHS_IN_FOR_IN: 'Invalid left-hand side in for-in',
INVALID_LHS_IN_FOR_OF: 'Invalid left-hand side in for-of',
INVALID_UPDATE_OPERAND: 'Increment/decrement target must be an identifier or member expression',
INVALID_EXPONENTIATION_LHS: 'Unary expressions as the left operand of an exponentation expression ' + 'must be disambiguated with parentheses',
MULTIPLE_DEFAULTS_IN_SWITCH: 'More than one default clause in switch statement',
NO_CATCH_OR_FINALLY: 'Missing catch or finally after try',
ILLEGAL_RETURN: 'Illegal return statement',
ILLEGAL_ARROW_FUNCTION_PARAMS: 'Illegal arrow function parameter list',
INVALID_VAR_INIT_FOR_IN: 'Invalid variable declaration in for-in statement',
INVALID_VAR_INIT_FOR_OF: 'Invalid variable declaration in for-of statement',
UNINITIALIZED_BINDINGPATTERN_IN_FOR_INIT: 'Binding pattern appears without initializer in for statement init',
ILLEGAL_PROPERTY: 'Illegal property initializer',
INVALID_ID_BINDING_STRICT_MODE: function INVALID_ID_BINDING_STRICT_MODE(id) {
return 'The identifier ' + JSON.stringify(id) + ' must not be in binding position in strict mode';
},
INVALID_ID_IN_LABEL_STRICT_MODE: function INVALID_ID_IN_LABEL_STRICT_MODE(id) {
return 'The identifier ' + JSON.stringify(id) + ' must not be in label position in strict mode';
},
INVALID_ID_IN_EXPRESSION_STRICT_MODE: function INVALID_ID_IN_EXPRESSION_STRICT_MODE(id) {
return 'The identifier ' + JSON.stringify(id) + ' must not be in expression position in strict mode';
},
INVALID_CALL_TO_SUPER: 'Calls to super must be in the "constructor" method of a class expression ' + 'or class declaration that has a superclass',
INVALID_DELETE_STRICT_MODE: 'Identifier expressions must not be deleted in strict mode',
DUPLICATE_BINDING: function DUPLICATE_BINDING(id) {
return 'Duplicate binding ' + JSON.stringify(id);
},
ILLEGAL_ID_IN_LEXICAL_DECLARATION: function ILLEGAL_ID_IN_LEXICAL_DECLARATION(id) {
return 'Lexical declarations must not have a binding named ' + JSON.stringify(id);
},
UNITIALIZED_CONST: 'Constant lexical declarations must have an initialiser',
ILLEGAL_LABEL_IN_BODY: function ILLEGAL_LABEL_IN_BODY(stmt) {
return 'The body of a ' + stmt + ' statement must not be a labeled function declaration';
},
ILLEGEAL_LABEL_IN_IF: 'The consequent of an if statement must not be a labeled function declaration',
ILLEGAL_LABEL_IN_ELSE: 'The alternate of an if statement must not be a labeled function declaration',
ILLEGAL_CONTINUE_WITHOUT_ITERATION_WITH_ID: function ILLEGAL_CONTINUE_WITHOUT_ITERATION_WITH_ID(id) {
return 'Continue statement must be nested within an iteration statement with label ' + JSON.stringify(id);
},
ILLEGAL_CONTINUE_WITHOUT_ITERATION: 'Continue statement must be nested within an iteration statement',
ILLEGAL_BREAK_WITHOUT_ITERATION_OR_SWITCH: 'Break statement must be nested within an iteration statement or a switch statement',
ILLEGAL_WITH_STRICT_MODE: 'Strict mode code must not include a with statement',
ILLEGAL_ACCESS_SUPER_MEMBER: 'Member access on super must be in a method',
DUPLICATE_LABEL_DECLARATION: function DUPLICATE_LABEL_DECLARATION(label) {
return 'Label ' + JSON.stringify(label) + ' has already been declared';
},
ILLEGAL_BREAK_WITHIN_LABEL: function ILLEGAL_BREAK_WITHIN_LABEL(label) {
return 'Break statement must be nested within a statement with label ' + JSON.stringify(label);
},
ILLEGAL_YIELD_EXPRESSIONS: function ILLEGAL_YIELD_EXPRESSIONS(paramType) {
return paramType + ' parameters must not contain yield expressions';
},
ILLEGAL_YIELD_IDENTIFIER: '"yield" may not be used as an identifier in this context',
DUPLICATE_CONSTRUCTOR: 'Duplicate constructor method in class',
ILLEGAL_CONSTRUCTORS: 'Constructors cannot be generators, getters or setters',
ILLEGAL_STATIC_CLASS_NAME: 'Static class methods cannot be named "prototype"',
NEW_TARGET_ERROR: 'new.target must be within function (but not arrow expression) code',
DUPLICATE_EXPORT: function DUPLICATE_EXPORT(id) {
return 'Duplicate export ' + JSON.stringify(id);
},
UNDECLARED_BINDING: function UNDECLARED_BINDING(id) {
return 'Exported binding ' + JSON.stringify(id) + ' is not declared';
},
DUPLICATE_PROPTO_PROP: 'Duplicate __proto__ property in object literal not allowed',
ILLEGAL_LABEL_FUNC_DECLARATION: 'Labeled FunctionDeclarations are disallowed in strict mode',
ILLEGAL_FUNC_DECL_IF: 'FunctionDeclarations in IfStatements are disallowed in strict mode',
ILLEGAL_USE_STRICT: 'Functions with non-simple parameter lists may not contain a "use strict" directive',
ILLEGAL_EXPORTED_NAME: 'Names of variables used in an export specifier from the current module must be identifiers'
};

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -10,5 +10,5 @@ Object.defineProperty(exports, "__esModule", {

var _tokenizer = require("./tokenizer");
var _tokenizer = require('./tokenizer');
Object.defineProperty(exports, "Tokenizer", {
Object.defineProperty(exports, 'Tokenizer', {
enumerable: true,

@@ -19,3 +19,3 @@ get: function get() {

});
Object.defineProperty(exports, "TokenClass", {
Object.defineProperty(exports, 'TokenClass', {
enumerable: true,

@@ -26,3 +26,3 @@ get: function get() {

});
Object.defineProperty(exports, "TokenType", {
Object.defineProperty(exports, 'TokenType', {
enumerable: true,

@@ -34,5 +34,5 @@ get: function get() {

var _parser = require("./parser");
var _parser = require('./parser');
var _earlyErrors = require("./early-errors");
var _earlyErrors = require('./early-errors');

@@ -61,15 +61,2 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function markLocation(node, location) {
node.loc = {
start: location,
end: {
line: this.lastLine + 1,
column: this.lastIndex - this.lastLineStart,
offset: this.lastIndex
},
source: null
};
return node;
}
var ParserWithLocation = function (_GenericParser) {

@@ -81,3 +68,3 @@ _inherits(ParserWithLocation, _GenericParser);

var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ParserWithLocation).call(this, source));
var _this = _possibleConstructorReturn(this, (ParserWithLocation.__proto__ || Object.getPrototypeOf(ParserWithLocation)).call(this, source));

@@ -89,3 +76,3 @@ _this.locations = new WeakMap();

_createClass(ParserWithLocation, [{
key: "startNode",
key: 'startNode',
value: function startNode() {

@@ -95,3 +82,3 @@ return this.getLocation();

}, {
key: "finishNode",
key: 'finishNode',
value: function finishNode(node, start) {

@@ -105,3 +92,3 @@ this.locations.set(node, {

}, {
key: "copyNode",
key: 'copyNode',
value: function copyNode(src, dest) {

@@ -118,7 +105,6 @@ this.locations.set(dest, this.locations.get(src)); // todo check undefined

return function parse(code) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$earlyErrors = _ref.earlyErrors,
earlyErrors = _ref$earlyErrors === undefined ? true : _ref$earlyErrors;
var _ref$earlyErrors = _ref.earlyErrors;
var earlyErrors = _ref$earlyErrors === undefined ? true : _ref$earlyErrors;
var parser = new _parser.GenericParser(code);

@@ -130,5 +116,5 @@ var tree = parser[parsingFunctionName]();

if (errors.length > 0) {
var _errors$ = errors[0];
var node = _errors$.node;
var message = _errors$.message;
var _errors$ = errors[0],
node = _errors$.node,
message = _errors$.message;

@@ -144,7 +130,6 @@ throw new _tokenizer.JsError(0, 1, 0, message);

return function parse(code) {
var _ref2 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref2$earlyErrors = _ref2.earlyErrors,
earlyErrors = _ref2$earlyErrors === undefined ? true : _ref2$earlyErrors;
var _ref2$earlyErrors = _ref2.earlyErrors;
var earlyErrors = _ref2$earlyErrors === undefined ? true : _ref2$earlyErrors;
var parser = new ParserWithLocation(code);

@@ -156,9 +141,9 @@ var tree = parser[parsingFunctionName]();

if (errors.length > 0) {
var _errors$2 = errors[0];
var node = _errors$2.node;
var message = _errors$2.message;
var _parser$locations$get = parser.locations.get(node).start;
var offset = _parser$locations$get.offset;
var line = _parser$locations$get.line;
var column = _parser$locations$get.column;
var _errors$2 = errors[0],
node = _errors$2.node,
message = _errors$2.message;
var _parser$locations$get = parser.locations.get(node).start,
offset = _parser$locations$get.offset,
line = _parser$locations$get.line,
column = _parser$locations$get.column;

@@ -172,6 +157,6 @@ throw new _tokenizer.JsError(offset, line, column, message);

var parseModule = exports.parseModule = generateInterface("parseModule");
var parseScript = exports.parseScript = generateInterface("parseScript");
var parseModuleWithLocation = exports.parseModuleWithLocation = generateInterfaceWithLocation("parseModule");
var parseScriptWithLocation = exports.parseScriptWithLocation = generateInterfaceWithLocation("parseScript");
var parseModule = exports.parseModule = generateInterface('parseModule');
var parseScript = exports.parseScript = generateInterface('parseScript');
var parseModuleWithLocation = exports.parseModuleWithLocation = generateInterfaceWithLocation('parseModule');
var parseScriptWithLocation = exports.parseScriptWithLocation = generateInterfaceWithLocation('parseScript');
exports.default = parseScript;

@@ -178,0 +163,0 @@ exports.EarlyErrorChecker = _earlyErrors.EarlyErrorChecker;

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -12,5 +12,5 @@ Object.defineProperty(exports, "__esModule", {

var _utils = require("./utils");
var _utils = require('./utils');
var _errors = require("./errors");
var _errors = require('./errors');

@@ -38,111 +38,113 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var TokenClass = exports.TokenClass = {
Eof: { name: "<End>" },
Ident: { name: "Identifier", isIdentifierName: true },
Keyword: { name: "Keyword", isIdentifierName: true },
NumericLiteral: { name: "Numeric" },
TemplateElement: { name: "Template" },
Punctuator: { name: "Punctuator" },
StringLiteral: { name: "String" },
RegularExpression: { name: "RegularExpression" },
Illegal: { name: "Illegal" }
Eof: { name: '<End>' },
Ident: { name: 'Identifier', isIdentifierName: true },
Keyword: { name: 'Keyword', isIdentifierName: true },
NumericLiteral: { name: 'Numeric' },
TemplateElement: { name: 'Template' },
Punctuator: { name: 'Punctuator' },
StringLiteral: { name: 'String' },
RegularExpression: { name: 'RegularExpression' },
Illegal: { name: 'Illegal' }
};
var TokenType = exports.TokenType = {
EOS: { klass: TokenClass.Eof, name: "EOS" },
LPAREN: { klass: TokenClass.Punctuator, name: "(" },
RPAREN: { klass: TokenClass.Punctuator, name: ")" },
LBRACK: { klass: TokenClass.Punctuator, name: "[" },
RBRACK: { klass: TokenClass.Punctuator, name: "]" },
LBRACE: { klass: TokenClass.Punctuator, name: "{" },
RBRACE: { klass: TokenClass.Punctuator, name: "}" },
COLON: { klass: TokenClass.Punctuator, name: ":" },
SEMICOLON: { klass: TokenClass.Punctuator, name: ";" },
PERIOD: { klass: TokenClass.Punctuator, name: "." },
ELLIPSIS: { klass: TokenClass.Punctuator, name: "..." },
ARROW: { klass: TokenClass.Punctuator, name: "=>" },
CONDITIONAL: { klass: TokenClass.Punctuator, name: "?" },
INC: { klass: TokenClass.Punctuator, name: "++" },
DEC: { klass: TokenClass.Punctuator, name: "--" },
ASSIGN: { klass: TokenClass.Punctuator, name: "=" },
ASSIGN_BIT_OR: { klass: TokenClass.Punctuator, name: "|=" },
ASSIGN_BIT_XOR: { klass: TokenClass.Punctuator, name: "^=" },
ASSIGN_BIT_AND: { klass: TokenClass.Punctuator, name: "&=" },
ASSIGN_SHL: { klass: TokenClass.Punctuator, name: "<<=" },
ASSIGN_SHR: { klass: TokenClass.Punctuator, name: ">>=" },
ASSIGN_SHR_UNSIGNED: { klass: TokenClass.Punctuator, name: ">>>=" },
ASSIGN_ADD: { klass: TokenClass.Punctuator, name: "+=" },
ASSIGN_SUB: { klass: TokenClass.Punctuator, name: "-=" },
ASSIGN_MUL: { klass: TokenClass.Punctuator, name: "*=" },
ASSIGN_DIV: { klass: TokenClass.Punctuator, name: "/=" },
ASSIGN_MOD: { klass: TokenClass.Punctuator, name: "%=" },
ASSIGN_EXP: { klass: TokenClass.Punctuator, name: "**=" },
COMMA: { klass: TokenClass.Punctuator, name: "," },
OR: { klass: TokenClass.Punctuator, name: "||" },
AND: { klass: TokenClass.Punctuator, name: "&&" },
BIT_OR: { klass: TokenClass.Punctuator, name: "|" },
BIT_XOR: { klass: TokenClass.Punctuator, name: "^" },
BIT_AND: { klass: TokenClass.Punctuator, name: "&" },
SHL: { klass: TokenClass.Punctuator, name: "<<" },
SHR: { klass: TokenClass.Punctuator, name: ">>" },
SHR_UNSIGNED: { klass: TokenClass.Punctuator, name: ">>>" },
ADD: { klass: TokenClass.Punctuator, name: "+" },
SUB: { klass: TokenClass.Punctuator, name: "-" },
MUL: { klass: TokenClass.Punctuator, name: "*" },
DIV: { klass: TokenClass.Punctuator, name: "/" },
MOD: { klass: TokenClass.Punctuator, name: "%" },
EXP: { klass: TokenClass.Punctuator, name: "**" },
EQ: { klass: TokenClass.Punctuator, name: "==" },
NE: { klass: TokenClass.Punctuator, name: "!=" },
EQ_STRICT: { klass: TokenClass.Punctuator, name: "===" },
NE_STRICT: { klass: TokenClass.Punctuator, name: "!==" },
LT: { klass: TokenClass.Punctuator, name: "<" },
GT: { klass: TokenClass.Punctuator, name: ">" },
LTE: { klass: TokenClass.Punctuator, name: "<=" },
GTE: { klass: TokenClass.Punctuator, name: ">=" },
INSTANCEOF: { klass: TokenClass.Keyword, name: "instanceof" },
IN: { klass: TokenClass.Keyword, name: "in" },
NOT: { klass: TokenClass.Punctuator, name: "!" },
BIT_NOT: { klass: TokenClass.Punctuator, name: "~" },
AWAIT: { klass: TokenClass.Keyword, name: "await" },
DELETE: { klass: TokenClass.Keyword, name: "delete" },
TYPEOF: { klass: TokenClass.Keyword, name: "typeof" },
VOID: { klass: TokenClass.Keyword, name: "void" },
BREAK: { klass: TokenClass.Keyword, name: "break" },
CASE: { klass: TokenClass.Keyword, name: "case" },
CATCH: { klass: TokenClass.Keyword, name: "catch" },
CLASS: { klass: TokenClass.Keyword, name: "class" },
CONTINUE: { klass: TokenClass.Keyword, name: "continue" },
DEBUGGER: { klass: TokenClass.Keyword, name: "debugger" },
DEFAULT: { klass: TokenClass.Keyword, name: "default" },
DO: { klass: TokenClass.Keyword, name: "do" },
ELSE: { klass: TokenClass.Keyword, name: "else" },
EXPORT: { klass: TokenClass.Keyword, name: "export" },
EXTENDS: { klass: TokenClass.Keyword, name: "extends" },
FINALLY: { klass: TokenClass.Keyword, name: "finally" },
FOR: { klass: TokenClass.Keyword, name: "for" },
FUNCTION: { klass: TokenClass.Keyword, name: "function" },
IF: { klass: TokenClass.Keyword, name: "if" },
IMPORT: { klass: TokenClass.Keyword, name: "import" },
LET: { klass: TokenClass.Keyword, name: "let" },
NEW: { klass: TokenClass.Keyword, name: "new" },
RETURN: { klass: TokenClass.Keyword, name: "return" },
SUPER: { klass: TokenClass.Keyword, name: "super" },
SWITCH: { klass: TokenClass.Keyword, name: "switch" },
THIS: { klass: TokenClass.Keyword, name: "this" },
THROW: { klass: TokenClass.Keyword, name: "throw" },
TRY: { klass: TokenClass.Keyword, name: "try" },
VAR: { klass: TokenClass.Keyword, name: "var" },
WHILE: { klass: TokenClass.Keyword, name: "while" },
WITH: { klass: TokenClass.Keyword, name: "with" },
NULL: { klass: TokenClass.Keyword, name: "null" },
TRUE: { klass: TokenClass.Keyword, name: "true" },
FALSE: { klass: TokenClass.Keyword, name: "false" },
YIELD: { klass: TokenClass.Keyword, name: "yield" },
NUMBER: { klass: TokenClass.NumericLiteral, name: "" },
STRING: { klass: TokenClass.StringLiteral, name: "" },
REGEXP: { klass: TokenClass.RegularExpression, name: "" },
IDENTIFIER: { klass: TokenClass.Ident, name: "" },
CONST: { klass: TokenClass.Keyword, name: "const" },
TEMPLATE: { klass: TokenClass.TemplateElement, name: "" },
ILLEGAL: { klass: TokenClass.Illegal, name: "" }
EOS: { klass: TokenClass.Eof, name: 'EOS' },
LPAREN: { klass: TokenClass.Punctuator, name: '(' },
RPAREN: { klass: TokenClass.Punctuator, name: ')' },
LBRACK: { klass: TokenClass.Punctuator, name: '[' },
RBRACK: { klass: TokenClass.Punctuator, name: ']' },
LBRACE: { klass: TokenClass.Punctuator, name: '{' },
RBRACE: { klass: TokenClass.Punctuator, name: '}' },
COLON: { klass: TokenClass.Punctuator, name: ':' },
SEMICOLON: { klass: TokenClass.Punctuator, name: ';' },
PERIOD: { klass: TokenClass.Punctuator, name: '.' },
ELLIPSIS: { klass: TokenClass.Punctuator, name: '...' },
ARROW: { klass: TokenClass.Punctuator, name: '=>' },
CONDITIONAL: { klass: TokenClass.Punctuator, name: '?' },
INC: { klass: TokenClass.Punctuator, name: '++' },
DEC: { klass: TokenClass.Punctuator, name: '--' },
ASSIGN: { klass: TokenClass.Punctuator, name: '=' },
ASSIGN_BIT_OR: { klass: TokenClass.Punctuator, name: '|=' },
ASSIGN_BIT_XOR: { klass: TokenClass.Punctuator, name: '^=' },
ASSIGN_BIT_AND: { klass: TokenClass.Punctuator, name: '&=' },
ASSIGN_SHL: { klass: TokenClass.Punctuator, name: '<<=' },
ASSIGN_SHR: { klass: TokenClass.Punctuator, name: '>>=' },
ASSIGN_SHR_UNSIGNED: { klass: TokenClass.Punctuator, name: '>>>=' },
ASSIGN_ADD: { klass: TokenClass.Punctuator, name: '+=' },
ASSIGN_SUB: { klass: TokenClass.Punctuator, name: '-=' },
ASSIGN_MUL: { klass: TokenClass.Punctuator, name: '*=' },
ASSIGN_DIV: { klass: TokenClass.Punctuator, name: '/=' },
ASSIGN_MOD: { klass: TokenClass.Punctuator, name: '%=' },
ASSIGN_EXP: { klass: TokenClass.Punctuator, name: '**=' },
COMMA: { klass: TokenClass.Punctuator, name: ',' },
OR: { klass: TokenClass.Punctuator, name: '||' },
AND: { klass: TokenClass.Punctuator, name: '&&' },
BIT_OR: { klass: TokenClass.Punctuator, name: '|' },
BIT_XOR: { klass: TokenClass.Punctuator, name: '^' },
BIT_AND: { klass: TokenClass.Punctuator, name: '&' },
SHL: { klass: TokenClass.Punctuator, name: '<<' },
SHR: { klass: TokenClass.Punctuator, name: '>>' },
SHR_UNSIGNED: { klass: TokenClass.Punctuator, name: '>>>' },
ADD: { klass: TokenClass.Punctuator, name: '+' },
SUB: { klass: TokenClass.Punctuator, name: '-' },
MUL: { klass: TokenClass.Punctuator, name: '*' },
DIV: { klass: TokenClass.Punctuator, name: '/' },
MOD: { klass: TokenClass.Punctuator, name: '%' },
EXP: { klass: TokenClass.Punctuator, name: '**' },
EQ: { klass: TokenClass.Punctuator, name: '==' },
NE: { klass: TokenClass.Punctuator, name: '!=' },
EQ_STRICT: { klass: TokenClass.Punctuator, name: '===' },
NE_STRICT: { klass: TokenClass.Punctuator, name: '!==' },
LT: { klass: TokenClass.Punctuator, name: '<' },
GT: { klass: TokenClass.Punctuator, name: '>' },
LTE: { klass: TokenClass.Punctuator, name: '<=' },
GTE: { klass: TokenClass.Punctuator, name: '>=' },
INSTANCEOF: { klass: TokenClass.Keyword, name: 'instanceof' },
IN: { klass: TokenClass.Keyword, name: 'in' },
NOT: { klass: TokenClass.Punctuator, name: '!' },
BIT_NOT: { klass: TokenClass.Punctuator, name: '~' },
AWAIT: { klass: TokenClass.Keyword, name: 'await' },
ENUM: { klass: TokenClass.Keyword, name: 'enum' },
DELETE: { klass: TokenClass.Keyword, name: 'delete' },
TYPEOF: { klass: TokenClass.Keyword, name: 'typeof' },
VOID: { klass: TokenClass.Keyword, name: 'void' },
BREAK: { klass: TokenClass.Keyword, name: 'break' },
CASE: { klass: TokenClass.Keyword, name: 'case' },
CATCH: { klass: TokenClass.Keyword, name: 'catch' },
CLASS: { klass: TokenClass.Keyword, name: 'class' },
CONTINUE: { klass: TokenClass.Keyword, name: 'continue' },
DEBUGGER: { klass: TokenClass.Keyword, name: 'debugger' },
DEFAULT: { klass: TokenClass.Keyword, name: 'default' },
DO: { klass: TokenClass.Keyword, name: 'do' },
ELSE: { klass: TokenClass.Keyword, name: 'else' },
EXPORT: { klass: TokenClass.Keyword, name: 'export' },
EXTENDS: { klass: TokenClass.Keyword, name: 'extends' },
FINALLY: { klass: TokenClass.Keyword, name: 'finally' },
FOR: { klass: TokenClass.Keyword, name: 'for' },
FUNCTION: { klass: TokenClass.Keyword, name: 'function' },
IF: { klass: TokenClass.Keyword, name: 'if' },
IMPORT: { klass: TokenClass.Keyword, name: 'import' },
LET: { klass: TokenClass.Keyword, name: 'let' },
NEW: { klass: TokenClass.Keyword, name: 'new' },
RETURN: { klass: TokenClass.Keyword, name: 'return' },
SUPER: { klass: TokenClass.Keyword, name: 'super' },
SWITCH: { klass: TokenClass.Keyword, name: 'switch' },
THIS: { klass: TokenClass.Keyword, name: 'this' },
THROW: { klass: TokenClass.Keyword, name: 'throw' },
TRY: { klass: TokenClass.Keyword, name: 'try' },
VAR: { klass: TokenClass.Keyword, name: 'var' },
WHILE: { klass: TokenClass.Keyword, name: 'while' },
WITH: { klass: TokenClass.Keyword, name: 'with' },
NULL: { klass: TokenClass.Keyword, name: 'null' },
TRUE: { klass: TokenClass.Keyword, name: 'true' },
FALSE: { klass: TokenClass.Keyword, name: 'false' },
YIELD: { klass: TokenClass.Keyword, name: 'yield' },
NUMBER: { klass: TokenClass.NumericLiteral, name: '' },
STRING: { klass: TokenClass.StringLiteral, name: '' },
REGEXP: { klass: TokenClass.RegularExpression, name: '' },
IDENTIFIER: { klass: TokenClass.Ident, name: '' },
CONST: { klass: TokenClass.Keyword, name: 'const' },
TEMPLATE: { klass: TokenClass.TemplateElement, name: '' },
ESCAPED_KEYWORD: { klass: TokenClass.Keyword, name: '' },
ILLEGAL: { klass: TokenClass.Illegal, name: '' }
};

@@ -165,3 +167,3 @@

var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(JsError).call(this, msg));
var _this = _possibleConstructorReturn(this, (JsError.__proto__ || Object.getPrototypeOf(JsError)).call(this, msg));

@@ -178,3 +180,3 @@ _this.index = index;

_this.description = msg;
_this.message = "[" + line + ":" + column + "]: " + msg;
_this.message = '[' + line + ':' + column + ']: ' + msg;
return _this;

@@ -216,3 +218,3 @@ }

_createClass(Tokenizer, [{
key: "saveLexerState",
key: 'saveLexerState',
value: function saveLexerState() {

@@ -236,3 +238,3 @@ return {

}, {
key: "restoreLexerState",
key: 'restoreLexerState',
value: function restoreLexerState(state) {

@@ -254,3 +256,3 @@ this.source = state.source;

}, {
key: "createILLEGAL",
key: 'createILLEGAL',
value: function createILLEGAL() {

@@ -263,3 +265,3 @@ this.startIndex = this.index;

}, {
key: "createUnexpected",
key: 'createUnexpected',
value: function createUnexpected(token) {

@@ -272,2 +274,5 @@ switch (token.type.klass) {

case TokenClass.Keyword:
if (token.type === TokenType.ESCAPED_KEYWORD) {
return this.createError(_errors.ErrorMessages.UNEXPECTED_ESCAPED_KEYWORD);
}
return this.createError(_errors.ErrorMessages.UNEXPECTED_TOKEN, token.slice.text);

@@ -286,20 +291,24 @@ case TokenClass.NumericLiteral:

}, {
key: "createError",
key: 'createError',
value: function createError(message) {
var _arguments = arguments;
var msg = void 0;
if (typeof message === 'function') {
for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
params[_key - 1] = arguments[_key];
}
/* istanbul ignore next */
var msg = message.replace(/\{(\d+)\}/g, function (_, n) {
return JSON.stringify(_arguments[+n + 1]);
});
msg = message.apply(undefined, params);
} else {
msg = message;
}
return new JsError(this.startIndex, this.startLine + 1, this.startIndex - this.startLineStart + 1, msg);
}
}, {
key: "createErrorWithLocation",
key: 'createErrorWithLocation',
value: function createErrorWithLocation(location, message) {
var _arguments2 = arguments;
var _arguments = arguments;
/* istanbul ignore next */
var msg = message.replace(/\{(\d+)\}/g, function (_, n) {
return JSON.stringify(_arguments2[+n + 2]);
return JSON.stringify(_arguments[+n + 2]);
});

@@ -312,3 +321,3 @@ if (location.slice && location.slice.startLocation) {

}, {
key: "getKeyword",
key: 'getKeyword',
value: function getKeyword(id) {

@@ -323,7 +332,7 @@ if (id.length === 1 || id.length > 10) {

switch (id.charAt(0)) {
case "i":
case 'i':
switch (id.charAt(1)) {
case "f":
case 'f':
return TokenType.IF;
case "n":
case 'n':
return TokenType.IN;

@@ -334,4 +343,4 @@ default:

break;
case "d":
if (id.charAt(1) === "o") {
case 'd':
if (id.charAt(1) === 'o') {
return TokenType.DO;

@@ -344,24 +353,24 @@ }

switch (id.charAt(0)) {
case "v":
if (Tokenizer.cse2(id, "a", "r")) {
case 'v':
if (Tokenizer.cse2(id, 'a', 'r')) {
return TokenType.VAR;
}
break;
case "f":
if (Tokenizer.cse2(id, "o", "r")) {
case 'f':
if (Tokenizer.cse2(id, 'o', 'r')) {
return TokenType.FOR;
}
break;
case "n":
if (Tokenizer.cse2(id, "e", "w")) {
case 'n':
if (Tokenizer.cse2(id, 'e', 'w')) {
return TokenType.NEW;
}
break;
case "t":
if (Tokenizer.cse2(id, "r", "y")) {
case 't':
if (Tokenizer.cse2(id, 'r', 'y')) {
return TokenType.TRY;
}
break;
case "l":
if (Tokenizer.cse2(id, "e", "t")) {
case 'l':
if (Tokenizer.cse2(id, 'e', 't')) {
return TokenType.LET;

@@ -374,31 +383,33 @@ }

switch (id.charAt(0)) {
case "t":
if (Tokenizer.cse3(id, "h", "i", "s")) {
case 't':
if (Tokenizer.cse3(id, 'h', 'i', 's')) {
return TokenType.THIS;
} else if (Tokenizer.cse3(id, "r", "u", "e")) {
} else if (Tokenizer.cse3(id, 'r', 'u', 'e')) {
return TokenType.TRUE;
}
break;
case "n":
if (Tokenizer.cse3(id, "u", "l", "l")) {
case 'n':
if (Tokenizer.cse3(id, 'u', 'l', 'l')) {
return TokenType.NULL;
}
break;
case "e":
if (Tokenizer.cse3(id, "l", "s", "e")) {
case 'e':
if (Tokenizer.cse3(id, 'l', 's', 'e')) {
return TokenType.ELSE;
} else if (Tokenizer.cse3(id, 'n', 'u', 'm')) {
return TokenType.ENUM;
}
break;
case "c":
if (Tokenizer.cse3(id, "a", "s", "e")) {
case 'c':
if (Tokenizer.cse3(id, 'a', 's', 'e')) {
return TokenType.CASE;
}
break;
case "v":
if (Tokenizer.cse3(id, "o", "i", "d")) {
case 'v':
if (Tokenizer.cse3(id, 'o', 'i', 'd')) {
return TokenType.VOID;
}
break;
case "w":
if (Tokenizer.cse3(id, "i", "t", "h")) {
case 'w':
if (Tokenizer.cse3(id, 'i', 't', 'h')) {
return TokenType.WITH;

@@ -411,43 +422,43 @@ }

switch (id.charAt(0)) {
case "a":
if (this.moduleIsTheGoalSymbol && Tokenizer.cse4(id, "w", "a", "i", "t")) {
case 'a':
if (this.moduleIsTheGoalSymbol && Tokenizer.cse4(id, 'w', 'a', 'i', 't')) {
return TokenType.AWAIT;
}
break;
case "w":
if (Tokenizer.cse4(id, "h", "i", "l", "e")) {
case 'w':
if (Tokenizer.cse4(id, 'h', 'i', 'l', 'e')) {
return TokenType.WHILE;
}
break;
case "b":
if (Tokenizer.cse4(id, "r", "e", "a", "k")) {
case 'b':
if (Tokenizer.cse4(id, 'r', 'e', 'a', 'k')) {
return TokenType.BREAK;
}
break;
case "f":
if (Tokenizer.cse4(id, "a", "l", "s", "e")) {
case 'f':
if (Tokenizer.cse4(id, 'a', 'l', 's', 'e')) {
return TokenType.FALSE;
}
break;
case "c":
if (Tokenizer.cse4(id, "a", "t", "c", "h")) {
case 'c':
if (Tokenizer.cse4(id, 'a', 't', 'c', 'h')) {
return TokenType.CATCH;
} else if (Tokenizer.cse4(id, "o", "n", "s", "t")) {
} else if (Tokenizer.cse4(id, 'o', 'n', 's', 't')) {
return TokenType.CONST;
} else if (Tokenizer.cse4(id, "l", "a", "s", "s")) {
} else if (Tokenizer.cse4(id, 'l', 'a', 's', 's')) {
return TokenType.CLASS;
}
break;
case "t":
if (Tokenizer.cse4(id, "h", "r", "o", "w")) {
case 't':
if (Tokenizer.cse4(id, 'h', 'r', 'o', 'w')) {
return TokenType.THROW;
}
break;
case "y":
if (Tokenizer.cse4(id, "i", "e", "l", "d")) {
case 'y':
if (Tokenizer.cse4(id, 'i', 'e', 'l', 'd')) {
return TokenType.YIELD;
}
break;
case "s":
if (Tokenizer.cse4(id, "u", "p", "e", "r")) {
case 's':
if (Tokenizer.cse4(id, 'u', 'p', 'e', 'r')) {
return TokenType.SUPER;

@@ -460,29 +471,29 @@ }

switch (id.charAt(0)) {
case "r":
if (Tokenizer.cse5(id, "e", "t", "u", "r", "n")) {
case 'r':
if (Tokenizer.cse5(id, 'e', 't', 'u', 'r', 'n')) {
return TokenType.RETURN;
}
break;
case "t":
if (Tokenizer.cse5(id, "y", "p", "e", "o", "f")) {
case 't':
if (Tokenizer.cse5(id, 'y', 'p', 'e', 'o', 'f')) {
return TokenType.TYPEOF;
}
break;
case "d":
if (Tokenizer.cse5(id, "e", "l", "e", "t", "e")) {
case 'd':
if (Tokenizer.cse5(id, 'e', 'l', 'e', 't', 'e')) {
return TokenType.DELETE;
}
break;
case "s":
if (Tokenizer.cse5(id, "w", "i", "t", "c", "h")) {
case 's':
if (Tokenizer.cse5(id, 'w', 'i', 't', 'c', 'h')) {
return TokenType.SWITCH;
}
break;
case "e":
if (Tokenizer.cse5(id, "x", "p", "o", "r", "t")) {
case 'e':
if (Tokenizer.cse5(id, 'x', 'p', 'o', 'r', 't')) {
return TokenType.EXPORT;
}
break;
case "i":
if (Tokenizer.cse5(id, "m", "p", "o", "r", "t")) {
case 'i':
if (Tokenizer.cse5(id, 'm', 'p', 'o', 'r', 't')) {
return TokenType.IMPORT;

@@ -495,14 +506,14 @@ }

switch (id.charAt(0)) {
case "d":
if (Tokenizer.cse6(id, "e", "f", "a", "u", "l", "t")) {
case 'd':
if (Tokenizer.cse6(id, 'e', 'f', 'a', 'u', 'l', 't')) {
return TokenType.DEFAULT;
}
break;
case "f":
if (Tokenizer.cse6(id, "i", "n", "a", "l", "l", "y")) {
case 'f':
if (Tokenizer.cse6(id, 'i', 'n', 'a', 'l', 'l', 'y')) {
return TokenType.FINALLY;
}
break;
case "e":
if (Tokenizer.cse6(id, "x", "t", "e", "n", "d", "s")) {
case 'e':
if (Tokenizer.cse6(id, 'x', 't', 'e', 'n', 'd', 's')) {
return TokenType.EXTENDS;

@@ -515,14 +526,14 @@ }

switch (id.charAt(0)) {
case "f":
if (Tokenizer.cse7(id, "u", "n", "c", "t", "i", "o", "n")) {
case 'f':
if (Tokenizer.cse7(id, 'u', 'n', 'c', 't', 'i', 'o', 'n')) {
return TokenType.FUNCTION;
}
break;
case "c":
if (Tokenizer.cse7(id, "o", "n", "t", "i", "n", "u", "e")) {
case 'c':
if (Tokenizer.cse7(id, 'o', 'n', 't', 'i', 'n', 'u', 'e')) {
return TokenType.CONTINUE;
}
break;
case "d":
if (Tokenizer.cse7(id, "e", "b", "u", "g", "g", "e", "r")) {
case 'd':
if (Tokenizer.cse7(id, 'e', 'b', 'u', 'g', 'g', 'e', 'r')) {
return TokenType.DEBUGGER;

@@ -534,3 +545,3 @@ }

case 10:
if (id === "instanceof") {
if (id === 'instanceof') {
return TokenType.INSTANCEOF;

@@ -543,3 +554,3 @@ }

}, {
key: "skipSingleLineComment",
key: 'skipSingleLineComment',
value: function skipSingleLineComment(offset) {

@@ -555,3 +566,3 @@ this.index += offset;

this.hasLineTerminatorBeforeNext = true;
if (chCode === 0xD /* "\r" */ && this.source.charCodeAt(this.index) === 0xA /*"\n" */) {
if (chCode === 0xD /* "\r" */ && this.source.charCodeAt(this.index) === 0xA /* "\n" */) {
this.index++;

@@ -566,3 +577,3 @@ }

}, {
key: "skipMultiLineComment",
key: 'skipMultiLineComment',
value: function skipMultiLineComment() {

@@ -579,3 +590,3 @@ this.index += 2;

// Block comment ends with "*/".
if (this.source.charAt(this.index + 1) === "/") {
if (this.source.charAt(this.index + 1) === '/') {
this.index = this.index + 2;

@@ -598,3 +609,3 @@ return isLineStart;

this.hasLineTerminatorBeforeNext = true;
if (this.source.charAt(this.index + 1) === "\n") {
if (this.source.charAt(this.index + 1) === '\n') {
this.index++;

@@ -622,3 +633,3 @@ }

}, {
key: "skipComment",
key: 'skipComment',
value: function skipComment() {

@@ -637,3 +648,3 @@ this.hasLineTerminatorBeforeNext = false;

this.index++;
if (chCode === 13 /* "\r" */ && this.source.charAt(this.index) === "\n") {
if (chCode === 13 /* "\r" */ && this.source.charAt(this.index) === '\n') {
this.index++;

@@ -662,3 +673,3 @@ }

// U+003E is ">"
if (this.source.charAt(this.index + 1) === "-" && this.source.charAt(this.index + 2) === ">") {
if (this.source.charAt(this.index + 1) === '-' && this.source.charAt(this.index + 2) === '>') {
// "-->" is a single-line comment

@@ -670,3 +681,3 @@ this.skipSingleLineComment(3);

} else if (!this.moduleIsTheGoalSymbol && chCode === 60 /* "<" */) {
if (this.source.slice(this.index + 1, this.index + 4) === "!--") {
if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
this.skipSingleLineComment(4);

@@ -682,3 +693,3 @@ } else {

}, {
key: "scanHexEscape2",
key: 'scanHexEscape2',
value: function scanHexEscape2() {

@@ -700,6 +711,6 @@ if (this.index + 2 > this.source.length) {

}, {
key: "scanUnicode",
key: 'scanUnicode',
value: function scanUnicode() {
if (this.source.charAt(this.index) === "{") {
//\u{HexDigits}
if (this.source.charAt(this.index) === '{') {
// \u{HexDigits}
var i = this.index + 1;

@@ -720,3 +731,3 @@ var hexDigits = 0,

}
if (ch !== "}") {
if (ch !== '}') {
throw this.createILLEGAL();

@@ -731,3 +742,3 @@ }

} else {
//\uHex4Digits
// \uHex4Digits
if (this.index + 4 > this.source.length) {

@@ -757,5 +768,5 @@ return -1;

}, {
key: "getEscapedIdentifier",
key: 'getEscapedIdentifier',
value: function getEscapedIdentifier() {
var id = "";
var id = '';
var check = _utils.isIdentifierStart;

@@ -768,7 +779,7 @@

++this.index;
if (ch === "\\") {
if (ch === '\\') {
if (this.index >= this.source.length) {
throw this.createILLEGAL();
}
if (this.source.charAt(this.index) !== "u") {
if (this.source.charAt(this.index) !== 'u') {
throw this.createILLEGAL();

@@ -782,3 +793,3 @@ }

ch = fromCodePoint(code);
} else if (0xD800 <= code && code <= 0xDBFF) {
} else if (code >= 0xD800 && code <= 0xDBFF) {
if (this.index >= this.source.length) {

@@ -789,3 +800,3 @@ throw this.createILLEGAL();

++this.index;
if (!(0xDC00 <= lowSurrogateCode && lowSurrogateCode <= 0xDFFF)) {
if (!(lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF)) {
throw this.createILLEGAL();

@@ -809,3 +820,3 @@ }

}, {
key: "getIdentifier",
key: 'getIdentifier',
value: function getIdentifier() {

@@ -819,3 +830,3 @@ var start = this.index;

var code = ch.charCodeAt(0);
if (ch === "\\" || 0xD800 <= code && code <= 0xDBFF) {
if (ch === '\\' || code >= 0xD800 && code <= 0xDBFF) {
// Go back and try the hard one.

@@ -836,3 +847,3 @@ this.index = start;

}, {
key: "scanIdentifier",
key: 'scanIdentifier',
value: function scanIdentifier() {

@@ -843,13 +854,16 @@ var startLocation = this.getLocation();

// Backslash (U+005C) starts an escaped character.
var id = this.source.charAt(this.index) === "\\" ? this.getEscapedIdentifier() : this.getIdentifier();
var id = this.source.charAt(this.index) === '\\' ? this.getEscapedIdentifier() : this.getIdentifier();
// There is no keyword or literal with only one character.
// Thus, it must be an identifier.
var slice = this.getSlice(start, startLocation);
slice.text = id;
var hasEscape = this.index - start !== id.length;
return { type: this.getKeyword(id), value: id, slice: slice };
var type = this.getKeyword(id);
if (hasEscape && type !== TokenType.IDENTIFIER) {
type = TokenType.ESCAPED_KEYWORD;
}
return { type: type, value: id, slice: slice };
}
}, {
key: "getLocation",
key: 'getLocation',
value: function getLocation() {

@@ -863,3 +877,3 @@ return {

}, {
key: "getSlice",
key: 'getSlice',
value: function getSlice(start, startLocation) {

@@ -869,3 +883,3 @@ return { text: this.source.slice(start, this.index), start: start, startLocation: startLocation, end: this.index };

}, {
key: "scanPunctuatorHelper",
key: 'scanPunctuatorHelper',
value: function scanPunctuatorHelper() {

@@ -876,60 +890,60 @@ var ch1 = this.source.charAt(this.index);

// Check for most common single-character punctuators.
case ".":
case '.':
var ch2 = this.source.charAt(this.index + 1);
if (ch2 !== ".") return TokenType.PERIOD;
if (ch2 !== '.') return TokenType.PERIOD;
var ch3 = this.source.charAt(this.index + 2);
if (ch3 !== ".") return TokenType.PERIOD;
if (ch3 !== '.') return TokenType.PERIOD;
return TokenType.ELLIPSIS;
case "(":
case '(':
return TokenType.LPAREN;
case ")":
case ";":
case ",":
case ')':
case ';':
case ',':
return ONE_CHAR_PUNCTUATOR[ch1.charCodeAt(0)];
case "{":
case '{':
return TokenType.LBRACE;
case "}":
case "[":
case "]":
case ":":
case "?":
case "~":
case '}':
case '[':
case ']':
case ':':
case '?':
case '~':
return ONE_CHAR_PUNCTUATOR[ch1.charCodeAt(0)];
default:
// "=" (U+003D) marks an assignment or comparison operator.
if (this.index + 1 < this.source.length && this.source.charAt(this.index + 1) === "=") {
if (this.index + 1 < this.source.length && this.source.charAt(this.index + 1) === '=') {
switch (ch1) {
case "=":
if (this.index + 2 < this.source.length && this.source.charAt(this.index + 2) === "=") {
case '=':
if (this.index + 2 < this.source.length && this.source.charAt(this.index + 2) === '=') {
return TokenType.EQ_STRICT;
}
return TokenType.EQ;
case "!":
if (this.index + 2 < this.source.length && this.source.charAt(this.index + 2) === "=") {
case '!':
if (this.index + 2 < this.source.length && this.source.charAt(this.index + 2) === '=') {
return TokenType.NE_STRICT;
}
return TokenType.NE;
case "|":
case '|':
return TokenType.ASSIGN_BIT_OR;
case "+":
case '+':
return TokenType.ASSIGN_ADD;
case "-":
case '-':
return TokenType.ASSIGN_SUB;
case "*":
case '*':
return TokenType.ASSIGN_MUL;
case "<":
case '<':
return TokenType.LTE;
case ">":
case '>':
return TokenType.GTE;
case "/":
case '/':
return TokenType.ASSIGN_DIV;
case "%":
case '%':
return TokenType.ASSIGN_MOD;
case "^":
case '^':
return TokenType.ASSIGN_BIT_XOR;
case "&":
case '&':
return TokenType.ASSIGN_BIT_AND;
// istanbul ignore next
default:
break; //failed
break; // failed
}

@@ -944,5 +958,5 @@ }

var _ch2 = this.source.charAt(this.index + 2);
if (ch1 === ">" && _ch2 === ">") {
if (ch1 === '>' && _ch2 === '>') {
// 4-character punctuator: >>>=
if (this.index + 3 < this.source.length && this.source.charAt(this.index + 3) === "=") {
if (this.index + 3 < this.source.length && this.source.charAt(this.index + 3) === '=') {
return TokenType.ASSIGN_SHR_UNSIGNED;

@@ -953,11 +967,11 @@ }

if (ch1 === "<" && _ch2 === "=") {
if (ch1 === '<' && _ch2 === '=') {
return TokenType.ASSIGN_SHL;
}
if (ch1 === ">" && _ch2 === "=") {
if (ch1 === '>' && _ch2 === '=') {
return TokenType.ASSIGN_SHR;
}
if (ch1 === "*" && _ch2 === "=") {
if (ch1 === '*' && _ch2 === '=') {
return TokenType.ASSIGN_EXP;

@@ -968,23 +982,23 @@ }

switch (ch1) {
case "*":
case '*':
return TokenType.EXP;
case "+":
case '+':
return TokenType.INC;
case "-":
case '-':
return TokenType.DEC;
case "<":
case '<':
return TokenType.SHL;
case ">":
case '>':
return TokenType.SHR;
case "&":
case '&':
return TokenType.AND;
case "|":
case '|':
return TokenType.OR;
// istanbul ignore next
default:
break; //failed
break; // failed
}
} else if (ch1 === "=" && _ch === ">") {
return TokenType.ARROW;
}
} else if (ch1 === '=' && _ch === '>') {
return TokenType.ARROW;
}
}

@@ -998,3 +1012,3 @@

}, {
key: "scanPunctuator",
key: 'scanPunctuator',
value: function scanPunctuator() {

@@ -1008,3 +1022,3 @@ var startLocation = this.getLocation();

}, {
key: "scanHexLiteral",
key: 'scanHexLiteral',
value: function scanHexLiteral(start, startLocation) {

@@ -1035,3 +1049,3 @@ var i = this.index;

}, {
key: "scanBinaryLiteral",
key: 'scanBinaryLiteral',
value: function scanBinaryLiteral(start, startLocation) {

@@ -1042,3 +1056,3 @@ var offset = this.index - start;

var ch = this.source.charAt(this.index);
if (ch !== "0" && ch !== "1") {
if (ch !== '0' && ch !== '1') {
break;

@@ -1066,7 +1080,7 @@ }

}, {
key: "scanOctalLiteral",
key: 'scanOctalLiteral',
value: function scanOctalLiteral(start, startLocation) {
while (this.index < this.source.length) {
var ch = this.source.charAt(this.index);
if ("0" <= ch && ch <= "7") {
if (ch >= '0' && ch <= '7') {
this.index++;

@@ -1093,3 +1107,3 @@ } else if ((0, _utils.isIdentifierPart)(ch.charCodeAt(0))) {

}, {
key: "scanLegacyOctalLiteral",
key: 'scanLegacyOctalLiteral',
value: function scanLegacyOctalLiteral(start, startLocation) {

@@ -1100,5 +1114,5 @@ var isOctal = true;

var ch = this.source.charAt(this.index);
if ("0" <= ch && ch <= "7") {
if (ch >= '0' && ch <= '7') {
this.index++;
} else if (ch === "8" || ch === "9") {
} else if (ch === '8' || ch === '9') {
isOctal = false;

@@ -1134,3 +1148,3 @@ this.index++;

}, {
key: "scanNumericLiteral",
key: 'scanNumericLiteral',
value: function scanNumericLiteral() {

@@ -1142,16 +1156,16 @@ var ch = this.source.charAt(this.index);

if (ch === "0") {
if (ch === '0') {
this.index++;
if (this.index < this.source.length) {
ch = this.source.charAt(this.index);
if (ch === "x" || ch === "X") {
if (ch === 'x' || ch === 'X') {
this.index++;
return this.scanHexLiteral(start, startLocation);
} else if (ch === "b" || ch === "B") {
} else if (ch === 'b' || ch === 'B') {
this.index++;
return this.scanBinaryLiteral(start, startLocation);
} else if (ch === "o" || ch === "O") {
} else if (ch === 'o' || ch === 'O') {
this.index++;
return this.scanOctalLiteral(start, startLocation);
} else if ("0" <= ch && ch <= "9") {
} else if (ch >= '0' && ch <= '9') {
return this.scanLegacyOctalLiteral(start, startLocation);

@@ -1169,6 +1183,6 @@ }

}
} else if (ch !== ".") {
} else if (ch !== '.') {
// Must be "1".."9"
ch = this.source.charAt(this.index);
while ("0" <= ch && ch <= "9") {
while (ch >= '0' && ch <= '9') {
this.index++;

@@ -1205,6 +1219,6 @@ if (this.index === this.source.length) {

}, {
key: "eatDecimalLiteralSuffix",
key: 'eatDecimalLiteralSuffix',
value: function eatDecimalLiteralSuffix() {
var ch = this.source.charAt(this.index);
if (ch === ".") {
if (ch === '.') {
this.index++;

@@ -1216,3 +1230,3 @@ if (this.index === this.source.length) {

ch = this.source.charAt(this.index);
while ("0" <= ch && ch <= "9") {
while (ch >= '0' && ch <= '9') {
this.index++;

@@ -1227,3 +1241,3 @@ if (this.index === this.source.length) {

// EOF not reached here
if (ch === "e" || ch === "E") {
if (ch === 'e' || ch === 'E') {
this.index++;

@@ -1235,3 +1249,3 @@ if (this.index === this.source.length) {

ch = this.source.charAt(this.index);
if (ch === "+" || ch === "-") {
if (ch === '+' || ch === '-') {
this.index++;

@@ -1244,4 +1258,4 @@ if (this.index === this.source.length) {

if ("0" <= ch && ch <= "9") {
while ("0" <= ch && ch <= "9") {
if (ch >= '0' && ch <= '9') {
while (ch >= '0' && ch <= '9') {
this.index++;

@@ -1259,3 +1273,3 @@ if (this.index === this.source.length) {

}, {
key: "scanStringEscape",
key: 'scanStringEscape',
value: function scanStringEscape(str, octal) {

@@ -1269,16 +1283,16 @@ this.index++;

switch (ch) {
case "n":
str += "\n";
case 'n':
str += '\n';
this.index++;
break;
case "r":
str += "\r";
case 'r':
str += '\r';
this.index++;
break;
case "t":
str += "\t";
case 't':
str += '\t';
this.index++;
break;
case "u":
case "x":
case 'u':
case 'x':
var unescaped = void 0;

@@ -1289,3 +1303,3 @@ this.index++;

}
unescaped = ch === "u" ? this.scanUnicode() : this.scanHexEscape2();
unescaped = ch === 'u' ? this.scanUnicode() : this.scanHexEscape2();
if (unescaped < 0) {

@@ -1296,16 +1310,16 @@ throw this.createILLEGAL();

break;
case "b":
str += "\b";
case 'b':
str += '\b';
this.index++;
break;
case "f":
str += "\f";
case 'f':
str += '\f';
this.index++;
break;
case "v":
str += "\u000b";
case 'v':
str += '\x0B';
this.index++;
break;
default:
if ("0" <= ch && ch <= "7") {
if (ch >= '0' && ch <= '7') {
var octalStart = this.index;

@@ -1315,13 +1329,13 @@ var octLen = 1;

// with 0, 1, 2, 3
if ("0" <= ch && ch <= "3") {
if (ch >= '0' && ch <= '3') {
octLen = 0;
}
var code = 0;
while (octLen < 3 && "0" <= ch && ch <= "7") {
while (octLen < 3 && ch >= '0' && ch <= '7') {
this.index++;
if (octLen > 0 || ch !== "0") {
if (octLen > 0 || ch !== '0') {
octal = this.source.slice(octalStart, this.index);
}
code *= 8;
code += ch - "0";
code += ch - '0';
octLen++;

@@ -1334,3 +1348,3 @@ if (this.index === this.source.length) {

str += String.fromCharCode(code);
} else if (ch === "8" || ch === "9") {
} else if (ch === '8' || ch === '9') {
throw this.createILLEGAL();

@@ -1344,3 +1358,3 @@ } else {

this.index++;
if (ch === "\r" && this.source.charAt(this.index) === "\n") {
if (ch === '\r' && this.source.charAt(this.index) === '\n') {
this.index++;

@@ -1356,5 +1370,5 @@ }

}, {
key: "scanStringLiteral",
key: 'scanStringLiteral',
value: function scanStringLiteral() {
var str = "";
var str = '';

@@ -1374,3 +1388,3 @@ var quote = this.source.charAt(this.index);

return { type: TokenType.STRING, slice: this.getSlice(start, startLocation), str: str, octal: octal };
} else if (ch === "\\") {
} else if (ch === '\\') {
var _scanStringEscape = this.scanStringEscape(str, octal);

@@ -1393,3 +1407,3 @@

}, {
key: "scanTemplateElement",
key: 'scanTemplateElement',
value: function scanTemplateElement() {

@@ -1418,3 +1432,3 @@ var startLocation = this.getLocation();

{
var octal = this.scanStringEscape("", null)[1];
var octal = this.scanStringEscape('', null)[1];
if (octal != null) {

@@ -1433,3 +1447,3 @@ throw this.createILLEGAL();

}, {
key: "scanRegExp",
key: 'scanRegExp',
value: function scanRegExp(str) {

@@ -1443,3 +1457,3 @@ var startLocation = this.getLocation();

var ch = this.source.charAt(this.index);
if (ch === "\\") {
if (ch === '\\') {
str += ch;

@@ -1458,14 +1472,12 @@ this.index++;

if (classMarker) {
if (ch === "]") {
if (ch === ']') {
classMarker = false;
}
} else {
if (ch === "/") {
terminated = true;
str += ch;
this.index++;
break;
} else if (ch === "[") {
classMarker = true;
}
} else if (ch === '/') {
terminated = true;
str += ch;
this.index++;
break;
} else if (ch === '[') {
classMarker = true;
}

@@ -1483,3 +1495,3 @@ str += ch;

var _ch3 = this.source.charAt(this.index);
if (_ch3 === "\\") {
if (_ch3 === '\\') {
throw this.createError(_errors.ErrorMessages.INVALID_REGEXP_FLAGS);

@@ -1496,3 +1508,3 @@ }

}, {
key: "advance",
key: 'advance',
value: function advance() {

@@ -1551,3 +1563,3 @@ var startLocation = this.getLocation();

if (0x30 /* "0" */ <= charCode && charCode <= 0x39 /* "9" */) {
if (charCode /* "0" */ >= 0x30 && charCode <= 0x39 /* "9" */) {
return this.scanNumericLiteral();

@@ -1559,3 +1571,3 @@ }

} else {
if ((0, _utils.isIdentifierStart)(charCode) || 0xD800 <= charCode && charCode <= 0xDBFF) {
if ((0, _utils.isIdentifierStart)(charCode) || charCode >= 0xD800 && charCode <= 0xDBFF) {
return this.scanIdentifier();

@@ -1568,3 +1580,3 @@ }

}, {
key: "eof",
key: 'eof',
value: function eof() {

@@ -1574,3 +1586,3 @@ return this.lookahead.type === TokenType.EOS;

}, {
key: "lex",
key: 'lex',
value: function lex() {

@@ -1583,3 +1595,3 @@ var prevToken = this.lookahead;

}], [{
key: "cse2",
key: 'cse2',
value: function cse2(id, ch1, ch2) {

@@ -1589,3 +1601,3 @@ return id.charAt(1) === ch1 && id.charAt(2) === ch2;

}, {
key: "cse3",
key: 'cse3',
value: function cse3(id, ch1, ch2, ch3) {

@@ -1595,3 +1607,3 @@ return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3;

}, {
key: "cse4",
key: 'cse4',
value: function cse4(id, ch1, ch2, ch3, ch4) {

@@ -1601,3 +1613,3 @@ return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4;

}, {
key: "cse5",
key: 'cse5',
value: function cse5(id, ch1, ch2, ch3, ch4, ch5) {

@@ -1607,3 +1619,3 @@ return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4 && id.charAt(5) === ch5;

}, {
key: "cse6",
key: 'cse6',
value: function cse6(id, ch1, ch2, ch3, ch4, ch5, ch6) {

@@ -1613,3 +1625,3 @@ return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4 && id.charAt(5) === ch5 && id.charAt(6) === ch6;

}, {
key: "cse7",
key: 'cse7',
value: function cse7(id, ch1, ch2, ch3, ch4, ch5, ch6, ch7) {

@@ -1616,0 +1628,0 @@ return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4 && id.charAt(5) === ch5 && id.charAt(6) === ch6 && id.charAt(7) === ch7;

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,48 +6,60 @@ Object.defineProperty(exports, "__esModule", {

});
exports.isDecimalDigit = exports.isLineTerminator = exports.isWhiteSpace = exports.isIdentifierPart = exports.isIdentifierStart = exports.isRestrictedWord = undefined;
exports.isStrictModeReservedWord = isStrictModeReservedWord;
exports.isWhiteSpace = isWhiteSpace;
exports.isLineTerminator = isLineTerminator;
exports.isIdentifierStart = isIdentifierStart;
exports.isIdentifierPart = isIdentifierPart;
exports.isDecimalDigit = isDecimalDigit;
exports.getHexValue = getHexValue;
var _esutils = require("esutils");
var _unicode = require('./unicode');
var isReservedWordES6 = _esutils.keyword.isReservedWordES6; /**
* Copyright 2014 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var strictReservedWords = new Set(['null', 'true', 'false', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'let', 'if', 'in', 'do', 'var', 'for', 'new', 'try', 'this', 'else', 'case', 'void', 'with', 'enum', 'while', 'break', 'catch', 'throw', 'const', 'yield', 'class', 'super', 'return', 'typeof', 'delete', 'switch', 'export', 'import', 'default', 'finally', 'extends', 'function', 'continue', 'debugger', 'instanceof']); /**
* Copyright 2017 Shape Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var isRestrictedWord = _esutils.keyword.isRestrictedWord;
var isIdentifierStartES6 = _esutils.code.isIdentifierStartES6;
var isIdentifierPartES6 = _esutils.code.isIdentifierPartES6;
var isWhiteSpace = _esutils.code.isWhiteSpace;
var isLineTerminator = _esutils.code.isLineTerminator;
var isDecimalDigit = _esutils.code.isDecimalDigit;
exports.isRestrictedWord = isRestrictedWord;
exports.isIdentifierStart = isIdentifierStartES6;
exports.isIdentifierPart = isIdentifierPartES6;
exports.isWhiteSpace = isWhiteSpace;
exports.isLineTerminator = isLineTerminator;
exports.isDecimalDigit = isDecimalDigit;
function isStrictModeReservedWord(id) {
return isReservedWordES6(id, true);
return strictReservedWords.has(id);
}
function isWhiteSpace(ch) {
return ch < 128 ? _unicode.whitespaceBool[ch] : ch === 0xA0 || ch > 0x167F && _unicode.whitespaceArray.indexOf(ch) !== -1;
}
function isLineTerminator(ch) {
return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
}
function isIdentifierStart(ch) {
return ch < 128 ? _unicode.idStartBool[ch] : _unicode.idStartLargeRegex.test(String.fromCodePoint(ch));
}
function isIdentifierPart(ch) {
return ch < 128 ? _unicode.idContinueBool[ch] : _unicode.idContinueLargeRegex.test(String.fromCodePoint(ch));
}
function isDecimalDigit(ch) {
return ch >= 48 && ch <= 57;
}
function getHexValue(rune) {
if ("0" <= rune && rune <= "9") {
if (rune >= '0' && rune <= '9') {
return rune.charCodeAt(0) - 48;
}
if ("a" <= rune && rune <= "f") {
if (rune >= 'a' && rune <= 'f') {
return rune.charCodeAt(0) - 87;
}
if ("A" <= rune && rune <= "F") {
if (rune >= 'A' && rune <= 'F') {
return rune.charCodeAt(0) - 55;

@@ -54,0 +66,0 @@ }

{
"name": "shift-parser",
"version": "5.0.2",
"version": "5.0.3",
"description": "ECMAScript parser that produces a Shift format AST",

@@ -16,12 +16,15 @@ "author": "Shape Security Labs",

"scripts": {
"test": "mocha --inline-diffs --check-leaks --ui tdd --reporter dot --slow 200 --timeout 5000 --recursive test",
"build": "babel --source-maps-inline --out-dir dist src",
"clean": "rm -rf dist coverage .nyc_output",
"test": "mocha --inline-diffs --check-leaks --ui tdd --reporter dot --slow 200 --timeout 5000 --recursive test --compilers js:babel-core/register",
"coverage": "npm run build -- --plugins=istanbul && nyc --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test",
"lint": "eslint src test",
"build": "babel --out-dir dist src",
"prepublish": "rm -rf dist/* && npm update && npm run build",
"benchmark": "node benchmark",
"profile": "node --prof profile.js && node-tick-processor",
"cjsify": "npm run build && cjsify dist/index.js --no-node --export Shift --output dist/shift.js"
"cjsify": "npm run build && cjsify dist/index.js --no-node --export Shift --output dist/shift.js",
"regenerate-unicode": "node scripts/generate-unicode-data.js > src/unicode.js"
},
"dependencies": {
"es6-map": "^0.1.1",
"esutils": "^2.0.2",
"multimap": "^0.1.1",

@@ -35,3 +38,4 @@ "shift-ast": "^4.0.0",

"babel-cli": "6.3.13",
"babel-register": "6.3.13",
"babel-core": "6.21.0",
"babel-plugin-istanbul": "4.0.0",
"babel-preset-es2015": "6.3.13",

@@ -45,6 +49,10 @@ "benchmark": "1.0.0",

"mocha": "2.3.4",
"nyc": "10.1.2",
"regenerate": "^1.3.2",
"shift-spec": "^2016.0.0",
"test262-parser-tests": "0.0.1",
"tick": "0.1.1",
"traceur": "0.0.91",
"uglifyjs": "2.4.10"
"uglifyjs": "2.4.10",
"unicode-8.0.0": "^0.7.0"
},

@@ -69,3 +77,10 @@ "keywords": [

},
"license": "Apache-2.0"
"license": "Apache-2.0",
"nyc": {
"include": [
"src"
],
"sourceMap": false,
"instrument": false
}
}

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