Skip to content

Instantly share code, notes, and snippets.

@erincandescent
Created December 6, 2014 16:29
Show Gist options
  • Save erincandescent/901c3292bc8cf253d153 to your computer and use it in GitHub Desktop.
Save erincandescent/901c3292bc8cf253d153 to your computer and use it in GitHub Desktop.
Local<CallExpression> Parser::parseFunctionCall(Handle<Expression> func)
{
LocalScope<3> ls;
Local<CallExpression> call(new CallExpression(func));
consume(Token::OpenParen);
for (;;) {
ls.resetPreserving(&call);
Local<Expression> param;
if (!(param = parseExpression(operatorPrecedence(Token::Comma) + 1)))
break;
call->m_parameters.push_back(param.get());
if (token().type == Token::Comma) {
consume();
} else if(token().type == Token::CloseParen) {
break;
} else {
error("Expected comma or closing parentheses");
}
}
if (token().type == Token::Multiply) {
Local<Expression> param;
// Unpack
consume();
if (!(param = parseExpression())) {
error("Expected unpack asterisk to be followed by expression");
}
call->m_listPack = param.get();
}
consume(Token::CloseParen);
return ls.ret<CallExpression>(call);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment