ariya/esprima — pull request #234 by benjamn (2014-03-27 01:51:32+00:00)
Title: Support async functions and the await keyword, pending standardization

Although the specification of `async` functions is not universally agreed upon yet, I thought I would implement what seems to be [the leading proposal](http://wiki.ecmascript.org/doku.php?id=strawman:async_functions), in an attempt to see if there are any difficulties involved in parsing the new syntax.

In other words, feedback is the primary goal of this pull request, and I do not expect it to be merged any time soon. I will keep rebasing it as long as anyone cares.

This pull request adds support for `async` function declarations, named and anonymous function expressions, and arrow function expressions.

The presence of the `async` keyword before a function causes the AST node for that function to contain the property `"async": true`. For backwards compatibility, the absence of an `async` keyword produces an AST node with no `"async"` property (rather than `"async": false`, which would also make sense but would require many more changes to existing tests).

I have also included support for both the standard `await` keyword and the undecided-upon `await*` keyword. For now, the `*` simply causes the `AwaitExpression` to contain the property `"all": true`, because the leading proposal seems to be that `await*` should be sugar for `Promise.all`. If a different consensus emerges, it will be easy to change the property name.

The `await` keyword is illegal outside of an `async` function, similar to `yield`, but (unlike `yield`) it is legal for an `async` function to contain no `await` expressions.