Parse port and chan types, constructors, send statements

This commit is contained in:
Brian Anderson 2011-03-02 22:29:53 -05:00 committed by Graydon Hoare
parent 45f7955261
commit 80e0ebaa86
2 changed files with 44 additions and 0 deletions

View File

@ -242,6 +242,9 @@ fn unop_to_str(unop op) -> str {
expr_be(@expr);
expr_log(@expr);
expr_check_expr(@expr);
expr_port(ann);
expr_chan(@expr, ann);
expr_send(@expr /* TODO: @expr|is_lval */, @expr, ann);
}
type lit = spanned[lit_];
@ -278,6 +281,8 @@ fn unop_to_str(unop op) -> str {
ty_rec(vec[ty_field]);
ty_fn(proto, vec[ty_arg], @ty); // TODO: effect
ty_obj(vec[ty_method]);
ty_chan(@ty);
ty_port(@ty);
ty_path(path, option.t[def]);
ty_mutable(@ty);
ty_type;

View File

@ -429,6 +429,22 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
t = parse_ty_obj(p, hi);
}
case (token.PORT) {
p.bump();
expect(p, token.LBRACKET);
t = ast.ty_port(parse_ty(p));
hi = p.get_span();
expect(p, token.RBRACKET);
}
case (token.CHAN) {
p.bump();
expect(p, token.LBRACKET);
t = ast.ty_chan(parse_ty(p));
hi = p.get_span();
expect(p, token.RBRACKET);
}
case (token.IDENT(_)) {
t = ast.ty_path(parse_path(p, GREEDY), none[ast.def]);
}
@ -799,6 +815,23 @@ fn is_ident(token.token t) -> bool {
}
}
case (token.PORT) {
p.bump();
expect(p, token.LPAREN);
expect(p, token.RPAREN);
hi = p.get_span();
ex = ast.expr_port(ast.ann_none);
}
case (token.CHAN) {
p.bump();
expect(p, token.LPAREN);
auto e = parse_expr(p);
hi = e.span;
expect(p, token.RPAREN);
ex = ast.expr_chan(e, ast.ann_none);
}
case (_) {
auto lit = parse_lit(p);
hi = lit.span;
@ -1080,6 +1113,12 @@ fn op_eq(token.token a, token.token b) -> bool {
ret @spanned(lo, rhs.span,
ast.expr_assign_op(aop, lhs, rhs, ast.ann_none));
}
case (token.SEND) {
p.bump();
auto rhs = parse_expr(p);
ret @spanned(lo, rhs.span,
ast.expr_send(lhs, rhs, ast.ann_none));
}
case (_) { /* fall through */ }
}
ret lhs;