aboutsummaryrefslogtreecommitdiff
path: root/node_modules/acorn
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/acorn
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
downloadwallet-core-0469abd4a9c9270a1fdc962969e36e63699af8b4.tar.xz
upgrade dependencies
Diffstat (limited to 'node_modules/acorn')
-rw-r--r--node_modules/acorn/.npmignore11
-rw-r--r--node_modules/acorn/AUTHORS1
-rw-r--r--node_modules/acorn/CHANGELOG.md32
-rw-r--r--node_modules/acorn/README.md4
-rwxr-xr-xnode_modules/acorn/bin/acorn2
-rw-r--r--node_modules/acorn/dist/acorn.es.js152
-rw-r--r--node_modules/acorn/dist/acorn.js152
-rw-r--r--node_modules/acorn/dist/acorn_loose.es.js16
-rw-r--r--node_modules/acorn/dist/acorn_loose.js16
-rw-r--r--node_modules/acorn/dist/walk.es.js4
-rw-r--r--node_modules/acorn/dist/walk.js4
-rw-r--r--node_modules/acorn/package.json2
12 files changed, 253 insertions, 143 deletions
diff --git a/node_modules/acorn/.npmignore b/node_modules/acorn/.npmignore
deleted file mode 100644
index 243d17d19..000000000
--- a/node_modules/acorn/.npmignore
+++ /dev/null
@@ -1,11 +0,0 @@
-/.tern-port
-/test
-/local
-/rollup
-/bin/generate-identifier-regex.js
-/bin/update_authors.sh
-.editorconfig
-.gitattributes
-.tern-project
-.travis.yml
-/src
diff --git a/node_modules/acorn/AUTHORS b/node_modules/acorn/AUTHORS
index 7b9f6a14b..78437f610 100644
--- a/node_modules/acorn/AUTHORS
+++ b/node_modules/acorn/AUTHORS
@@ -59,6 +59,7 @@ r-e-d
Richard Gibson
Rich Harris
Sebastian McKenzie
+Shahar Soel
Simen Bekkhus
Teddy Katz
Timothy Gu
diff --git a/node_modules/acorn/CHANGELOG.md b/node_modules/acorn/CHANGELOG.md
index 34d1ac780..3003a04a9 100644
--- a/node_modules/acorn/CHANGELOG.md
+++ b/node_modules/acorn/CHANGELOG.md
@@ -1,3 +1,35 @@
+## 5.2.1 (2017-10-30)
+
+### Bug fixes
+
+Fix a token context corruption bug.
+
+## 5.2.0 (2017-10-30)
+
+### Bug fixes
+
+Fix token context tracking for `class` and `function` in property-name position.
+
+Make sure `%*` isn't parsed as a valid operator.
+
+The `full` and `fullAncestor` walkers no longer visit nodes multiple times.
+
+Allow shorthand properties `get` and `set` to be followed by default values.
+
+Disallow `super` when not in callee or object position.
+
+### New features
+
+Support [`directive` property](https://github.com/estree/estree/compare/b3de58c9997504d6fba04b72f76e6dd1619ee4eb...1da8e603237144f44710360f8feb7a9977e905e0) on directive expression statements.
+
+## 5.1.2 (2017-09-04)
+
+### Bug fixes
+
+Disable parsing of legacy HTML-style comments in modules.
+
+Fix parsing of async methods whose names are keywords.
+
## 5.1.1 (2017-07-06)
### Bug fixes
diff --git a/node_modules/acorn/README.md b/node_modules/acorn/README.md
index bd853c43b..ab2c12ea5 100644
--- a/node_modules/acorn/README.md
+++ b/node_modules/acorn/README.md
@@ -351,8 +351,8 @@ The `bin/acorn` utility can be used to parse a file from the command
line. It accepts as arguments its input file and the following
options:
-- `--ecma3|--ecma5|--ecma6|--ecma7`: Sets the ECMAScript version to parse. Default is
- version 5.
+- `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9`: Sets the ECMAScript version
+ to parse. Default is version 7.
- `--module`: Sets the parsing mode to `"module"`. Is set to `"script"` otherwise.
diff --git a/node_modules/acorn/bin/acorn b/node_modules/acorn/bin/acorn
index 257195780..830c38964 100755
--- a/node_modules/acorn/bin/acorn
+++ b/node_modules/acorn/bin/acorn
@@ -14,7 +14,7 @@ var options = {};
function help(status) {
var print = (status == 0) ? console.log : console.error;
- print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]");
+ print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]");
print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]");
process.exit(status);
}
diff --git a/node_modules/acorn/dist/acorn.es.js b/node_modules/acorn/dist/acorn.es.js
index 5b5977671..d7289102c 100644
--- a/node_modules/acorn/dist/acorn.es.js
+++ b/node_modules/acorn/dist/acorn.es.js
@@ -183,15 +183,15 @@ var types = {
eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
- prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}),
+ prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
logicalOR: binop("||", 1),
logicalAND: binop("&&", 2),
bitwiseOR: binop("|", 3),
bitwiseXOR: binop("^", 4),
bitwiseAND: binop("&", 5),
- equality: binop("==/!=", 6),
- relational: binop("</>", 7),
- bitShift: binop("<</>>", 8),
+ equality: binop("==/!=/===/!==", 6),
+ relational: binop("</>/<=/>=", 7),
+ bitShift: binop("<</>>/>>>", 8),
plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
modulo: binop("%", 10),
star: binop("*", 10),
@@ -541,7 +541,7 @@ var pp = Parser.prototype;
// ## Parser utilities
-var literal = /^(?:'((?:[^']|\.)*)'|"((?:[^"]|\.)*)"|;)/;
+var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;
pp.strictDirective = function(start) {
var this$1 = this;
@@ -684,6 +684,7 @@ pp$1.parseTopLevel = function(node) {
var stmt = this$1.parseStatement(true, true, exports);
node.body.push(stmt);
}
+ this.adaptDirectivePrologue(node.body);
this.next();
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType;
@@ -1464,6 +1465,22 @@ pp$1.parseImportSpecifiers = function() {
return nodes
};
+// Set `ExpressionStatement#directive` property for directive prologues.
+pp$1.adaptDirectivePrologue = function(statements) {
+ for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
+ statements[i].directive = statements[i].expression.raw.slice(1, -1);
+ }
+};
+pp$1.isDirectiveCandidate = function(statement) {
+ return (
+ statement.type === "ExpressionStatement" &&
+ statement.expression.type === "Literal" &&
+ typeof statement.expression.value === "string" &&
+ // Reject parenthesized strings.
+ (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
+ )
+};
+
var pp$2 = Parser.prototype;
// Convert existing expression atom to assignable pattern
@@ -1578,23 +1595,19 @@ pp$2.parseRestBinding = function() {
// Parses lvalue (assignable) atom.
pp$2.parseBindingAtom = function() {
- if (this.options.ecmaVersion < 6) { return this.parseIdent() }
- switch (this.type) {
- case types.name:
- return this.parseIdent()
-
- case types.bracketL:
- var node = this.startNode();
- this.next();
- node.elements = this.parseBindingList(types.bracketR, true, true);
- return this.finishNode(node, "ArrayPattern")
-
- case types.braceL:
- return this.parseObj(true)
+ if (this.options.ecmaVersion >= 6) {
+ switch (this.type) {
+ case types.bracketL:
+ var node = this.startNode();
+ this.next();
+ node.elements = this.parseBindingList(types.bracketR, true, true);
+ return this.finishNode(node, "ArrayPattern")
- default:
- this.unexpected();
+ case types.braceL:
+ return this.parseObj(true)
+ }
}
+ return this.parseIdent()
};
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
@@ -1907,7 +1920,7 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
var startPos = this.start, startLoc = this.startLoc, expr;
if (this.inAsync && this.isContextual("await")) {
- expr = this.parseAwait(refDestructuringErrors);
+ expr = this.parseAwait();
sawUnary = true;
} else if (this.type.prefix) {
var node = this.startNode(), update = this.type === types.incDec;
@@ -2011,12 +2024,22 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
case types._super:
if (!this.inFunction)
{ this.raise(this.start, "'super' outside of function or class"); }
+ node = this.startNode();
+ this.next();
+ // The `super` keyword can appear at below:
+ // SuperProperty:
+ // super [ Expression ]
+ // super . IdentifierName
+ // SuperCall:
+ // super Arguments
+ if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
+ { this.unexpected(); }
+ return this.finishNode(node, "Super")
case types._this:
- var type = this.type === types._this ? "ThisExpression" : "Super";
node = this.startNode();
this.next();
- return this.finishNode(node, type)
+ return this.finishNode(node, "ThisExpression")
case types.name:
var startPos = this.start, startLoc = this.startLoc;
@@ -2251,14 +2274,14 @@ pp$3.parseTemplate = function(ref) {
return this.finishNode(node, "TemplateLiteral")
};
-// Parse an object literal or binding pattern.
-
pp$3.isAsyncProp = function(prop) {
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
- (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL) &&
+ (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword) &&
!lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
};
+// Parse an object literal or binding pattern.
+
pp$3.parseObj = function(isPattern, refDestructuringErrors) {
var this$1 = this;
@@ -2271,31 +2294,36 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
if (this$1.afterTrailingComma(types.braceR)) { break }
} else { first = false; }
- var prop = this$1.startNode(), isGenerator = (void 0), isAsync = (void 0), startPos = (void 0), startLoc = (void 0);
- if (this$1.options.ecmaVersion >= 6) {
- prop.method = false;
- prop.shorthand = false;
- if (isPattern || refDestructuringErrors) {
- startPos = this$1.start;
- startLoc = this$1.startLoc;
- }
- if (!isPattern)
- { isGenerator = this$1.eat(types.star); }
- }
- this$1.parsePropertyName(prop);
- if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && this$1.isAsyncProp(prop)) {
- isAsync = true;
- this$1.parsePropertyName(prop, refDestructuringErrors);
- } else {
- isAsync = false;
- }
- this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors);
+ var prop = this$1.parseProperty(isPattern, refDestructuringErrors);
this$1.checkPropClash(prop, propHash);
- node.properties.push(this$1.finishNode(prop, "Property"));
+ node.properties.push(prop);
}
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
};
+pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
+ var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
+ if (this.options.ecmaVersion >= 6) {
+ prop.method = false;
+ prop.shorthand = false;
+ if (isPattern || refDestructuringErrors) {
+ startPos = this.start;
+ startLoc = this.startLoc;
+ }
+ if (!isPattern)
+ { isGenerator = this.eat(types.star); }
+ }
+ this.parsePropertyName(prop);
+ if (!isPattern && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
+ isAsync = true;
+ this.parsePropertyName(prop, refDestructuringErrors);
+ } else {
+ isAsync = false;
+ }
+ this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors);
+ return this.finishNode(prop, "Property")
+};
+
pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) {
if ((isGenerator || isAsync) && this.type === types.colon)
{ this.unexpected(); }
@@ -2308,10 +2336,11 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
prop.kind = "init";
prop.method = true;
prop.value = this.parseMethod(isGenerator, isAsync);
- } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
+ } else if (!isPattern &&
+ this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set") &&
(this.type != types.comma && this.type != types.braceR)) {
- if (isGenerator || isAsync || isPattern) { this.unexpected(); }
+ if (isGenerator || isAsync) { this.unexpected(); }
prop.kind = prop.key.name;
this.parsePropertyName(prop);
prop.value = this.parseMethod(false);
@@ -2459,6 +2488,7 @@ pp$3.parseFunctionBody = function(node, isArrowFunction) {
this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params));
node.body = this.parseBlock(false);
node.expression = false;
+ this.adaptDirectivePrologue(node.body.body);
this.labels = oldLabels;
}
this.exitFunctionScope();
@@ -2526,10 +2556,6 @@ pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestruct
return elts
};
-// Parse the next token as an identifier. If `liberal` is true (used
-// when parsing properties), it will also convert keywords into
-// identifiers.
-
pp$3.checkUnreserved = function(ref) {
var start = ref.start;
var end = ref.end;
@@ -2548,6 +2574,10 @@ pp$3.checkUnreserved = function(ref) {
{ this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); }
};
+// Parse the next token as an identifier. If `liberal` is true (used
+// when parsing properties), it will also convert keywords into
+// identifiers.
+
pp$3.parseIdent = function(liberal, isBinding) {
var node = this.startNode();
if (liberal && this.options.allowReserved == "never") { liberal = false; }
@@ -2555,6 +2585,15 @@ pp$3.parseIdent = function(liberal, isBinding) {
node.name = this.value;
} else if (this.type.keyword) {
node.name = this.type.keyword;
+
+ // To fix https://github.com/ternjs/acorn/issues/575
+ // `class` and `function` keywords push new context into this.context.
+ // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
+ // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
+ if ((node.name === "class" || node.name === "function") &&
+ (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
+ this.context.pop();
+ }
} else {
this.unexpected();
}
@@ -3105,7 +3144,7 @@ pp$8.readToken_mult_modulo_exp = function(code) { // '%*'
var tokentype = code === 42 ? types.star : types.modulo;
// exponentiation operator ** and **=
- if (this.options.ecmaVersion >= 7 && next === 42) {
+ if (this.options.ecmaVersion >= 7 && code == 42 && next === 42) {
++size;
tokentype = types.starstar;
next = this.input.charCodeAt(this.pos + 2);
@@ -3131,7 +3170,7 @@ pp$8.readToken_caret = function() { // '^'
pp$8.readToken_plus_min = function(code) { // '+-'
var next = this.input.charCodeAt(this.pos + 1);
if (next === code) {
- if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
+ if (next == 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 62 &&
(this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
// A `-->` line comment
this.skipLineComment(3);
@@ -3152,9 +3191,8 @@ pp$8.readToken_lt_gt = function(code) { // '<>'
if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
return this.finishOp(types.bitShift, size)
}
- if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&
+ if (next == 33 && code == 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 45 &&
this.input.charCodeAt(this.pos + 3) == 45) {
- if (this.inModule) { this.unexpected(); }
// `<!--`, an XML-style comment that should be interpreted as a line comment
this.skipLineComment(4);
this.skipSpace();
@@ -3651,7 +3689,7 @@ pp$8.readWord = function() {
// [dammit]: acorn_loose.js
// [walk]: util/walk.js
-var version = "5.1.1";
+var version = "5.2.1";
// The main exported interface (under `self.acorn` when in the
// browser) is a `parse` function that takes a code string and
diff --git a/node_modules/acorn/dist/acorn.js b/node_modules/acorn/dist/acorn.js
index 9ddd332e5..4f0dd5d21 100644
--- a/node_modules/acorn/dist/acorn.js
+++ b/node_modules/acorn/dist/acorn.js
@@ -189,15 +189,15 @@ var types = {
eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
- prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}),
+ prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
logicalOR: binop("||", 1),
logicalAND: binop("&&", 2),
bitwiseOR: binop("|", 3),
bitwiseXOR: binop("^", 4),
bitwiseAND: binop("&", 5),
- equality: binop("==/!=", 6),
- relational: binop("</>", 7),
- bitShift: binop("<</>>", 8),
+ equality: binop("==/!=/===/!==", 6),
+ relational: binop("</>/<=/>=", 7),
+ bitShift: binop("<</>>/>>>", 8),
plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
modulo: binop("%", 10),
star: binop("*", 10),
@@ -547,7 +547,7 @@ var pp = Parser.prototype;
// ## Parser utilities
-var literal = /^(?:'((?:[^']|\.)*)'|"((?:[^"]|\.)*)"|;)/;
+var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;
pp.strictDirective = function(start) {
var this$1 = this;
@@ -690,6 +690,7 @@ pp$1.parseTopLevel = function(node) {
var stmt = this$1.parseStatement(true, true, exports);
node.body.push(stmt);
}
+ this.adaptDirectivePrologue(node.body);
this.next();
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType;
@@ -1470,6 +1471,22 @@ pp$1.parseImportSpecifiers = function() {
return nodes
};
+// Set `ExpressionStatement#directive` property for directive prologues.
+pp$1.adaptDirectivePrologue = function(statements) {
+ for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
+ statements[i].directive = statements[i].expression.raw.slice(1, -1);
+ }
+};
+pp$1.isDirectiveCandidate = function(statement) {
+ return (
+ statement.type === "ExpressionStatement" &&
+ statement.expression.type === "Literal" &&
+ typeof statement.expression.value === "string" &&
+ // Reject parenthesized strings.
+ (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
+ )
+};
+
var pp$2 = Parser.prototype;
// Convert existing expression atom to assignable pattern
@@ -1584,23 +1601,19 @@ pp$2.parseRestBinding = function() {
// Parses lvalue (assignable) atom.
pp$2.parseBindingAtom = function() {
- if (this.options.ecmaVersion < 6) { return this.parseIdent() }
- switch (this.type) {
- case types.name:
- return this.parseIdent()
-
- case types.bracketL:
- var node = this.startNode();
- this.next();
- node.elements = this.parseBindingList(types.bracketR, true, true);
- return this.finishNode(node, "ArrayPattern")
-
- case types.braceL:
- return this.parseObj(true)
+ if (this.options.ecmaVersion >= 6) {
+ switch (this.type) {
+ case types.bracketL:
+ var node = this.startNode();
+ this.next();
+ node.elements = this.parseBindingList(types.bracketR, true, true);
+ return this.finishNode(node, "ArrayPattern")
- default:
- this.unexpected();
+ case types.braceL:
+ return this.parseObj(true)
+ }
}
+ return this.parseIdent()
};
pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
@@ -1913,7 +1926,7 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
var startPos = this.start, startLoc = this.startLoc, expr;
if (this.inAsync && this.isContextual("await")) {
- expr = this.parseAwait(refDestructuringErrors);
+ expr = this.parseAwait();
sawUnary = true;
} else if (this.type.prefix) {
var node = this.startNode(), update = this.type === types.incDec;
@@ -2017,12 +2030,22 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
case types._super:
if (!this.inFunction)
{ this.raise(this.start, "'super' outside of function or class"); }
+ node = this.startNode();
+ this.next();
+ // The `super` keyword can appear at below:
+ // SuperProperty:
+ // super [ Expression ]
+ // super . IdentifierName
+ // SuperCall:
+ // super Arguments
+ if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
+ { this.unexpected(); }
+ return this.finishNode(node, "Super")
case types._this:
- var type = this.type === types._this ? "ThisExpression" : "Super";
node = this.startNode();
this.next();
- return this.finishNode(node, type)
+ return this.finishNode(node, "ThisExpression")
case types.name:
var startPos = this.start, startLoc = this.startLoc;
@@ -2257,14 +2280,14 @@ pp$3.parseTemplate = function(ref) {
return this.finishNode(node, "TemplateLiteral")
};
-// Parse an object literal or binding pattern.
-
pp$3.isAsyncProp = function(prop) {
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
- (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL) &&
+ (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword) &&
!lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
};
+// Parse an object literal or binding pattern.
+
pp$3.parseObj = function(isPattern, refDestructuringErrors) {
var this$1 = this;
@@ -2277,31 +2300,36 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
if (this$1.afterTrailingComma(types.braceR)) { break }
} else { first = false; }
- var prop = this$1.startNode(), isGenerator = (void 0), isAsync = (void 0), startPos = (void 0), startLoc = (void 0);
- if (this$1.options.ecmaVersion >= 6) {
- prop.method = false;
- prop.shorthand = false;
- if (isPattern || refDestructuringErrors) {
- startPos = this$1.start;
- startLoc = this$1.startLoc;
- }
- if (!isPattern)
- { isGenerator = this$1.eat(types.star); }
- }
- this$1.parsePropertyName(prop);
- if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && this$1.isAsyncProp(prop)) {
- isAsync = true;
- this$1.parsePropertyName(prop, refDestructuringErrors);
- } else {
- isAsync = false;
- }
- this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors);
+ var prop = this$1.parseProperty(isPattern, refDestructuringErrors);
this$1.checkPropClash(prop, propHash);
- node.properties.push(this$1.finishNode(prop, "Property"));
+ node.properties.push(prop);
}
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
};
+pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
+ var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
+ if (this.options.ecmaVersion >= 6) {
+ prop.method = false;
+ prop.shorthand = false;
+ if (isPattern || refDestructuringErrors) {
+ startPos = this.start;
+ startLoc = this.startLoc;
+ }
+ if (!isPattern)
+ { isGenerator = this.eat(types.star); }
+ }
+ this.parsePropertyName(prop);
+ if (!isPattern && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
+ isAsync = true;
+ this.parsePropertyName(prop, refDestructuringErrors);
+ } else {
+ isAsync = false;
+ }
+ this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors);
+ return this.finishNode(prop, "Property")
+};
+
pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) {
if ((isGenerator || isAsync) && this.type === types.colon)
{ this.unexpected(); }
@@ -2314,10 +2342,11 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
prop.kind = "init";
prop.method = true;
prop.value = this.parseMethod(isGenerator, isAsync);
- } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
+ } else if (!isPattern &&
+ this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set") &&
(this.type != types.comma && this.type != types.braceR)) {
- if (isGenerator || isAsync || isPattern) { this.unexpected(); }
+ if (isGenerator || isAsync) { this.unexpected(); }
prop.kind = prop.key.name;
this.parsePropertyName(prop);
prop.value = this.parseMethod(false);
@@ -2465,6 +2494,7 @@ pp$3.parseFunctionBody = function(node, isArrowFunction) {
this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params));
node.body = this.parseBlock(false);
node.expression = false;
+ this.adaptDirectivePrologue(node.body.body);
this.labels = oldLabels;
}
this.exitFunctionScope();
@@ -2532,10 +2562,6 @@ pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestruct
return elts
};
-// Parse the next token as an identifier. If `liberal` is true (used
-// when parsing properties), it will also convert keywords into
-// identifiers.
-
pp$3.checkUnreserved = function(ref) {
var start = ref.start;
var end = ref.end;
@@ -2554,6 +2580,10 @@ pp$3.checkUnreserved = function(ref) {
{ this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); }
};
+// Parse the next token as an identifier. If `liberal` is true (used
+// when parsing properties), it will also convert keywords into
+// identifiers.
+
pp$3.parseIdent = function(liberal, isBinding) {
var node = this.startNode();
if (liberal && this.options.allowReserved == "never") { liberal = false; }
@@ -2561,6 +2591,15 @@ pp$3.parseIdent = function(liberal, isBinding) {
node.name = this.value;
} else if (this.type.keyword) {
node.name = this.type.keyword;
+
+ // To fix https://github.com/ternjs/acorn/issues/575
+ // `class` and `function` keywords push new context into this.context.
+ // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
+ // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
+ if ((node.name === "class" || node.name === "function") &&
+ (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
+ this.context.pop();
+ }
} else {
this.unexpected();
}
@@ -3111,7 +3150,7 @@ pp$8.readToken_mult_modulo_exp = function(code) { // '%*'
var tokentype = code === 42 ? types.star : types.modulo;
// exponentiation operator ** and **=
- if (this.options.ecmaVersion >= 7 && next === 42) {
+ if (this.options.ecmaVersion >= 7 && code == 42 && next === 42) {
++size;
tokentype = types.starstar;
next = this.input.charCodeAt(this.pos + 2);
@@ -3137,7 +3176,7 @@ pp$8.readToken_caret = function() { // '^'
pp$8.readToken_plus_min = function(code) { // '+-'
var next = this.input.charCodeAt(this.pos + 1);
if (next === code) {
- if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
+ if (next == 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 62 &&
(this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
// A `-->` line comment
this.skipLineComment(3);
@@ -3158,9 +3197,8 @@ pp$8.readToken_lt_gt = function(code) { // '<>'
if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
return this.finishOp(types.bitShift, size)
}
- if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&
+ if (next == 33 && code == 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 45 &&
this.input.charCodeAt(this.pos + 3) == 45) {
- if (this.inModule) { this.unexpected(); }
// `<!--`, an XML-style comment that should be interpreted as a line comment
this.skipLineComment(4);
this.skipSpace();
@@ -3657,7 +3695,7 @@ pp$8.readWord = function() {
// [dammit]: acorn_loose.js
// [walk]: util/walk.js
-var version = "5.1.1";
+var version = "5.2.1";
// The main exported interface (under `self.acorn` when in the
// browser) is a `parse` function that takes a code string and
diff --git a/node_modules/acorn/dist/acorn_loose.es.js b/node_modules/acorn/dist/acorn_loose.es.js
index 449afc889..469f73a2f 100644
--- a/node_modules/acorn/dist/acorn_loose.es.js
+++ b/node_modules/acorn/dist/acorn_loose.es.js
@@ -300,6 +300,7 @@ lp$1.parseTopLevel = function() {
var node = this.startNodeAt(this.options.locations ? [0, getLineInfo(this.input, 0)] : 0);
node.body = [];
while (this.tok.type !== tokTypes.eof) { node.body.push(this$1.parseStatement()); }
+ this.toks.adaptDirectivePrologue(node.body);
this.last = this.tok;
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType;
@@ -630,6 +631,7 @@ lp$1.parseFunction = function(node, isStatement, isAsync) {
this.inAsync = node.async;
node.params = this.parseFunctionParams();
node.body = this.parseBlock();
+ this.toks.adaptDirectivePrologue(node.body.body);
this.inAsync = oldInAsync;
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
};
@@ -676,7 +678,6 @@ lp$1.parseImport = function() {
if (this.tok.type === tokTypes.string) {
node.specifiers = [];
node.source = this.parseExprAtom();
- node.kind = "";
} else {
var elt;
if (this.tok.type === tokTypes.name && this.tok.value !== "from") {
@@ -1150,7 +1151,7 @@ lp$2.parseObj = function() {
prop.value = this$1.parseMethod(isGenerator, isAsync);
} else if (this$1.options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
!prop.computed && (prop.key.name === "get" || prop.key.name === "set") &&
- (this$1.tok.type != tokTypes.comma && this$1.tok.type != tokTypes.braceR)) {
+ (this$1.tok.type != tokTypes.comma && this$1.tok.type != tokTypes.braceR && this$1.tok.type != tokTypes.eq)) {
prop.kind = prop.key.name;
this$1.parsePropertyName(prop);
prop.value = this$1.parseMethod(false);
@@ -1285,8 +1286,8 @@ lp$2.parseMethod = function(isGenerator, isAsync) {
{ node.async = !!isAsync; }
this.inAsync = node.async;
node.params = this.parseFunctionParams();
- node.expression = this.options.ecmaVersion >= 6 && this.tok.type !== tokTypes.braceL;
- node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock();
+ node.body = this.parseBlock();
+ this.toks.adaptDirectivePrologue(node.body.body);
this.inAsync = oldInAsync;
return this.finishNode(node, "FunctionExpression")
};
@@ -1299,7 +1300,12 @@ lp$2.parseArrowExpression = function(node, params, isAsync) {
this.inAsync = node.async;
node.params = this.toAssignableList(params, true);
node.expression = this.tok.type !== tokTypes.braceL;
- node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock();
+ if (node.expression) {
+ node.body = this.parseMaybeAssign();
+ } else {
+ node.body = this.parseBlock();
+ this.toks.adaptDirectivePrologue(node.body.body);
+ }
this.inAsync = oldInAsync;
return this.finishNode(node, "ArrowFunctionExpression")
};
diff --git a/node_modules/acorn/dist/acorn_loose.js b/node_modules/acorn/dist/acorn_loose.js
index ce8638b82..d6738db9d 100644
--- a/node_modules/acorn/dist/acorn_loose.js
+++ b/node_modules/acorn/dist/acorn_loose.js
@@ -304,6 +304,7 @@ lp$1.parseTopLevel = function() {
var node = this.startNodeAt(this.options.locations ? [0, __acorn.getLineInfo(this.input, 0)] : 0);
node.body = [];
while (this.tok.type !== __acorn.tokTypes.eof) { node.body.push(this$1.parseStatement()); }
+ this.toks.adaptDirectivePrologue(node.body);
this.last = this.tok;
if (this.options.ecmaVersion >= 6) {
node.sourceType = this.options.sourceType;
@@ -634,6 +635,7 @@ lp$1.parseFunction = function(node, isStatement, isAsync) {
this.inAsync = node.async;
node.params = this.parseFunctionParams();
node.body = this.parseBlock();
+ this.toks.adaptDirectivePrologue(node.body.body);
this.inAsync = oldInAsync;
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
};
@@ -680,7 +682,6 @@ lp$1.parseImport = function() {
if (this.tok.type === __acorn.tokTypes.string) {
node.specifiers = [];
node.source = this.parseExprAtom();
- node.kind = "";
} else {
var elt;
if (this.tok.type === __acorn.tokTypes.name && this.tok.value !== "from") {
@@ -1154,7 +1155,7 @@ lp$2.parseObj = function() {
prop.value = this$1.parseMethod(isGenerator, isAsync);
} else if (this$1.options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
!prop.computed && (prop.key.name === "get" || prop.key.name === "set") &&
- (this$1.tok.type != __acorn.tokTypes.comma && this$1.tok.type != __acorn.tokTypes.braceR)) {
+ (this$1.tok.type != __acorn.tokTypes.comma && this$1.tok.type != __acorn.tokTypes.braceR && this$1.tok.type != __acorn.tokTypes.eq)) {
prop.kind = prop.key.name;
this$1.parsePropertyName(prop);
prop.value = this$1.parseMethod(false);
@@ -1289,8 +1290,8 @@ lp$2.parseMethod = function(isGenerator, isAsync) {
{ node.async = !!isAsync; }
this.inAsync = node.async;
node.params = this.parseFunctionParams();
- node.expression = this.options.ecmaVersion >= 6 && this.tok.type !== __acorn.tokTypes.braceL;
- node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock();
+ node.body = this.parseBlock();
+ this.toks.adaptDirectivePrologue(node.body.body);
this.inAsync = oldInAsync;
return this.finishNode(node, "FunctionExpression")
};
@@ -1303,7 +1304,12 @@ lp$2.parseArrowExpression = function(node, params, isAsync) {
this.inAsync = node.async;
node.params = this.toAssignableList(params, true);
node.expression = this.tok.type !== __acorn.tokTypes.braceL;
- node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock();
+ if (node.expression) {
+ node.body = this.parseMaybeAssign();
+ } else {
+ node.body = this.parseBlock();
+ this.toks.adaptDirectivePrologue(node.body.body);
+ }
this.inAsync = oldInAsync;
return this.finishNode(node, "ArrowFunctionExpression")
};
diff --git a/node_modules/acorn/dist/walk.es.js b/node_modules/acorn/dist/walk.es.js
index 153534673..40356507d 100644
--- a/node_modules/acorn/dist/walk.es.js
+++ b/node_modules/acorn/dist/walk.es.js
@@ -68,7 +68,7 @@ function full(node, callback, base, state, override) {
; }(function c(node, st, override) {
var type = override || node.type;
base[type](node, st, c);
- callback(node, st, type);
+ if (!override) { callback(node, st, type); }
})(node, state, override);
}
@@ -81,7 +81,7 @@ function fullAncestor(node, callback, base, state) {
var isNew = node != ancestors[ancestors.length - 1];
if (isNew) { ancestors.push(node); }
base[type](node, st, c);
- callback(node, st || ancestors, ancestors, type);
+ if (!override) { callback(node, st || ancestors, ancestors, type); }
if (isNew) { ancestors.pop(); }
})(node, state);
}
diff --git a/node_modules/acorn/dist/walk.js b/node_modules/acorn/dist/walk.js
index d6aaa9a95..b4fb69405 100644
--- a/node_modules/acorn/dist/walk.js
+++ b/node_modules/acorn/dist/walk.js
@@ -74,7 +74,7 @@ function full(node, callback, base, state, override) {
; }(function c(node, st, override) {
var type = override || node.type;
base[type](node, st, c);
- callback(node, st, type);
+ if (!override) { callback(node, st, type); }
})(node, state, override);
}
@@ -87,7 +87,7 @@ function fullAncestor(node, callback, base, state) {
var isNew = node != ancestors[ancestors.length - 1];
if (isNew) { ancestors.push(node); }
base[type](node, st, c);
- callback(node, st || ancestors, ancestors, type);
+ if (!override) { callback(node, st || ancestors, ancestors, type); }
if (isNew) { ancestors.pop(); }
})(node, state);
}
diff --git a/node_modules/acorn/package.json b/node_modules/acorn/package.json
index 3d242e741..56c63a4a9 100644
--- a/node_modules/acorn/package.json
+++ b/node_modules/acorn/package.json
@@ -4,7 +4,7 @@
"homepage": "https://github.com/ternjs/acorn",
"main": "dist/acorn.js",
"module": "dist/acorn.es.js",
- "version": "5.1.1",
+ "version": "5.2.1",
"engines": {
"node": ">=0.4.0"
},