add support for es7 object/spread and move acorn-6to5 tests to a separate file
This commit is contained in:
parent
9b38a4826b
commit
25c45a1e8e
@ -1,3 +1,8 @@
|
||||
# acorn-6to5
|
||||
|
||||
Based on [acorn-jsx](https://github.com/RReverser/acorn-jsx).
|
||||
Deviates from [acorn](https://github.com/marijnh/acorn) in the following ways:
|
||||
|
||||
* JSX support via [acorn-jsx](https://github.com/RReverser/acorn-jsx)
|
||||
* [ES7 Abstract references](https://github.com/zenparsing/es-abstract-refs)
|
||||
* [ES7 Async/await](https://github.com/lukehoban/ecmascript-asyncawait)
|
||||
* [ES7 Object Rest/Spread](https://github.com/sebmarkbage/ecmascript-rest-spread)
|
||||
|
||||
17
acorn.js
17
acorn.js
@ -1757,7 +1757,7 @@
|
||||
node.type = "ObjectPattern";
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
var prop = node.properties[i];
|
||||
if (prop.kind !== "init") unexpected(prop.key.start);
|
||||
if (prop.type === "Property" && prop.kind !== "init") unexpected(prop.key.start);
|
||||
toAssignable(prop.value, false, checkType);
|
||||
}
|
||||
break;
|
||||
@ -1865,8 +1865,11 @@
|
||||
if (!isBinding) break;
|
||||
|
||||
case "ObjectPattern":
|
||||
for (var i = 0; i < expr.properties.length; i++)
|
||||
checkLVal(expr.properties[i].value, isBinding);
|
||||
for (var i = 0; i < expr.properties.length; i++) {
|
||||
var prop = expr.properties[i];
|
||||
if (prop.type === "Property") prop = prop.value;
|
||||
checkLVal(prop, isBinding);
|
||||
}
|
||||
break;
|
||||
|
||||
case "ArrayPattern":
|
||||
@ -1876,6 +1879,7 @@
|
||||
}
|
||||
break;
|
||||
|
||||
case "SpreadProperty":
|
||||
case "SpreadElement":
|
||||
case "VirtualPropertyExpression":
|
||||
break;
|
||||
@ -2644,6 +2648,13 @@
|
||||
prop.shorthand = false;
|
||||
isGenerator = eat(_star);
|
||||
}
|
||||
if (options.ecmaVersion >= 7 && tokType === _ellipsis) {
|
||||
if (isAsync || isGenerator) unexpected();
|
||||
prop = parseMaybeUnary();
|
||||
prop.type = "SpreadProperty";
|
||||
node.properties.push(prop);
|
||||
continue;
|
||||
}
|
||||
parsePropertyName(prop);
|
||||
if (eat(_colon)) {
|
||||
prop.value = parseExpression(true);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "acorn-6to5",
|
||||
"description": "Acorn fork used by 6to5",
|
||||
"main": "acorn.js",
|
||||
"version": "0.9.1-4",
|
||||
"version": "0.9.1-5",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Marijn Haverbeke",
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
require("./tests.js");
|
||||
require("./tests-harmony.js");
|
||||
require("./tests-jsx.js");
|
||||
require("./tests-6to5.js");
|
||||
} else {
|
||||
driver = window;
|
||||
}
|
||||
|
||||
1591
test/tests-6to5.js
Normal file
1591
test/tests-6to5.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user