about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-07-23 12:20:20 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-07-23 12:20:20 -0700
commit7d44ee7c3ccd051ec6e205fc07b1bd63cf58a9f6 (patch)
treeb7a964c452d44239618c2f915f06035be604d569 /src
parent4d4fa99b314c78ff50f744beace5f2b62b211df1 (diff)
downloadrust-7d44ee7c3ccd051ec6e205fc07b1bd63cf58a9f6.tar.gz
rust-7d44ee7c3ccd051ec6e205fc07b1bd63cf58a9f6.zip
Add pretty-printing for alt-tag statements.
Diffstat (limited to 'src')
-rw-r--r--src/boot/fe/ast.ml33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/boot/fe/ast.ml b/src/boot/fe/ast.ml
index 511ca33c14c..767a64265ca 100644
--- a/src/boot/fe/ast.ml
+++ b/src/boot/fe/ast.ml
@@ -1195,13 +1195,44 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
           fmt_atom ff at;
           fmt ff ";"
 
-      | STMT_alt_tag _ -> fmt ff "?stmt_alt_tag?"
+      | STMT_alt_tag at ->
+          fmt_obox ff;
+          fmt ff "alt (";
+          fmt_lval ff at.alt_tag_lval;
+          fmt ff ") ";
+          fmt_obr ff;
+          Array.iter (fmt_arm ff) at.alt_tag_arms;
+          fmt_cbb ff;
+
       | STMT_alt_type _ -> fmt ff "?stmt_alt_type?"
       | STMT_alt_port _ -> fmt ff "?stmt_alt_port?"
       | STMT_note _ -> fmt ff "?stmt_note?"
       | STMT_slice _ -> fmt ff "?stmt_slice?"
   end
 
+and fmt_arm (ff:Format.formatter) (arm:arm) : unit =
+  let (pat, block) = arm.node in
+    fmt ff "@\n";
+    fmt_obox ff;
+    fmt ff "case (";
+    fmt_pat ff pat;
+    fmt ff ") ";
+    fmt_obr ff;
+    fmt_stmts ff block.node;
+    fmt_cbb ff;
+
+and fmt_pat (ff:Format.formatter) (pat:pat) : unit =
+  match pat with
+      PAT_lit lit ->
+        fmt_lit ff lit
+    | PAT_tag (ctor, pats) ->
+        fmt_lval ff ctor;
+        fmt_bracketed_arr_sep "(" ")" "," fmt_pat ff pats
+    | PAT_slot (_, ident) ->
+        fmt_ident ff ident
+    | PAT_wild ->
+        fmt ff "_"
+
 and fmt_decl_param (ff:Format.formatter) (param:ty_param) : unit =
   let (ident, (i, e)) = param in
   fmt_effect ff e;