asyncgenerator icon indicating copy to clipboard operation
asyncgenerator copied to clipboard

Syntax

Open mnieper opened this issue 9 years ago • 7 comments

In the async generator examples, a syntax like

await yield f()

is used. However, this does not seem to be parseable by the ES6 grammar and https://github.com/lukehoban/ecmascript-asyncawait. await expects an UnaryExpression, while yield produces an AssignmentExpression.

mnieper avatar Feb 09 '15 09:02 mnieper

Good point. It would have to be

await (yield f())

zenparsing avatar Feb 13 '15 20:02 zenparsing

In the implementation in Traceur, I have added a parser rule for await yield without parens. I think this grammar change should be added to this or @lukehoban's proposal because await yield will be a common idiom with async generators in place.

mnieper avatar Feb 13 '15 20:02 mnieper

@mnieper What is the grammar rule you are proposing?

zenparsing avatar Feb 13 '15 20:02 zenparsing

I don't speak Ecma, but I wouldn't it suffice to say

UnaryExpression :
    ...
    await [Lexical goal InputElementRegExp] UnaryExpression
    await ... YieldExpression

?

mnieper avatar Feb 13 '15 20:02 mnieper

@mnieper Trying to clean up our parser a bit and the YieldExpression probably needs a [In] there to allow:

await yield 42 in obj

arv avatar May 01 '15 02:05 arv

Yes, this makes perfect sense.

mnieper avatar May 04 '15 11:05 mnieper

@mnieper want to file a bug here if you want this syntax in the async functions proposal?

bterlson avatar Jun 06 '15 17:06 bterlson