Skip to content

Instantly share code, notes, and snippets.

@disnet disnet/gist:8609245
Created Jan 24, 2014

Embed
What would you like to do?
let function = macro {
case { _ * $id ($args ...) { $body ... } } => {
var body = #{ $body ... };
var isAwaitGenerator = false;
for (var i = 0; i < body.length; i++) {
if (body[i].token.type === parser.Token.Identifier &&
body[i].token.value === 'await') {
var expr = getExpr(body.slice(i));
if (expr.success) {
isAwaitGenerator = true;
// just drop the token?
body.splice(i,1);
i--;
}
}
}
if (isAwaitGenerator) {
//PROBLEM: causes errors?
letstx $nbody ... = body;
return #{
function* $id ($args ...) { "is an await";
$nbody ...
}
}
}
}
}
var a = function*x(b) {
// PROBLEM: Expected to drop await token?
await +1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.