babylon
Advanced tools
Comparing version 5.7.1 to 5.7.2
@@ -35,3 +35,3 @@ // A recursive descent parser operates by defining functions for all | ||
pp.checkPropClash = function (prop, propHash) { | ||
if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) return; | ||
if (prop.computed || prop.method || prop.shorthand) return; | ||
@@ -50,23 +50,6 @@ var key = prop.key, | ||
var kind = prop.kind; | ||
if (this.options.ecmaVersion >= 6) { | ||
if (name === "__proto__" && kind === "init") { | ||
if (propHash.proto) this.raise(key.start, "Redefinition of __proto__ property"); | ||
propHash.proto = true; | ||
} | ||
return; | ||
if (name === "__proto__" && kind === "init") { | ||
if (propHash.proto) this.raise(key.start, "Redefinition of __proto__ property"); | ||
propHash.proto = true; | ||
} | ||
var other = undefined; | ||
if (propHash[name]) { | ||
other = propHash[name]; | ||
var isGetSet = kind !== "init"; | ||
if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property"); | ||
} else { | ||
other = propHash[name] = { | ||
init: false, | ||
get: false, | ||
set: false | ||
}; | ||
} | ||
other[kind] = true; | ||
}; | ||
@@ -270,3 +253,7 @@ | ||
base = this.finishNode(node, "MemberExpression"); | ||
} else if (!noCalls && this.eat(_tokentype.types.parenL)) { | ||
} else if (!noCalls && this.type === _tokentype.types.parenL) { | ||
var possibleAsync = false; | ||
if (base.type === "Identifier" && base.name === "async" && !this.canInsertSemicolon()) possibleAsync = true; | ||
this.next(); | ||
var node = this.startNodeAt(startPos, startLoc); | ||
@@ -276,2 +263,6 @@ node.callee = base; | ||
base = this.finishNode(node, "CallExpression"); | ||
if (possibleAsync && (this.type === _tokentype.types.colon || this.type === _tokentype.types.arrow)) { | ||
return this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node); | ||
} | ||
} else if (this.type === _tokentype.types.backQuote) { | ||
@@ -288,2 +279,8 @@ var node = this.startNodeAt(startPos, startLoc); | ||
pp.parseAsyncArrowFromCallExpression = function (node, call) { | ||
if (!this.options.features["es7.asyncFunctions"]) this.unexpected(); | ||
this.expect(_tokentype.types.arrow); | ||
return this.parseArrowExpression(node, call.arguments, true); | ||
}; | ||
// Parse a no-call expression (like argument of `new` or `::` operators). | ||
@@ -332,4 +329,2 @@ | ||
case _tokentype.types.name: | ||
var startPos = this.start, | ||
startLoc = this.startLoc; | ||
node = this.startNode(); | ||
@@ -340,38 +335,16 @@ var id = this.parseIdent(true); | ||
if (this.options.features["es7.asyncFunctions"]) { | ||
// async functions! | ||
if (id.name === "async" && !this.canInsertSemicolon()) { | ||
// arrow functions | ||
if (this.type === _tokentype.types.parenL) { | ||
var expr = this.parseParenAndDistinguishExpression(startPos, startLoc, true, true); | ||
if (expr && expr.type === "ArrowFunctionExpression") { | ||
return expr; | ||
} else { | ||
node.callee = id; | ||
if (!expr) { | ||
node.arguments = []; | ||
} else if (expr.type === "SequenceExpression") { | ||
node.arguments = expr.expressions; | ||
} else { | ||
node.arguments = [expr]; | ||
} | ||
return this.parseSubscripts(this.finishNode(node, "CallExpression"), startPos, startLoc); | ||
} | ||
} else if (this.type === _tokentype.types.name) { | ||
id = this.parseIdent(); | ||
this.expect(_tokentype.types.arrow); | ||
return this.parseArrowExpression(node, [id], true); | ||
} | ||
// normal functions | ||
if (this.type === _tokentype.types._function && !this.canInsertSemicolon()) { | ||
this.next(); | ||
return this.parseFunction(node, false, false, true); | ||
} | ||
} else if (id.name === "await") { | ||
if (id.name === "await") { | ||
if (this.inAsync) return this.parseAwait(node); | ||
} else if (id.name === "async" && this.type === _tokentype.types._function && !this.canInsertSemicolon()) { | ||
this.next(); | ||
return this.parseFunction(node, false, false, true); | ||
} else if (id.name === "async" && this.type === _tokentype.types.name) { | ||
var params = [this.parseIdent()]; | ||
this.expect(_tokentype.types.arrow); | ||
// var foo = bar => {}; | ||
return this.parseArrowExpression(node, params, true); | ||
} | ||
} | ||
// | ||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id]); | ||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) return this.parseArrowExpression(node, [id]); | ||
@@ -403,3 +376,3 @@ return id; | ||
// check whether this is array comprehension or regular array | ||
if ((this.options.ecmaVersion >= 7 || this.options.features["es7.comprehensions"]) && this.type === _tokentype.types._for) { | ||
if (this.options.features["es7.comprehensions"] && this.type === _tokentype.types._for) { | ||
return this.parseComprehension(node, false); | ||
@@ -467,70 +440,66 @@ } | ||
var val = undefined; | ||
if (this.options.ecmaVersion >= 6) { | ||
this.next(); | ||
this.next(); | ||
if ((this.options.features["es7.comprehensions"] || this.options.ecmaVersion >= 7) && this.type === _tokentype.types._for) { | ||
return this.parseComprehension(this.startNodeAt(startPos, startLoc), true); | ||
} | ||
if (this.options.features["es7.comprehensions"] && this.type === _tokentype.types._for) { | ||
return this.parseComprehension(this.startNodeAt(startPos, startLoc), true); | ||
} | ||
var innerStartPos = this.start, | ||
innerStartLoc = this.startLoc; | ||
var exprList = [], | ||
first = true; | ||
var refShorthandDefaultPos = { start: 0 }, | ||
spreadStart = undefined, | ||
innerParenStart = undefined, | ||
optionalCommaStart = undefined; | ||
while (this.type !== _tokentype.types.parenR) { | ||
if (first) { | ||
first = false; | ||
} else { | ||
this.expect(_tokentype.types.comma); | ||
if (this.type === _tokentype.types.parenR && this.options.features["es7.trailingFunctionCommas"]) { | ||
optionalCommaStart = this.start; | ||
break; | ||
} | ||
} | ||
if (this.type === _tokentype.types.ellipsis) { | ||
var spreadNodeStartPos = this.start, | ||
spreadNodeStartLoc = this.startLoc; | ||
spreadStart = this.start; | ||
exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStartLoc, spreadNodeStartPos)); | ||
var innerStartPos = this.start, | ||
innerStartLoc = this.startLoc; | ||
var exprList = [], | ||
first = true; | ||
var refShorthandDefaultPos = { start: 0 }, | ||
spreadStart = undefined, | ||
innerParenStart = undefined, | ||
optionalCommaStart = undefined; | ||
while (this.type !== _tokentype.types.parenR) { | ||
if (first) { | ||
first = false; | ||
} else { | ||
this.expect(_tokentype.types.comma); | ||
if (this.type === _tokentype.types.parenR && this.options.features["es7.trailingFunctionCommas"]) { | ||
optionalCommaStart = this.start; | ||
break; | ||
} else { | ||
if (this.type === _tokentype.types.parenL && !innerParenStart) { | ||
innerParenStart = this.start; | ||
} | ||
exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem)); | ||
} | ||
} | ||
var innerEndPos = this.start, | ||
innerEndLoc = this.startLoc; | ||
this.expect(_tokentype.types.parenR); | ||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) { | ||
if (innerParenStart) this.unexpected(innerParenStart); | ||
return this.parseParenArrowList(startPos, startLoc, exprList, isAsync); | ||
} | ||
if (!exprList.length) { | ||
if (isAsync) { | ||
return; | ||
} else { | ||
this.unexpected(this.lastTokStart); | ||
if (this.type === _tokentype.types.ellipsis) { | ||
var spreadNodeStartPos = this.start, | ||
spreadNodeStartLoc = this.startLoc; | ||
spreadStart = this.start; | ||
exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStartLoc, spreadNodeStartPos)); | ||
break; | ||
} else { | ||
if (this.type === _tokentype.types.parenL && !innerParenStart) { | ||
innerParenStart = this.start; | ||
} | ||
exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem)); | ||
} | ||
if (optionalCommaStart) this.unexpected(optionalCommaStart); | ||
if (spreadStart) this.unexpected(spreadStart); | ||
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start); | ||
} | ||
var innerEndPos = this.start, | ||
innerEndLoc = this.startLoc; | ||
this.expect(_tokentype.types.parenR); | ||
if (exprList.length > 1) { | ||
val = this.startNodeAt(innerStartPos, innerStartLoc); | ||
val.expressions = exprList; | ||
this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); | ||
if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokentype.types.arrow)) { | ||
if (innerParenStart) this.unexpected(innerParenStart); | ||
return this.parseParenArrowList(startPos, startLoc, exprList, isAsync); | ||
} | ||
if (!exprList.length) { | ||
if (isAsync) { | ||
return; | ||
} else { | ||
val = exprList[0]; | ||
this.unexpected(this.lastTokStart); | ||
} | ||
} | ||
if (optionalCommaStart) this.unexpected(optionalCommaStart); | ||
if (spreadStart) this.unexpected(spreadStart); | ||
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start); | ||
if (exprList.length > 1) { | ||
val = this.startNodeAt(innerStartPos, innerStartLoc); | ||
val.expressions = exprList; | ||
this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); | ||
} else { | ||
val = this.parseParenExpression(); | ||
val = exprList[0]; | ||
} | ||
@@ -558,3 +527,3 @@ | ||
if (this.options.ecmaVersion >= 6 && this.eat(_tokentype.types.dot)) { | ||
if (this.eat(_tokentype.types.dot)) { | ||
node.meta = meta; | ||
@@ -646,11 +615,9 @@ node.property = this.parseIdent(true); | ||
} | ||
if (this.options.ecmaVersion >= 6) { | ||
prop.method = false; | ||
prop.shorthand = false; | ||
if (isPattern || refShorthandDefaultPos) { | ||
startPos = this.start; | ||
startLoc = this.startLoc; | ||
} | ||
if (!isPattern) isGenerator = this.eat(_tokentype.types.star); | ||
prop.method = false; | ||
prop.shorthand = false; | ||
if (isPattern || refShorthandDefaultPos) { | ||
startPos = this.start; | ||
startLoc = this.startLoc; | ||
} | ||
if (!isPattern) isGenerator = this.eat(_tokentype.types.star); | ||
if (this.options.features["es7.asyncFunctions"] && this.isContextual("async")) { | ||
@@ -682,3 +649,3 @@ if (isGenerator || isPattern) this.unexpected(); | ||
prop.kind = "init"; | ||
} else if (this.options.ecmaVersion >= 6 && this.type === _tokentype.types.parenL) { | ||
} else if (this.type === _tokentype.types.parenL) { | ||
if (isPattern) this.unexpected(); | ||
@@ -688,3 +655,3 @@ prop.kind = "init"; | ||
prop.value = this.parseMethod(isGenerator, isAsync); | ||
} else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type !== _tokentype.types.comma && this.type !== _tokentype.types.braceR)) { | ||
} else if (!prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type !== _tokentype.types.comma && this.type !== _tokentype.types.braceR)) { | ||
if (isGenerator || isAsync || isPattern) this.unexpected(); | ||
@@ -699,3 +666,3 @@ prop.kind = prop.key.name; | ||
} | ||
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { | ||
} else if (!prop.computed && prop.key.type === "Identifier") { | ||
prop.kind = "init"; | ||
@@ -718,13 +685,11 @@ if (isPattern) { | ||
pp.parsePropertyName = function (prop) { | ||
if (this.options.ecmaVersion >= 6) { | ||
if (this.eat(_tokentype.types.bracketL)) { | ||
prop.computed = true; | ||
prop.key = this.parseMaybeAssign(); | ||
this.expect(_tokentype.types.bracketR); | ||
return prop.key; | ||
} else { | ||
prop.computed = false; | ||
} | ||
if (this.eat(_tokentype.types.bracketL)) { | ||
prop.computed = true; | ||
prop.key = this.parseMaybeAssign(); | ||
this.expect(_tokentype.types.bracketR); | ||
return prop.key; | ||
} else { | ||
prop.computed = false; | ||
return prop.key = this.type === _tokentype.types.num || this.type === _tokentype.types.string ? this.parseExprAtom() : this.parseIdent(true); | ||
} | ||
return prop.key = this.type === _tokentype.types.num || this.type === _tokentype.types.string ? this.parseExprAtom() : this.parseIdent(true); | ||
}; | ||
@@ -736,6 +701,4 @@ | ||
node.id = null; | ||
if (this.options.ecmaVersion >= 6) { | ||
node.generator = false; | ||
node.expression = false; | ||
} | ||
node.generator = false; | ||
node.expression = false; | ||
if (this.options.features["es7.asyncFunctions"]) { | ||
@@ -753,5 +716,3 @@ node.async = !!isAsync; | ||
node.params = this.parseBindingList(_tokentype.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]); | ||
if (this.options.ecmaVersion >= 6) { | ||
node.generator = isGenerator; | ||
} | ||
node.generator = isGenerator; | ||
this.parseFunctionBody(node); | ||
@@ -845,3 +806,3 @@ return this.finishNode(node, "FunctionExpression"); | ||
if (this.type === _tokentype.types.name) { | ||
if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && _identifier.reservedWords.strict(this.value) && (this.options.ecmaVersion >= 6 || this.input.slice(this.start, this.end).indexOf("\\") === -1))) this.raise(this.start, "The keyword '" + this.value + "' is reserved"); | ||
if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && _identifier.reservedWords.strict(this.value))) this.raise(this.start, "The keyword '" + this.value + "' is reserved"); | ||
node.name = this.value; | ||
@@ -848,0 +809,0 @@ } else if (liberal && this.type.keyword) { |
@@ -20,2 +20,8 @@ "use strict"; | ||
pp.setState = function (state) { | ||
for (var key in state) { | ||
this[key] = state[key]; | ||
} | ||
}; | ||
pp.lookahead = function () { | ||
@@ -27,4 +33,4 @@ var old = this.getState(); | ||
var curr = this.getState(); | ||
for (var key in old) this[key] = old[key]; | ||
this.setState(old); | ||
return curr; | ||
}; |
@@ -15,3 +15,3 @@ "use strict"; | ||
pp.toAssignable = function (node, isBinding) { | ||
if (this.options.ecmaVersion >= 6 && node) { | ||
if (node) { | ||
switch (node.type) { | ||
@@ -102,3 +102,2 @@ case "Identifier": | ||
pp.parseBindingAtom = function () { | ||
if (this.options.ecmaVersion < 6) return this.parseIdent(); | ||
switch (this.type) { | ||
@@ -105,0 +104,0 @@ case _tokentype.types.name: |
@@ -14,7 +14,2 @@ "use strict"; | ||
var defaultOptions = { | ||
// `ecmaVersion` indicates the ECMAScript version to parse. Must | ||
// be either 3, or 5, or 6. This influences support for strict | ||
// mode, the set of reserved words, support for getters and | ||
// setters and other features. | ||
ecmaVersion: 5, | ||
// Source type ("script" or "module") for different semantics | ||
@@ -88,5 +83,2 @@ sourceType: "script", | ||
directSourceFile: null, | ||
// When enabled, parenthesized expressions are represented by | ||
// (non-standard) ParenthesizedExpression nodes | ||
preserveParens: false, | ||
plugins: {}, | ||
@@ -93,0 +85,0 @@ // Babel-specific options |
@@ -16,3 +16,3 @@ "use strict"; | ||
pp.isUseStrict = function (stmt) { | ||
return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.raw.slice(1, -1) === "use strict"; | ||
return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.raw.slice(1, -1) === "use strict"; | ||
}; | ||
@@ -19,0 +19,0 @@ |
@@ -599,3 +599,5 @@ "use strict"; | ||
return function (node, allowExpression) { | ||
if (this.type === _tokentype.types.colon) { | ||
if (this.type === _tokentype.types.colon && !allowExpression) { | ||
// if allowExpression is true then we're parsing an arrow function and if | ||
// there's a return type then it's been handled elsewhere | ||
node.returnType = this.flowParseTypeAnnotation(); | ||
@@ -648,3 +650,3 @@ } | ||
instance.extend("parseParenItem", function () { | ||
return function (node, startLoc, startPos) { | ||
return function (node, startLoc, startPos, forceArrow) { | ||
if (this.type === _tokentype.types.colon) { | ||
@@ -654,3 +656,15 @@ var typeCastNode = this.startNodeAt(startLoc, startPos); | ||
typeCastNode.typeAnnotation = this.flowParseTypeAnnotation(); | ||
return this.finishNode(typeCastNode, "TypeCastExpression"); | ||
if (forceArrow && this.type !== _tokentype.types.arrow) { | ||
this.unexpected(); | ||
} | ||
if (this.eat(_tokentype.types.arrow)) { | ||
// ((lol): number => {}); | ||
var func = this.parseArrowExpression(this.startNodeAt(startLoc, startPos), [node]); | ||
func.returnType = typeCastNode.typeAnnotation; | ||
return func; | ||
} else { | ||
return this.finishNode(typeCastNode, "TypeCastExpression"); | ||
} | ||
} else { | ||
@@ -825,4 +839,53 @@ return node; | ||
}); | ||
// var foo = (async (): number => {}); | ||
instance.extend("parseAsyncArrowFromCallExpression", function (inner) { | ||
return function (node, call) { | ||
if (this.type === _tokentype.types.colon) { | ||
node.returnType = this.flowParseTypeAnnotation(); | ||
} | ||
return inner.call(this, node, call); | ||
}; | ||
}); | ||
instance.extend("parseParenAndDistinguishExpression", function (inner) { | ||
return function (startPos, startLoc, canBeArrow, isAsync) { | ||
startPos = startPos || this.start; | ||
startLoc = startLoc || this.startLoc; | ||
if (this.lookahead().type === _tokentype.types.parenR) { | ||
// var foo = (): number => {}; | ||
this.expect(_tokentype.types.parenL); | ||
this.expect(_tokentype.types.parenR); | ||
var node = this.startNodeAt(startPos, startLoc); | ||
if (this.type === _tokentype.types.colon) node.returnType = this.flowParseTypeAnnotation(); | ||
this.expect(_tokentype.types.arrow); | ||
return this.parseArrowExpression(node, [], isAsync); | ||
} else { | ||
// var foo = (foo): number => {}; | ||
var node = inner.call(this, startPos, startLoc, canBeArrow, isAsync); | ||
var state = this.getState(); | ||
if (this.type === _tokentype.types.colon) { | ||
try { | ||
return this.parseParenItem(node, startPos, startLoc, true); | ||
} catch (err) { | ||
if (err instanceof SyntaxError) { | ||
this.setState(state); | ||
return node; | ||
} else { | ||
throw err; | ||
} | ||
} | ||
} else { | ||
return node; | ||
} | ||
} | ||
}; | ||
}); | ||
}; | ||
module.exports = exports["default"]; |
@@ -15,4 +15,4 @@ "use strict"; | ||
this.sourceFile = this.options.sourceFile || null; | ||
this.isKeyword = _identifier.keywords[this.options.ecmaVersion >= 6 ? 6 : 5]; | ||
this.isReservedWord = _identifier.reservedWords[this.options.ecmaVersion]; | ||
this.isKeyword = _identifier.keywords[6]; | ||
this.isReservedWord = _identifier.reservedWords[6]; | ||
this.input = input; | ||
@@ -19,0 +19,0 @@ this.loadPlugins(this.options.plugins); |
@@ -30,5 +30,3 @@ "use strict"; | ||
this.next(); | ||
if (this.options.ecmaVersion >= 6) { | ||
node.sourceType = this.options.sourceType; | ||
} | ||
node.sourceType = this.options.sourceType; | ||
return this.finishNode(node, "Program"); | ||
@@ -69,3 +67,3 @@ }; | ||
case _tokentype.types._function: | ||
if (!declaration && this.options.ecmaVersion >= 6) this.unexpected(); | ||
if (!declaration) this.unexpected(); | ||
return this.parseFunctionStatement(node); | ||
@@ -206,7 +204,3 @@ | ||
node.test = this.parseParenExpression(); | ||
if (this.options.ecmaVersion >= 6) { | ||
this.eat(_tokentype.types.semi); | ||
} else { | ||
this.semicolon(); | ||
} | ||
this.eat(_tokentype.types.semi); | ||
return this.finishNode(node, "DoWhileStatement"); | ||
@@ -238,3 +232,3 @@ }; | ||
this.finishNode(_init, "VariableDeclaration"); | ||
if ((this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== _tokentype.types._var && _init.declarations[0].init)) return this.parseForIn(node, _init); | ||
if ((this.type === _tokentype.types._in || this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== _tokentype.types._var && _init.declarations[0].init)) return this.parseForIn(node, _init); | ||
return this.parseFor(node, _init); | ||
@@ -245,3 +239,3 @@ } | ||
var init = this.parseExpression(true, refShorthandDefaultPos); | ||
if (this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) { | ||
if (this.type === _tokentype.types._in || this.isContextual("of")) { | ||
this.toAssignable(init); | ||
@@ -487,3 +481,3 @@ this.checkLVal(init); | ||
decl.init = this.parseMaybeAssign(isFor); | ||
} else if (kind === _tokentype.types._const && !(this.type === _tokentype.types._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) { | ||
} else if (kind === _tokentype.types._const && !(this.type === _tokentype.types._in || this.isContextual("of"))) { | ||
this.unexpected(); | ||
@@ -511,5 +505,3 @@ } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === _tokentype.types._in || this.isContextual("of")))) { | ||
this.initFunction(node, isAsync); | ||
if (this.options.ecmaVersion >= 6) { | ||
node.generator = this.eat(_tokentype.types.star); | ||
} | ||
node.generator = this.eat(_tokentype.types.star); | ||
@@ -516,0 +508,0 @@ if (isStatement || this.type === _tokentype.types.name) { |
@@ -103,3 +103,3 @@ "use strict"; | ||
// identifiers, so '\' also dispatches to that. | ||
if (_identifier.isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord(); | ||
if (_identifier.isIdentifierStart(code, true) || code === 92 /* '\' */) return this.readWord(); | ||
@@ -228,3 +228,3 @@ return this.getTokenFromCode(code); | ||
var next2 = this.input.charCodeAt(this.pos + 2); | ||
if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { | ||
if (next === 46 && next2 === 46) { | ||
// 46 = dot '.' | ||
@@ -256,3 +256,3 @@ this.pos += 3; | ||
if (next === 42) { | ||
if (next === 42 && this.options.features["es7.exponentiationOperator"]) { | ||
// '*' | ||
@@ -341,3 +341,3 @@ width++; | ||
if (next === 61) return this.finishOp(_tokentype.types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2); | ||
if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { | ||
if (code === 61 && next === 62) { | ||
// '=>' | ||
@@ -391,3 +391,2 @@ this.pos += 2; | ||
// '`' | ||
if (this.options.ecmaVersion < 6) break; | ||
++this.pos; | ||
@@ -400,6 +399,4 @@ return this.finishToken(_tokentype.types.backQuote); | ||
if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number | ||
if (this.options.ecmaVersion >= 6) { | ||
if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number | ||
if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number | ||
} | ||
if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number | ||
if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number | ||
// Anything else beginning with a digit is an integer, octal | ||
@@ -506,4 +503,3 @@ // number, or float. | ||
if (mods) { | ||
var validFlags = /^[gmsiy]*$/; | ||
if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/; | ||
var validFlags = /^[gmsiyu]*$/; | ||
if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag"); | ||
@@ -608,3 +604,2 @@ if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) { | ||
if (ch === 123) { | ||
if (this.options.ecmaVersion < 6) this.unexpected(); | ||
var codePos = ++this.pos; | ||
@@ -773,6 +768,5 @@ code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos); | ||
chunkStart = this.pos; | ||
var astral = this.options.ecmaVersion >= 6; | ||
while (this.pos < this.input.length) { | ||
var ch = this.fullCharCodeAtPos(); | ||
if (_identifier.isIdentifierChar(ch, astral)) { | ||
if (_identifier.isIdentifierChar(ch, true)) { | ||
this.pos += ch <= 0xffff ? 1 : 2; | ||
@@ -793,3 +787,3 @@ } else if (ch === 92) { | ||
var esc = this.readCodePoint(); | ||
if (!(first ? _identifier.isIdentifierStart : _identifier.isIdentifierChar)(esc, astral)) { | ||
if (!(first ? _identifier.isIdentifierStart : _identifier.isIdentifierChar)(esc, true)) { | ||
this.raise(escStart, "Invalid Unicode escape"); | ||
@@ -814,4 +808,4 @@ } | ||
var type = _tokentype.types.name; | ||
if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = _tokentype.keywords[word]; | ||
if (!containsEsc && this.isKeyword(word)) type = _tokentype.keywords[word]; | ||
return this.finishToken(type, word); | ||
}; |
{ | ||
"name": "babylon", | ||
"version": "5.7.1", | ||
"version": "5.7.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171008
4482