aboutsummaryrefslogtreecommitdiff
path: root/src/comp/pretty
diff options
context:
space:
mode:
authorBrian Anderson <[email protected]>2011-03-24 23:03:12 -0400
committerGraydon Hoare <[email protected]>2011-03-25 11:01:52 -0700
commit9ca7acb1f3455f76a7991ce675a46aaa228aa497 (patch)
tree8dcb26a54f0701148882af0ee88213e4745c79fd /src/comp/pretty
parentImplement local declarations with receive. Un-XFAIL decl-with-recv.rs. (diff)
downloadrust-9ca7acb1f3455f76a7991ce675a46aaa228aa497.tar.xz
rust-9ca7acb1f3455f76a7991ce675a46aaa228aa497.zip
Update pretty printer for ports, channels, send and receive
Diffstat (limited to 'src/comp/pretty')
-rw-r--r--src/comp/pretty/pprust.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/comp/pretty/pprust.rs b/src/comp/pretty/pprust.rs
index 10cc5355..589ee0c3 100644
--- a/src/comp/pretty/pprust.rs
+++ b/src/comp/pretty/pprust.rs
@@ -78,6 +78,8 @@ impure fn print_type(ps s, &@ast.ty ty) {
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 @@ impure fn print_expr(ps s, &@ast.expr expr) {
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 @@ impure fn print_expr(ps s, &@ast.expr expr) {
}
// 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 @@ impure fn print_decl(ps s, @ast.decl decl) {
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 (_) {}