Expression* e;
if (saw_comma || !this->peek_token()->is_op(OPERATOR_CHANOP))
- e = this->expression(PRECEDENCE_NORMAL, true, true, NULL, NULL);
+ {
+ e = this->expression(PRECEDENCE_NORMAL, true, true, NULL, NULL);
+ if (e->receive_expression() != NULL)
+ {
+ *is_send = false;
+ *channel = e->receive_expression()->channel();
+ // This is 'case (<-c):'. We now expect ':'. If we see
+ // '<-', then we have case (<-c)<-v:
+ if (!this->peek_token()->is_op(OPERATOR_CHANOP))
+ return true;
+ }
+ }
else
{
// case <-c:
if (this->peek_token()->is_op(OPERATOR_EQ))
{
- if (!this->advance_token()->is_op(OPERATOR_CHANOP))
+ *is_send = false;
+ this->advance_token();
+ Location recvloc = this->location();
+ Expression* recvexpr = this->expression(PRECEDENCE_NORMAL, false,
+ true, NULL, NULL);
+ if (recvexpr->receive_expression() == NULL)
{
- go_error_at(this->location(), "missing %<<-%>");
+ go_error_at(recvloc, "missing %<<-%>");
return false;
}
- *is_send = false;
- this->advance_token();
- *channel = this->expression(PRECEDENCE_NORMAL, false, true, NULL, NULL);
+ *channel = recvexpr->receive_expression()->channel();
if (saw_comma)
{
// case v, e = <-c: