提交 9ca7acb1 编写于 作者: B Brian Anderson 提交者: Graydon Hoare

Update pretty printer for ports, channels, send and receive

上级 ebc4df3c
......@@ -1621,6 +1621,8 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
case (ast.expr_assign(_,_,_)) { ret true; }
case (ast.expr_assign_op(_,_,_,_))
{ ret true; }
case (ast.expr_send(_,_,_)) { ret true; }
case (ast.expr_recv(_,_,_)) { ret true; }
case (ast.expr_field(_,_,_)) { ret true; }
case (ast.expr_index(_,_,_)) { ret true; }
case (ast.expr_path(_,_,_)) { ret true; }
......
......@@ -78,6 +78,8 @@ fn ty_to_str(&@ast.ty ty) -> str {
case (ast.ty_str) {wrd(s, "str");}
case (ast.ty_box(?mt)) {wrd(s, "@"); print_mt(s, mt);}
case (ast.ty_vec(?mt)) {wrd(s, "vec["); print_mt(s, mt); wrd(s, "]");}
case (ast.ty_port(?t)) {wrd(s, "port["); print_type(s, t); wrd(s, "]");}
case (ast.ty_chan(?t)) {wrd(s, "chan["); print_type(s, t); wrd(s, "]");}
case (ast.ty_type) {wrd(s, "type");}
case (ast.ty_tup(?elts)) {
wrd(s, "tup");
......@@ -481,6 +483,18 @@ fn ty_to_str(&@ast.ty ty) -> str {
wrd1(s, "=");
print_expr(s, rhs);
}
case (ast.expr_send(?lhs, ?rhs, _)) {
print_expr(s, lhs);
space(s);
wrd1(s, "<|");
print_expr(s, rhs);
}
case (ast.expr_recv(?lhs, ?rhs, _)) {
print_expr(s, lhs);
space(s);
wrd1(s, "<-");
print_expr(s, rhs);
}
case (ast.expr_field(?expr,?id,_)) {
print_expr(s, expr);
wrd(s, ".");
......@@ -541,6 +555,17 @@ fn ty_to_str(&@ast.ty ty) -> str {
}
// TODO: extension 'body'
}
case (ast.expr_port(_)) {
wrd(s, "port");
popen(s);
pclose(s);
}
case (ast.expr_chan(?expr, _)) {
wrd(s, "chan");
popen(s);
print_expr(s, expr);
pclose(s);
}
}
end(s);
}
......@@ -563,7 +588,14 @@ fn ty_to_str(&@ast.ty ty) -> str {
alt (loc.init) {
case (option.some[ast.initializer](?init)) {
space(s);
wrd1(s, "=");
alt (init.op) {
case (ast.init_assign) {
wrd1(s, "=");
}
case (ast.init_recv) {
wrd1(s, "<-");
}
}
print_expr(s, init.expr);
}
case (_) {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册