Skip to content

Instantly share code, notes, and snippets.

@disnet
Created January 24, 2014 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disnet/8609245 to your computer and use it in GitHub Desktop.
Save disnet/8609245 to your computer and use it in GitHub Desktop.
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