aboutsummaryrefslogtreecommitdiff
path: root/src/comp
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
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')
-rw-r--r--src/comp/front/parser.rs2
-rw-r--r--src/comp/pretty/pprust.rs34
2 files changed, 35 insertions, 1 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index a903124d..80130ebf 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -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; }
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 (_) {}