diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-08-02 11:15:32 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-08-02 11:15:32 -0400 |
commit | 49c123050b2bc8a24f250fcc0d55e49484bc604c (patch) | |
tree | 9dfcca82a4a6629190d044d10950f50872dbe52e /src/core_print.sml | |
parent | 16d3d1c3a6d1e78faab91076c20b76fdcb90edb9 (diff) |
Case through corify
Diffstat (limited to 'src/core_print.sml')
-rw-r--r-- | src/core_print.sml | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/core_print.sml b/src/core_print.sml index 28080bfa..7458fef0 100644 --- a/src/core_print.sml +++ b/src/core_print.sml @@ -152,6 +152,43 @@ fun p_enamed env n = string (#1 (E.lookupENamed env n))) handle E.UnboundNamed _ => string ("UNBOUNDN_" ^ Int.toString n) +fun p_con_named env n = + (if !debug then + string (#1 (E.lookupConstructor env n) ^ "__" ^ Int.toString n) + else + string (#1 (E.lookupConstructor env n))) + handle E.UnboundNamed _ => string ("CONSTRUCTOR_" ^ Int.toString n) + +fun p_patCon env pc = + case pc of + PConVar n => p_con_named env n + | PConFfi (m, x) => box [string "FFI(", + string m, + string ".", + string x, + string ")"] + +fun p_pat' par env (p, _) = + case p of + PWild => string "_" + | PVar s => string s + | PPrim p => Prim.p_t p + | PCon (n, NONE) => p_patCon env n + | PCon (n, SOME p) => parenIf par (box [p_patCon env n, + space, + p_pat' true env p]) + | PRecord xps => + box [string "{", + p_list_sep (box [string ",", space]) (fn (x, p) => + box [string x, + space, + string "=", + space, + p_pat env p]) xps, + string "}"] + +and p_pat x = p_pat' false x + fun p_exp' par env (e, _) = case e of EPrim p => Prim.p_t p @@ -162,6 +199,10 @@ fun p_exp' par env (e, _) = string (#1 (E.lookupERel env n))) handle E.UnboundRel _ => string ("UNBOUND_" ^ Int.toString n)) | ENamed n => p_enamed env n + | ECon (n, NONE) => p_con_named env n + | ECon (n, SOME e) => parenIf par (box [p_con_named env n, + space, + p_exp' true env e]) | EFfi (m, x) => box [string "FFI(", string m, string ".", string x, string ")"] | EFfiApp (m, x, es) => box [string "FFI(", string m, @@ -249,6 +290,19 @@ fun p_exp' par env (e, _) = p_con' true env c]) | EFold _ => string "fold" + | ECase (e, pes, _) => parenIf par (box [string "case", + space, + p_exp env e, + space, + string "of", + space, + p_list_sep (box [space, string "|", space]) + (fn (p, e) => box [p_pat env p, + space, + string "=>", + space, + p_exp env e]) pes]) + | EWrite e => box [string "write(", p_exp env e, string ")"] |