diff src/elab_print.sml @ 9:14b533dbe6cc

Added simple expression constructors to Elab
author Adam Chlipala <adamc@hcoop.net>
date Sat, 26 Jan 2008 17:26:14 -0500
parents a455a9f85cc3
children e97c6d335869
line wrap: on
line diff
--- a/src/elab_print.sml	Sat Jan 26 17:10:26 2008 -0500
+++ b/src/elab_print.sml	Sat Jan 26 17:26:14 2008 -0500
@@ -128,6 +128,45 @@
         
 and p_con env = p_con' false env
 
+fun p_exp' par env (e, _) =
+    case e of
+        ERel n => string (#1 (E.lookupERel env n) ^ "_" ^ Int.toString n)
+      | ENamed n => string (#1 (E.lookupENamed env n) ^ "__" ^ Int.toString n)
+      | EApp (e1, e2) => parenIf par (box [p_exp env e1,
+                                           space,
+                                           p_exp' true env e2])
+      | EAbs (x, t, e) => parenIf par (box [string "fn",
+                                            space,
+                                            string x,
+                                            space,
+                                            string ":",
+                                            space,
+                                            p_con env t,
+                                            space,
+                                            string "=>",
+                                            space,
+                                            p_exp (E.pushERel env x t) e])
+      | ECApp (e, c) => parenIf par (box [p_exp env e,
+                                          space,
+                                          string "[",
+                                          p_con env c,
+                                          string "]"])
+      | ECAbs (exp, x, k, e) => parenIf par (box [string "fn",
+                                                  space,
+                                                  string x,
+                                                  space,
+                                                  p_explicitness exp,
+                                                  space,
+                                                  p_kind k,
+                                                  space,
+                                                  string "=>",
+                                                  space,
+                                                  p_exp (E.pushCRel env x k) e])
+
+      | EError => string "<ERROR>"
+
+and p_exp env = p_exp' false env
+
 fun p_decl env ((d, _) : decl) =
     case d of
         DCon (x, n, k, c) => box [string "con",
@@ -143,6 +182,19 @@
                                   string "=",
                                   space,
                                   p_con env c]
+      | DVal (x, n, t, e) => box [string "val",
+                                  space,
+                                  string x,
+                                  string "__",
+                                  string (Int.toString n),
+                                  space,
+                                  string ":",
+                                  space,
+                                  p_con env t,
+                                  space,
+                                  string "=",
+                                  space,
+                                  p_exp env e]
 
 fun p_file env file =
     let