acorn-es7-plugin
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -5,6 +5,7 @@ var NotAsync = {} ; | ||
var atomOrPropertyOrLabel = /^\s*[:;]/ ; | ||
var asyncAtEndOfLine = /^async[\t ]*\n/ ; | ||
/* Create a new parser derived from the specified parser, so that in the | ||
* event of an error we can back out and try again */ | ||
function subParse(parser, how, pos, extensions) { | ||
function subParse(parser, pos, extensions) { | ||
var p = new parser.constructor(parser.options, parser.input, pos); | ||
@@ -20,3 +21,3 @@ if (extensions) | ||
p.nextToken(); | ||
return p[how](); | ||
return p; | ||
} | ||
@@ -72,3 +73,3 @@ | ||
if (r.type==='Identifier') { | ||
if (r.name==='async' && !/^async[\t ]*\n/.test(this.input.slice(start))) { | ||
if (r.name==='async' && !asyncAtEndOfLine.test(this.input.slice(start))) { | ||
// Is this really an async function? | ||
@@ -80,3 +81,4 @@ var isAsync = this.inAsyncFunction ; | ||
var inBody = false ; | ||
rhs = subParse(this,'parseExpression',this.start,{ | ||
var parseHooks = { | ||
parseFunctionBody:function(){ | ||
@@ -98,3 +100,5 @@ try { | ||
} | ||
}) ; | ||
} ; | ||
rhs = subParse(this,this.start,parseHooks).parseExpression() ; | ||
if (rhs.type==='SequenceExpression') | ||
@@ -137,5 +141,5 @@ rhs = rhs.expressions[0] ; | ||
var start = this.start ; | ||
rhs = subParse(this,'parseExprSubscripts',this.start-4) ; | ||
rhs = subParse(this,this.start-4).parseExprSubscripts() ; | ||
if (rhs.end<=start) { | ||
rhs = subParse(this,'parseExprSubscripts',this.start) ; | ||
rhs = subParse(this,this.start).parseExprSubscripts() ; | ||
n.operator = 'await' ; | ||
@@ -142,0 +146,0 @@ n.argument = rhs ; |
{ | ||
"name": "acorn-es7-plugin", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "A plugin for the Acorn parser that understands the ES7 keywords async and await", | ||
@@ -5,0 +5,0 @@ "main": "acorn-es7-plugin.js", |
9536
166