Fix indentation in GPL headers
[hcoop/domtool2.git] / src / print.sml
index 7f182b9..9305714 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*)
+ *)
 
 (* Pretty-printing Domtool configuration file ASTs *)
 
@@ -58,7 +58,14 @@ fun p_typ' pn (t, _) =
        parenIf pn [p_typ' true t1, space 1, string "->", space 1, p_typ' true t2]
       | TAction (p, r1, r2) =>
        parenIf pn [p_predBoxed p, space 1, p_record r1, space 1,
-                   string "->", space 1, p_record r2]
+                   string "=>", space 1, p_record r2]
+      | TNested (p, t) =>
+       parenIf pn [p_pred' false p, space 1, string "=>", space 1, p_typ' false t]
+
+      | TError => string "<error>"
+      | TUnif (_, ref (SOME t)) => p_typ' pn t
+      | TUnif (name, ref NONE) => string ("<" ^ name ^ ">")
+
 and p_record r =
     case StringMap.foldri (fn (name, t, d) =>
                              SOME (case d of
@@ -86,13 +93,17 @@ fun p_exp (e, _) =
             NONE => string "[]"
           | SOME d => dBox [string "[", d, string "]"])
 
-      | ELam (x, t, e) => dBox [string "(\\", space 1, string x, space 1,
+      | ELam (x, NONE, e) => dBox [string "(\\", space 1, string x, space 1,
+                               string "->", space 1, p_exp e, string ")"]
+      | ELam (x, SOME t, e) => dBox [string "(\\", space 1, string x, space 1,
                                string ":", space 1,
                                dBox [string "(", p_typ t, string ")"],
                                space 1, string "->", space 1, p_exp e, string ")"]
+
       | EVar x => string x
       | EApp (e1, e2) => dBox [string "(", p_exp e1, break {nsp = 1, offset = 0}, p_exp e2, string ")"]
 
+      | ESkip => string "_"
       | ESet (x, e) => dBox [string x, space 1, string "=", space 1, p_exp e]
       | EGet (x1, x2, e) => dBox [dBox [string x1, space 1, string "<-",
                                        space 1, string x2, string ";", space 1],
@@ -100,14 +111,15 @@ fun p_exp (e, _) =
       | ESeq es => dBox (valOf (foldr (fn (e, NONE) => SOME [p_exp e]
                                        | (e, SOME ds) => SOME (dBox [p_exp e, string ";", space 1] :: ds))
                                      NONE es))
-      | ELocal (ESeq [e1, e2], _) => dBox [string "let", space 1,
-                                          p_exp e1, space 1,
-                                          string "in", space 1,
-                                          p_exp e2, space 1,
-                                          string "end"]
-      | ELocal _ => raise Fail "Unexpected ELocal form"
-
-fun print d =
+      | ELocal (e1, e2) => dBox [string "let", space 1,
+                                p_exp e1, space 1,
+                                string "in", space 1,
+                                p_exp e2, space 1,
+                                string "end"]
+      | EWith (e1, (ESkip, _)) => dBox [p_exp e1, space 1, string "with", space 1, string "end"]
+      | EWith (e1, e2) => dBox [p_exp e1, space 1, string "with", p_exp e2, space 1, string "end"]
+
+fun printd d =
     let
        val myStream = SM.openOut {dst = TextIO.stdOut,
                                   wid = 80}