Conflicts:
	acorn.js
This commit is contained in:
Sebastian McKenzie 2014-12-10 15:24:36 +11:00
commit 7dbddd566c
5 changed files with 9854 additions and 8523 deletions

View File

@ -852,25 +852,18 @@
function getTemplateToken(code) {
// '`' and '${' have special meanings, but they should follow
// string (can be empty)
if (tokType === _string) {
if (code === 96) { // '`'
++tokPos;
return finishToken(_bquote);
} else
if (code === 36 && input.charCodeAt(tokPos + 1) === 123) { // '${'
tokPos += 2;
return finishToken(_dollarBraceL);
}
if (tokType === _string) {
if (code === 96) { // '`'
++tokPos;
return finishToken(_bquote);
} else if (code === 36 && input.charCodeAt(tokPos + 1) === 123) { // '${'
tokPos += 2;
return finishToken(_dollarBraceL);
}
if (code === 125) { // '}'
++tokPos;
return finishToken(_braceR, undefined, false);
}
// anything else is considered string literal
// anything else is considered string literal
return readTmplString();
}
}
function getTokenFromCode(code) {
switch(code) {
@ -2687,10 +2680,11 @@
// Parse template expression.
function parseTemplate() {
var oldInTemplate = inTemplate;
inTemplate = true;
var node = startNode();
node.expressions = [];
node.quasis = [];
inTemplate = true;
next();
for (;;) {
var elem = startNode();
@ -2710,7 +2704,7 @@
tokPos = tokEnd;
expect(_braceR);
}
inTemplate = false;
inTemplate = oldInTemplate;
next();
return finishNode(node, "TemplateLiteral");
}
@ -3104,9 +3098,6 @@
if (tokType !== _name || tokVal !== "from") unexpected();
next();
node.source = tokType === _string ? parseExprAtom() : unexpected();
// only for backward compatibility with Esprima's AST
// (it doesn't support mixed default + named yet)
node.kind = node.specifiers[0]['default'] ? "default" : "named";
}
semicolon();
return finishNode(node, "ImportDeclaration");
@ -3116,16 +3107,6 @@
function parseImportSpecifiers() {
var nodes = [], first = true;
if (tokType === _star) {
var node = startNode();
next();
if (tokType !== _name || tokVal !== "as") unexpected();
next();
node.name = parseIdent();
checkLVal(node.name, true);
nodes.push(finishNode(node, "ImportBatchSpecifier"));
return nodes;
}
if (tokType === _name) {
// import defaultObj, { x, y as z } from '...'
var node = startNode();
@ -3136,6 +3117,16 @@
nodes.push(finishNode(node, "ImportSpecifier"));
if (!eat(_comma)) return nodes;
}
if (tokType === _star) {
var node = startNode();
next();
if (tokType !== _name || tokVal !== "as") unexpected();
next();
node.name = parseIdent();
checkLVal(node.name, true);
nodes.push(finishNode(node, "ImportBatchSpecifier"));
return nodes;
}
expect(_braceL);
while (!eat(_braceR)) {
if (!first) {

View File

@ -1,6 +1,6 @@
# Combine existing list of authors with everyone known in git, sort, add header.
tail --lines=+3 AUTHORS > AUTHORS.tmp
git log --format='%aN' | grep -v abraidwood >> AUTHORS.tmp
echo "List of Acorn contributors. Updated before every release.\n" > AUTHORS
echo -e "List of Acorn contributors. Updated before every release.\n" > AUTHORS
sort -u AUTHORS.tmp >> AUTHORS
rm -f AUTHORS.tmp

View File

@ -18,7 +18,7 @@
<h1>Acorn/Esprima/Traceur speed comparison</h1>
<p>This will run each of the three ES6 parsers on the source code of
jQuery 1.6.4 and CodeMirror 3.0b1 for five seconds, and show a table
jQuery 1.11.1 and CodeMirror 3.0b1 for five seconds, and show a table
indicating the number of lines parsed per second. Note that Traceur
always stores location data, and is thus not fairly compared by the
benchmark <em>without</em> location data.<p>
@ -49,17 +49,17 @@ numbers.</p>
parser.parseScript();
}
var totalLines = codemirror30.split("\n").length + jquery164.split("\n").length;
var totalLines = codemirror30.split("\n").length + jquery111.split("\n").length;
var nowHost = (typeof performance === 'object' && 'now' in performance) ? performance : Date;
function benchmark(runner, locations) {
// Give it a chance to warm up (first runs are usually outliers)
runner(jquery164, locations);
runner(jquery111, locations);
runner(codemirror30, locations);
var t0 = nowHost.now(), t1, lines = 0;
for (;;) {
runner(jquery164, locations);
runner(jquery111, locations);
runner(codemirror30, locations);
lines += totalLines;
t1 = nowHost.now();

18242
test/jquery-string.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -14160,3 +14160,75 @@ test("(for (x of array) for (y of array2) if (x === test) x)", {
}
}]
}, {ecmaVersion: 7, preserveParens: true});
// https://github.com/marijnh/acorn/issues/161
test("import foo, * as bar from 'baz';", {
type: "Program",
body: [{
type: "ImportDeclaration",
specifiers: [
{
type: "ImportSpecifier",
id: {
type: "Identifier",
name: "foo"
},
name: null,
default: true
},
{
type: "ImportBatchSpecifier",
name: {
type: "Identifier",
name: "bar"
}
}
],
source: {
type: "Literal",
value: "baz",
raw: "'baz'"
}
}]
}, {ecmaVersion: 6});
// https://github.com/marijnh/acorn/issues/173
test("`{${x}}`, `}`", {
type: "Program",
body: [{
type: "ExpressionStatement",
expression: {
type: "SequenceExpression",
expressions: [
{
type: "TemplateLiteral",
expressions: [{
type: "Identifier",
name: "x"
}],
quasis: [
{
type: "TemplateElement",
value: {cooked: "{", raw: "{"},
tail: false
},
{
type: "TemplateElement",
value: {cooked: "}", raw: "}"},
tail: true
}
]
},
{
type: "TemplateLiteral",
expressions: [],
quasis: [{
type: "TemplateElement",
value: {cooked: "}", raw: "}"},
tail: true
}]
}
]
}
}]
}, {ecmaVersion: 6});